Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;Menu buttons ;Guido 10/03 ;Note: The menu button is a checkbox in the dialog editor, you later change ; the style to pushlike. ;Creates a popup menu ;items : '|' delimited list of menu item names ;Returns : menu handle #definefunction MNCreate(items) user32=strcat(dirwindows(1),"user32.dll") MF_STRING=0 hmenu=dllcall(user32,long:"CreatePopupMenu") for id=1 to itemcount(items,"|") dllcall(user32,long:"AppendMenuA",long:hmenu,long:MF_STRING,long:id,lpstr:itemextract(id,items,"|")) next return hmenu #endfunction ;Shows a popup menu and waits for selection ;hdlg : dialog handle ;hmenu : menu handle ;hbut : button handle ;Returns : position in list of selected menu item #definefunction MNTrackMenu(hdlg,hmenu,hbut) user32=strcat(dirwindows(1),"user32.dll") RECT=binaryalloc(16) HWND_DESKTOP=0 TPM_LEFTALIGN=0 TPM_LEFTBUTTON=0 TPM_VERTICAL=64 TPM_RETURNCMD=256 dllcall(user32,long:"GetClientRect",long:hbut,lpbinary:RECT) dllcall(user32,long:"MapWindowPoints",long:hbut,long:HWND_DESKTOP,lpbinary:RECT,long:2) r=dllcall(user32,long:"TrackPopupMenuEx",long:hmenu,long:TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL|TPM_RETURNCMD,long:binarypeek4(RECT,0),long:binarypeek4(RECT,12),long:hdlg,lpnull) binaryfree(RECT) return r #endfunction ;Destroys a menu ;hmenu : menu handle #definefunction MNDestroy(hmenu) user32=strcat(dirwindows(1),"user32.dll") return dllcall(user32,long:"DestroyMenu",long:hmenu) #endfunction ;+------------------------------------------------------ ;TEST #definesubroutine dlgproc(hdlg,msg,id,p4,p5) select msg case 0 user32=strcat(dirwindows(1),"user32.dll") GWL_STYLE=-16 BS_PUSHLIKE=4096 ;give checkbox pushlike style hbut=dllcall(user32,long:"GetDlgItem",long:hdlg,long:100) ;100=button id, got with roboscripter os=dllcall(user32,long:"GetWindowLongA",long:hbut,long:GWL_STYLE) dllcall(user32,long:"SetWindowLongA",long:hbut,long:GWL_STYLE,long:os|BS_PUSHLIKE) ;create menu hmenu=MNCreate("Option1|Option2") DialogProcOptions(hdlg,2,1) ;buttons DialogProcOptions(hdlg,4,1) ;checkbox break case 4 ;checkbutton select id case 2 dialogcontrolset(hdlg,2,1,1) ;check button select MNTrackMenu(hdlg,hmenu,hbut) case 1 message("","option1") break case 2 message("","option2") break endselect dialogcontrolset(hdlg,2,1,0) ;uncheck button return -2 endselect case 2 ;button select id case 1 ;cancel, destroy menu MNDestroy(hmenu) return -1 endselect endselect return -1 #endsubroutine MyDialogFormat=`WWWDLGED,6.1` MyDialogCaption=`Menu Button` MyDialogX=029 MyDialogY=046 MyDialogWidth=246 MyDialogHeight=130 MyDialogNumControls=002 MyDialogProcedure=`dlgproc` MyDialogFont=`DEFAULT` MyDialogTextColor=`DEFAULT` MyDialogBackground=`DEFAULT,DEFAULT` MyDialogConfig=0 MyDialog001=`071,013,036,012,PUSHBUTTON,DEFAULT,"Cancel",2,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog002=`011,013,044,012,CHECKBOX,MyVariable1,"Option",1,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ButtonPushed=Dialog("MyDialog")
Article ID: W15921
File Created: 2004:03:30:15:41:42
Last Updated: 2004:03:30:15:41:42