I've created a nice menu bar in a dialog with nested pop-up menus using the DDT MENU commands.
The problem I'm having is that I cannot get the MENU SET STATE statement (are the pos& & state& parameters backwards from the docs?) to work with either the main menu handle or the nested menu handles. I am using the MENU DRAW BAR statement afterwards, but to no effect.
Also, the MENU GET TEXT returns empty strings every time:
' ** Create a new dialog template
DIALOG NEW 0, $Title, ,, 300, 200, %WS_POPUPWINDOW OR %WS_CAPTION OR _
%WS_MAXIMIZEBOX OR %WS_MINIMIZEBOX OR %WS_SIZEBOX TO hDlg&
' Add a menu bar to the GUI
MENU NEW BAR TO hMenu&
' Create a popup menu "File"
MENU NEW POPUP TO hFile&
MENU ADD STRING, hFile&, "E&xit", %IDCANCEL, %MF_ENABLED, CALL CancelButton
' Attach the popup menu to the menu bar
MENU ADD POPUP, hMenu&, "&File", hFile&, %MF_ENABLED
' Create a popup menu "Edit"
MENU NEW POPUP TO hEdit&
MENU NEW POPUP TO hFirstEd&
MENU ADD STRING, hFirstEd&, "&One", %ONE, %MF_ENABLED, CALL OneButton
MENU ADD STRING, hFirstEd&, "&Two", %TWO, %MF_DISABLED, CALL TwoButton
...
MENU ADD POPUP, hEdit&, "&First Edit Line", hFirstEd&, %MF_ENABLED
MENU NEW POPUP TO hSecEd&
MENU ADD STRING, hSecEd&, "&TwoOne", %TWOONE, %MF_ENABLED, CALL TwoOneButton
MENU ADD STRING, hSecEd&, "T&woTwo", %TWOTWO, %MF_ENABLED, CALL TwoTwoButton
...
MENU ADD POPUP, hEdit&, "&Second Edit Line", hSecEd&, %MF_ENABLED
...
' Attach the popup menu to the menu bar
MENU ATTACH hMenu&, hDlg&
I& = 0
DIALOG SHOW MODELESS hDlg&
DO
DIALOG DOEVENTS
IF I& = 1 THEN
INCR I&
MENU GET TEXT hFirstEd&, %ONE TO T$
MSGBOX "hFirstEd Text = <"+T$+">"
MENU GET TEXT hMenu&, %ONE TO T$
MSGBOX "hMenu Text = <"+T$+">"
END IF
IF I& = 0 THEN
INCR I&
MENU SET STATE hMenu&, %MF_GRAYED, BYCMD %ONE
MENU SET STATE hMenu&, %MF_ENABLED, BYCMD %TWO
MENU DRAW BAR hDlg&
END IF
DIALOG GET SIZE hDlg& TO x&, x&
LOOP UNTIL x& = 0
------------------
Bernard Ertl
[This message has been edited by Bern Ertl (edited January 31, 2001).]
The problem I'm having is that I cannot get the MENU SET STATE statement (are the pos& & state& parameters backwards from the docs?) to work with either the main menu handle or the nested menu handles. I am using the MENU DRAW BAR statement afterwards, but to no effect.
Also, the MENU GET TEXT returns empty strings every time:
' ** Create a new dialog template
DIALOG NEW 0, $Title, ,, 300, 200, %WS_POPUPWINDOW OR %WS_CAPTION OR _
%WS_MAXIMIZEBOX OR %WS_MINIMIZEBOX OR %WS_SIZEBOX TO hDlg&
' Add a menu bar to the GUI
MENU NEW BAR TO hMenu&
' Create a popup menu "File"
MENU NEW POPUP TO hFile&
MENU ADD STRING, hFile&, "E&xit", %IDCANCEL, %MF_ENABLED, CALL CancelButton
' Attach the popup menu to the menu bar
MENU ADD POPUP, hMenu&, "&File", hFile&, %MF_ENABLED
' Create a popup menu "Edit"
MENU NEW POPUP TO hEdit&
MENU NEW POPUP TO hFirstEd&
MENU ADD STRING, hFirstEd&, "&One", %ONE, %MF_ENABLED, CALL OneButton
MENU ADD STRING, hFirstEd&, "&Two", %TWO, %MF_DISABLED, CALL TwoButton
...
MENU ADD POPUP, hEdit&, "&First Edit Line", hFirstEd&, %MF_ENABLED
MENU NEW POPUP TO hSecEd&
MENU ADD STRING, hSecEd&, "&TwoOne", %TWOONE, %MF_ENABLED, CALL TwoOneButton
MENU ADD STRING, hSecEd&, "T&woTwo", %TWOTWO, %MF_ENABLED, CALL TwoTwoButton
...
MENU ADD POPUP, hEdit&, "&Second Edit Line", hSecEd&, %MF_ENABLED
...
' Attach the popup menu to the menu bar
MENU ATTACH hMenu&, hDlg&
I& = 0
DIALOG SHOW MODELESS hDlg&
DO
DIALOG DOEVENTS
IF I& = 1 THEN
INCR I&
MENU GET TEXT hFirstEd&, %ONE TO T$
MSGBOX "hFirstEd Text = <"+T$+">"
MENU GET TEXT hMenu&, %ONE TO T$
MSGBOX "hMenu Text = <"+T$+">"
END IF
IF I& = 0 THEN
INCR I&
MENU SET STATE hMenu&, %MF_GRAYED, BYCMD %ONE
MENU SET STATE hMenu&, %MF_ENABLED, BYCMD %TWO
MENU DRAW BAR hDlg&
END IF
DIALOG GET SIZE hDlg& TO x&, x&
LOOP UNTIL x& = 0
------------------
Bernard Ertl
[This message has been edited by Bern Ertl (edited January 31, 2001).]
Comment