Hi ! Everyone. Please teach me how to do this: :stupid:

- How to make program run only one Instance (When i double click on .exe many times , my program run only one time, and show message box : "This program already running"

- How to make menu invisible or visible
- How to make menu checked or unchecked
Posted on 2003-12-25 21:50:47 by neverending
Hi,

To force only one instance use this at the very start of your program

.data

mutex db "Any Unique String",0
.code
invoke CreateMutex,NULL,NULL,OFFSET mutex
invoke GetLastError
.IF eax == ERROR_ALREADY_EXISTS
invoke ExitProcess,0
.endif


To check or uncheck a menu item first find the handle to the menu bar, then to the submenu that contains the item then check or uncheck the item:

invoke GetMenu,hWin

mov hMenuBar,eax
invoke GetSubMenu,hMenuBar,0
mov hMenu,eax
invoke CheckMenuItem,hMenu,1001,MF_BYCOMMAND or MF_CHECKED
invoke CheckMenuItem,hMenu,1001,MF_BYCOMMAND or MF_UNCHECKED
Posted on 2003-12-25 22:01:52 by donkey
Thank alot, i've done that .
But What about : How to make menu invisible or visible.
Posted on 2003-12-28 02:14:08 by neverending
Hi neverending,

Use RemoveMenu and InsertMenu for that.

invoke GetMenu,hWin

mov hMenuBar,eax
invoke GetSubMenu,hMenuBar,0
mov hSubMenu,eax

invoke RemoveMenu,hMenuBar,0,MF_BYPOSITION
invoke DrawMenuBar,hWin

invoke InsertMenu,hMenuBar,0,MF_POPUP or MF_BYPOSITION or MF_ENABLED or MF_STRING,\
hSubMenu,pszMenuName
invoke DrawMenuBar,hWin
Posted on 2003-12-28 07:44:42 by donkey