>>DEFINE BAR 610 OF moviewpop PROMPT "Always on \<Top" ; >> SKIP FOR not docmd("SET MARK OF BAR 610 OF moviewpop TO _screen.AlwaysOnTop") ; && force refresh as nec. >> MESSAGE "Toggle whether to keep this " + MONT_APPNAME + " Desktop in front of other windows." >>ON SELECTION BAR 610 OF moviewpop _screen.AlwaysOnTop = not _screen.AlwaysOnTop && toggle the setting >>SET MARK OF BAR 610 OF moviewpop TO _screen.AlwaysOnTop >>>>
>DEFINE PAD sessioninfo OF (m.cMenuName) PROMPT "\<Session info" COLOR SCHEME 3 ; > KEY ALT+S, "" ; > SKIP FOR isnull( goMainWindow ) or empty( goMainWindow.cMPSFile ) >>goMainWindow is a global variable that holds a reference to the form.
> lcMenuName = "" > do BasicMenuSM.mpr with this, lcMenuName, .t., .t. > thisform.cMenuName = lcMenuName >>So, there is a userdefined property cMenuName. I'll need it later.
>lparameter tcAction, tuP1 > >local lcAction, lox, i > >lcAction = lower( tcAction ) > >with thisform > > do case > case inlist( lcAction, 'init', 'menu init' ) > * > if empty( .cMPSFile ) > RETURN .F. > endif > * > if lcAction = 'menu init' > * Pad named 'sessioninfo' has already been predeclared > * in the menu BasicMenuSM.mnx. > ON PAD sessioninfo OF (thisform.cMenuName ) activate popup treeview > DEFINE POPUP treeview MARGIN RELATIVE SHADOW COLOR SCHEME 4 > else > DEFINE POPUP treeview SHORTCUT RELATIVE FROM MROW(),MCOL() > endif > > * Use goMainWindow instead of thisform, because menusystem > * can't handle thisform, but it can handle goMainWindow. > DEFINE BAR 1 OF treeview PROMPT "E\<xpand all" > DEFINE BAR 2 OF treeview PROMPT "\<Collapse all" ; > skip for not goMainWindow.pgf.pagMain.oleTreeview.Nodes(1).Expanded > DEFINE BAR 7 OF treeview PROMPT "Show current \<actions" > > * > ON SELECTION BAR 1 OF treeview goMainWindow.TreeviewMenu( '+' ) > ON SELECTION BAR 2 OF treeview goMainWindow.TreeviewMenu( '-' ) > ON SELECTION BAR 7 OF treeview goMainWindow.TreeviewMenu( 'actions' ) > * > set mark of bar 7 of treeview to goMainWindow.lShowActions > * > if lcAction == 'init' > activate popup treeview > endif > > case lcAction = 'menu remove' > * > release popup treeview && will not generate an error if it still doesn't exist > > case inlist( lcAction, "+-", "+", "-" ) > > do case > case lcAction == "+-" && This action indicates that the current setting must be used. > case lcAction == "+" && Let's expand. > .lExpanded = .T. > case lcAction == "-" && Let's collapse > .lExpanded = .F. > endcase > > lox = .pgf.pagMain.oleTreeview > .lockscreen = .t. > lox.visible = .f. > > FOR i = 1 TO lox.Nodes.Count > lox.Nodes(i).Expanded = .lExpanded > ENDFOR > > lox.visible = .t. > lox.setfocus() > > .lockscreen = .f. > > case lcAction = 'actions' > * > .lShowActions = not .lShowActions > .filltreeview() && refreshes treeview > .TreeViewMenu( "+-" ) > set mark of bar 7 of treeview to goMainWindow.lShowActions > .refresh() > > endcase > >endwith > >RETURN .T. >>The MouseDown() event of the treeview contains this code...
>*** ActiveX Control Event *** >LPARAMETERS button, shift, x, y > >if button = 2 and shift = 0 && if rightclick > * > thisform.treeviewmenu( 'init' ) >endif >>And there's also a method that's responsible for the just-in-time declaration of the popup of the sessioninfo menu pad. In my case it is in the method that acts on a selected file. The crucial code herein is...
>with thisform > ... > if not .CreateCursors() && creates a cursor that's used to fill the treeview > * > if reccount( 'c_treeview' ) = 0 > * > .cMPSFile = "" > .TreeviewMenu( "menu remove" ) > .pgf.pagMain.oleTreeview.nodes.clear() > endif > .refresh() > else > .TreeviewMenu( "menu init" ) > .TreeviewMenu( "+-" ) > .refresh() > endif >endwith >>The crux is that the main menu must have been updated BEFORE the user rightclicks on the treeview! If that's not the case, then the main menu's treeview popup will be at the wrong place with the wrong color scheme.