Collapse a categorized embedded View by default

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.

expanded embedded View

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…


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: since I have no option here to upload a file (?).

Thanks in advance for reading!

 // KR Patrick


9 thoughts on “Collapse a categorized embedded View by default

  1. Juan F. Ruiz 2006-November-2 / 12:47 am

    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?


  2. Juan F. Ruiz 2006-November-9 / 10:49 pm


    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 … :-/

  3. Uriel Hernandez 2007-September-10 / 8:06 pm

    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).

  4. raz 2008-May-15 / 3:25 am

    Great code..but what about embedded views with a single category? (given the postopen event has already occurred)

  5. erik 2009-October-6 / 10:01 am

    great code…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s