lparameter tcAction, tcMenuName > >local llExpanded, lcAction, lox, i > >lcAction = lower( tcAction ) > >with thisform > > do case > case inlist( lcAction, 'init shortcut', 'init main' ) > * > with thisform.pgf.pagMain.oleTreeview > * > llExpanded = .Nodes(1).Expanded > >* This call is not appropriate if 'init main' is intended. But what is appropriate then? > DEFINE POPUP treeview SHORTCUT RELATIVE FROM MROW(),MCOL() > > DEFINE BAR 1 OF treeview PROMPT "E\<xpand all" > DEFINE BAR 2 OF treeview PROMPT "\<Collapse all" skip for not llExpanded > * etc.. > endwith > * > ON SELECTION BAR 1 OF treeview goMainWindow.TreeviewMenu( '+' ) > ON SELECTION BAR 2 OF treeview goMainWindow.TreeviewMenu( '-' ) > * etc.. > * >* This call is not appropriate if 'init main' is intended. But what is appropriate then? > activate popup treeview > > 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 etc... > endcase > >endwith>
goMainWindow.TreeviewMenu( "init main" , "&cMenuName.")>
* define the main menu pad for the Format submenu DEFINE PAD mofmtpad OF _MSYSMENU PROMPT "Format" COLOR SCHEME 3 ; AFTER moviewpad ; KEY ALT+O, "" ; MESSAGE "Text and image formatting options." * cause the Format submenu to appear when its main menu pad is selected ON PAD mofmtpad OF _MSYSMENU ACTIVATE POPUP mofmtpop * define the Format submenu popup DEFINE POPUP mofmtpop MARGIN RELATIVE SHADOW COLOR SCHEME 4 * define various text Font-related menu bars contained in the Format submenu DEFINE BAR 10 OF mofmtpop PROMPT "\<Font..." ; SKIP FOR &skpfontif ; MESSAGE "Select a text font." ON SELECTION BAR 10 OF mofmtpop ; docmd("getfontx(&vwformname..moc_viewer)", "_screen.moc_main.mom_setenablements()") ...Going beyond syntactic differences, shortcut menus are typically generated dynamically each time they are invoked, while main menus are most commonly initialized once. You don't have to do things that way, but it's the least klunky way to use main menus. This imposes some limitations on how dynamic your main menus can be, since there's not much to work with besides the SKIP FOR clause. Of course you could have code to somehow refresh or modify the main menu on some basis, but this can easily get ugly and complicated.
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.AlwaysOnTopThe docmd() function is just a generic UDF that executes the specified command line(s), always returning .T. (Hence this is just a "dummy" SKIP FOR clause, since it never actually disables the menu bar.)