I have several items that need to be "checked" on a drop down menu list. When you click one to check it, the list disappears. Is there a way to keep the menu list "dropped down"?
Later,
Clint
Not that I'm aware of. The left click is what triggers the closing of the menu and as far as I can tell from reading the SDK there is no external message or flag that I can see.
If you could keep a menu open while left clicking on it then what would signify that you actually made a selection and wanted to close the menu?
What are you wanting to do that makes you want to open a menu and select multiple menu items without actually "selecting" a menu option?
Maybe if I can understand that I can help you.
This is the best I could come up with for you.
The following allows you to RIGHT-CLICK on menu items (in the 2nd menu dropdown only, by design) and toggle each item's checkmark.
This does not impact the ability to LEFT-CLICK a menu item and close the dropdown as usual.
The one minor visual glitch is that the checkmark will not appear/disappear after right-clicking until you move the mouse off the item.
Maybe this will do what you are needing.
/*
Example of right clicking to check multiple menu options without selecting
*/
CONST MF_UNCHECKED = 0x00000000
CONST MF_CHECKED = 0x00000008
CONST WM_MENURBUTTONUP = 0x122
DECLARE IMPORT,CheckMenuItemA ALIAS CheckMenuItem(hmenu as UINT,id as UINT,nFlags as UINT),INT
DECLARE IMPORT,GetMenuState(hMenu:INT, wID:INT, wFlags:INT),INT
DECLARE IMPORT,GetMenu(hwnd as UINT),UINT
DECLARE IMPORT,GetSubMenu(hMenu as UINT,pos as INT),UINT
DEF w1 as WINDOW
OPENWINDOW w1,0,0,350,350,@MINBOX|@MAXBOX|@SIZE,0,"Simple Window",&main
BEGINMENU w1
MENUTITLE "Skip"
MENUITEM "Print", 0, 10
MENUITEM "Quit", 0, 20
SEPARATOR
MENUITEM "no Check me", 0, 30
MENUTITLE "Option"
MENUITEM "Print", 0, 40
SEPARATOR
MENUITEM "Check me", 0, 50
ENDMENU
WAITUNTIL w1 = 0
END
SUB main(),int
SELECT @MESSAGE
case WM_MENURBUTTONUP
'@lparam contains the handle to the dropdown meun
'@wparam contains the 0 based index of the menu item
IF w1.hwnd 'got to make sure we have a window handle
uint hmenu = GetMenu(w1.hwnd) 'get the handle to the main menu bar
IF hmenu THEN hmenu = GetSubMenu(hmenu,1) 'get the 0 based index to the drop down menu we want this to work on
'using a 1 here makes this work only for the 2nd main menu dropdown
IF hmenu=@lparam ' if equal it means we're in the correct submenu
int wFlags=0x400 'this toggles the check
if (GetMenuState(@lparam,@wparam, wFlags) & MF_CHECKED)=MF_CHECKED
CheckMenuItemA(@lparam,@wparam,0x400 )
else
CheckMenuItemA(@lparam,@wparam,0x400 | 0x8)
endif
endif
endif
CASE @IDCREATE
CENTERWINDOW w1
CASE @IDCLOSEWINDOW
REM closes the window and sets w1 = 0
CLOSEWINDOW w1
CASE @IDMENUPICK
SELECT @MENUNUM
CASE 10: ' user selected Print
PRINTWINDOW w1
CASE 20: ' user selected Quit
CLOSEWINDOW w1
CASE 50:
messagebox w1, "left click still selects","",0
ENDSELECT
ENDSELECT
RETURN 0
ENDSUB
Thanks LarryMc,
It is something a customer wanted. I ended up sending virtual keystrokes to drop down the menu again when an item was selected. You have to click outside of the list to close it. I'm going to look at what you sent.
Later,
Clint