In previous versions of Notes an embedded View was NOT collapsed by default. Not realy user-friendly when the embedded view contains a large amount of categorized documents.

This posting describes how you can implement a mechanism that collapses the embedded View by default.
Intro: MS-Projects alike database
I received a request for a MS-Projects alike Notes database in which users could define a project and create a predefined set of (sub) documents. This whole set of documents (main + subs) represented a standard way of project management.
Because some documents were mandatory while others were optional the users should be able to create new sub-documents or delete those sub-documents that were optional but not desired.
In order to make the set of documents manageable from 1 central point the set of documents was presented via an categorized embedded View on the main project document.
So far no problems but what happened when the main document was being opened? The embedded View was expanded by default and in order to have a good overview of all the sub documents the user had to collapse every category manually…
User32.dll
The user32.dll file is a module that contains Windows API functions related the Windows user interface (Window handling, basic UI functions, and so forth). With the module you can monitor what key funtions are being used when a view is completely collapsed by a user. So why not use this module to mimic collapsing a view programmatically?
Collapse function
All of the possible keyboard functions (left mouse button, cancel key, the ‘a’ key etcetera) were described in one script-library and from this description two functions collapse and expand where defined.
In the database script Options this library was called, in order to have the functions ready when opening the database:
Use “KeyboardFunctions”
In the declarations of the script library the next code was declared:
Declare Sub keybd_event Lib “user32.dll” (Byval bVk As Integer, Byval bScan As Integer, Byval dwFlags As Integer, Byval dwExtraInfo As Integer)
This enables to write information (what user handlings to mimic) to the running application (Notes).
Here is a descriptive overview of handlings a user would do in order to collapse a view and set focus on the first document in the view:
- Pressing Page Down and space to get focus to embedded view
- Pressing Ctrl Home to get focus on the first view line
- Pressing – to collapse category
- Pressing arrow down key to go to next category
- Pressing Esc to get focus back on the form
- Pressing Ctrl Home to get focus on the first field in the form
- Pressing Ctrl Home to get focus on the first view line
For expanding the whole view the number of handings is much less:
- Pressing Ctrl End and space to get focus to embedded view
- Pressing Shift + to expand all categories
Postopen event – main document
In the main document the following code was placed in the Postopen event:
Sub Postopen(Source As Notesuidocument)
Call Collapse (True)
End Sub
From now on the embedded View was being collapsed every time the main document was opened, with a focus on the first view line (the first category in the view)! The user could navigate through the list of categories to the sub document he/she would like to work on:

Using the Collapse and Expand functions as look-a-like Action buttons
In a normal view you can use:
@Command( [ViewCollapseAll] ) and
@Command( [ViewExpandAll] ) to collapse or expand an entire view. With the Collapse and Functions under an Action Hotspot running LotusScript we could mimic that same feature for the embedded View.

The Expand Function has even got the ‘advantage’ that you remain focus on the selected category in the embedded View. At least this habbit is nice for improved user experience.


Reviewing the code
If you are interested in reviewing the code or see it running for yourself just send me a email to: info@quintessens.com since I have no option here to upload a file (?).
Thanks in advance for reading!
// KR Patrick
Juan F. Ruiz said
Hey, Patrick!
Good job! It’s very interesting and i think is a good workaround …
It’s a nice web, too. I like very much the logo … it’s a Bic pen?
Regards.
Patrick said
Hej Juan.
The pen is just a standard WordPress template. There are unfortunately not so many templates to choose from.
Other things you can do with a Bic-pen:
http://sth.sagepub.com/cgi/content/refs/30/1/52
Re: Collapse a categorized embedded View by default « All about Lotus Domino Development said
[...] In a previous article I explained how you can use the user key-events to collapse a categorized embedded View by default. [...]
Juan F. Ruiz said
Ooops!
Poor woman … a bad way to leave this world …
The content of that article recalls to me an scene of “Demolition Man” film, when Snipes uses a pen *with* the eye of prison’s director to bypass the iris-controled security system of a gate in the fuge … aaahg …
Usually, i use pens to write or bit it … :-/
Uriel Hernandez said
i like this code, it’s work’s but only if i have one embedded view, how can i make this work for multiple views in the same document. (the views are in a table with tabs).
Demo ‘collapse embedded view by default’ « All about Lotus Domino Development said
[...] September 29, 2007 at 8:16 pm · Filed under LotusScript, lotus notes Today it was here very rainy so I hate plenty of time to do those things you wtill wanted/needed/were asked to do. For example I receive frequently question to send a working example for collapsing an embedded view by default. I have explained the principles in a previous writing. [...]
quintessens said
here is a link to a working example:
http://www.divshare.com/download/2158175-8ae
raz said
Great code..but what about embedded views with a single category? (given the postopen event has already occurred)
erik said
great code…