Re: Collapse a categorized embedded View by default

Here is the Script library called ‘Keyboard_Functions’ used for the collapsing an embedded categorized view by default:

(Options)

Const vKY = 89 ‘Y key
Const vKZ = 90 ‘Z key
Const vK0 = 48 ‘0 key
Const vK1 = 49 ‘1 key
Const vK2 = 50 ‘2 key
Const vK3 = 51 ‘3 key
Const vK4 = 52 ‘4 key
Const vK5 = 53 ‘5 key
Const vK6 = 54 ‘6 key
Const vK7 = 55 ‘7 key
Const vK8 = 56 ‘8 key
Const vK9 = 57 ‘9 key
Const vKnP0 = 96 ‘0 key
Const vKnP1 = 97 ‘1 key
Const vKnP2 = 98 ‘2 key
Const vKnP3 = 99 ‘3 key
Const vKnP4 = 100 ‘4 key
Const vKnP5 = 101 ‘5 key
Const vKnP6 = 102 ‘6 key
Const vKnP7 = 103 ‘7 key
Const vKnP8 = 104 ‘8 key
Const vKnP9 = 105 ‘9 key
Const vKMultiply = 106 ‘MULTIPLICATION SIGN (*) key
Const vKAdd = 107 ‘PLUS SIGN (+) key
Const vKEnter = 108 ‘ENTER (keypad) key
Const vKSubtract = 109 ‘MINUS SIGN (-) key
Const vKDecimal = 110 ‘DECIMAL POINT(.) key
Const vKDivide = 111 ‘DIVISION SIGN (/) key
Const vKF1 = 112 ‘F1 key
Const vKF2 = 113 ‘F2 key
Const vKF3 = 114 ‘F3 key
Const vKF4 = 115 ‘F4 key
Const vKF5 = 116 ‘F5 key
Const vKF6 = 117 ‘F6 key
Const vKF7 = 118 ‘F7 key
Const vKF8 = 119 ‘F8 key
Const vKF9 = 120 ‘F9 key
Const vKF10 = 121 ‘F10 key
Const vKF11 = 122 ‘F11 key
Const vKF12 = 123 ‘F12 key
Const vKF13 = 124 ‘F13 key
Const vKF14 = 125 ‘F14 key
Const vKF15 = 126 ‘F15 key
Const vKF16 = 127 ‘F16 key

(Declarations)

Declare Sub keybd_event Lib “user32.dll” (Byval bVk As Integer, Byval bScan As Integer, Byval dwFlags As Integer, Byval dwExtraInfo As Integer)

Collapse

Function Collapse (focusonform As Integer)
 Dim i As Integer 
 ‘Pressing Page Down and SPACE to get focus to embedded view
 keybd_event vKControl , 0, KeyDown, 0
 keybd_event vKEnd , 0, KeyDown, 0
 keybd_event vKEnd , 0, KeyUp, 0
 keybd_event vKControl , 0, KeyUp, 0  
 keybd_event vKSpace, 0, KeyDown, 0
 keybd_event vKSpace, 0, KeyUp, 0  
 ‘Pressing CTRL HOME to get focus on the first view line
 keybd_event vKControl , 0, KeyDown, 0
 keybd_event vKHome , 0, KeyDown, 0
 keybd_event vKHome , 0, KeyUp, 0
 keybd_event vKControl , 0, KeyUp, 0  
 ‘Repeat for max 20 categories
 For i =1 To 20
 ‘Pressing – to collapse category
  keybd_event vKSubtract, 0, KeyDown, 0
  keybd_event vKSubtract, 0, KeyUp, 0   
 ‘Pressing arrow down key to go to next category
  keybd_event vKDown, 0, KeyDown, 0
  keybd_event vKDown, 0, KeyUp, 0   
 Next 
 If focusonform Then
  ‘Pressing Esc to get focus back on the form
  keybd_event vKEscape , 0, KeyDown, 0
  keybd_event vKEscape , 0, KeyUp, 0
  ‘Pressing Ctrl Home to get focus on the first field in the form
  keybd_event vKControl , 0, KeyDown, 0
  keybd_event vKHome , 0, KeyDown, 0
  keybd_event vKHome , 0, KeyUp, 0
  keybd_event vKControl , 0, KeyUp, 0   
 End If 
 ‘Pressing Ctrl Home to get focus on the first view line
 keybd_event vKControl , 0, KeyDown, 0
 keybd_event vKHome , 0, KeyDown, 0
 keybd_event vKHome , 0, KeyUp, 0
 keybd_event vKControl , 0, KeyUp, 0   
End Function

Expand

Function Expand
 ‘Pressing Ctrl + End and SPACE to get focus to embedded view
 keybd_event vKControl , 0, KeyDown, 0
 keybd_event vKEnd , 0, KeyDown, 0
 keybd_event vKEnd , 0, KeyUp, 0
 keybd_event vKControl , 0, KeyUp, 0  
 keybd_event vKSpace, 0, KeyDown, 0
 keybd_event vKSpace, 0, KeyUp, 0  
 ‘Pressing Shift + to expand all categories
 keybd_event vKShift , 0, KeyDown, 0
 keybd_event vKAdd , 0, KeyDown, 0
 keybd_event vKAdd , 0, KeyUp, 0
 keybd_event vKShift , 0, KeyUp, 0
End Function

previousTab

Sub previousTab
 ‘Ctrl-Shift-Tab
 keybd_event vKControl , 0, KeyDown, 0
 keybd_event vKShift , 0, KeyDown, 0  
 keybd_event vKTab, 0, KeyDown, 0
 keybd_event vKTab, 0, KeyUp, 0  
 keybd_event vKShift , 0, KeyUp, 0
 keybd_event vKControl , 0, KeyUp, 0
End Sub 

Goodluck!

Advertisements

10 thoughts on “Re: Collapse a categorized embedded View by default

  1. Doug 2007-January-15 / 3:51 pm

    Excellent! Many thanks.

  2. Phill Beckman 2007-February-16 / 4:08 pm

    Thanks for the code I found it useful in an application I am writing…

    You may want to consider re-writing the ‘expand’ to something like this which will open the first category level and could be called multiple times depending how far you want to expand your multi categorised view.

    Function Expand (uivw As notesuiview)

    Dim session As New NotesSession
    Dim view As NotesView
    Dim nav As NotesViewNavigator
    Dim entry As NotesViewEntry
    Dim catentry As NotesViewEntry
    Dim count As Integer
    Set view = uivw.View

    Set nav = view.CreateViewNav()
    Set entry = nav.GetLast()
    If entry Is Nothing Then Exit Function
    If entry.IsCategory Then
    Set catentry = entry
    Else
    Set catentry = nav.GetPrevCategory(entry)
    End If

    ‘Send Ctrl End to navigate to the bottom of the view
    keybd_event vKControl , 0, KeyDown, 0
    keybd_event vKEnd , 0, KeyDown, 0
    keybd_event vKEnd , 0, KeyUp, 0
    keybd_event vKControl , 0, KeyUp, 0

    ‘Expand 1 level of categories
    While Not catentry Is Nothing
    ‘Send a + to open the category
    keybd_event vKAdd , 0, KeyDown, 0
    keybd_event vKAdd , 0, KeyUp, 0
    ‘now send an up arrow to navigate to the previous category
    keybd_event vKUp , 0, KeyDown, 0
    keybd_event vKUp , 0, KeyUp, 0
    Set catentry = nav.GetPrevCategory(catentry)
    Wend

    ‘Finally send Down Arrow to highlight the first document in the view
    keybd_event vKDown , 0, KeyDown, 0
    keybd_event vKDown , 0, KeyUp, 0

    End Function

  3. Patrick 2007-March-8 / 5:15 pm

    Hej Phill,

    thanks for your contribution, but I get an error ‘variant does not contavin an object’. I did not have time to take a look at the error…

  4. Dave 2007-August-9 / 11:40 pm

    I tried this script, but it does not work, I get errors Variable not declared KEYUP.

    Any ideas?????

    Appreciate all the help and time.

    Thanks,

    Dave

  5. Uriel Hernandez 2007-September-10 / 8:05 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).

  6. Alex 2008-January-30 / 1:07 pm

    Thanks, probably a nice solution, but where do you call the Collapse function ? What event ? What object (form or embedded view… ? Can’t make it work…

    Thank you,

    Alex

  7. Evgeny 2008-April-7 / 4:08 pm

    Hi!
    I have 2 frames. In Top frame (NotesView) – View with my documents, in bottom frame (NotesPreview) – Form with Embedded View with responses and responses-to-responses documents. How can I Collapse this Embedded View?
    Thanks!

  8. quintessens 2008-April-7 / 10:30 pm

    @Evgeny: I have not used the code in this way but sure in the ‘sandbox’ you find a downloadable example, please test the example in your case scenario and let me know if it works…

  9. Ravi 2009-October-23 / 5:41 pm

    The expand all and collapse all are working now in 8.5.1 on an embedded view.

  10. Brad 2010-August-2 / 5:22 pm

    I’m having problems with keybd_event in 8.51, works sporadically or not at all. Do these not work in 8.51?

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s