Hello again,

I am trying to manipulate one menuitem text on each press, like this:
OpenClose proc 
LOCAL mc:MENUITEMINFO
LOCAL buf1[20]:BYTE
invoke RtlZeroMemory,addr sbText2,sizeof sbText2
.if uiOpen==1
invoke lstrcpy,addr buf1,CTXT("&Open")
mov fPortStat,001900FFh
mov uiOpen,0
invoke lstrcpy,offset sbText2,CTXT("Closed")
.elseif uiOpen==0
invoke lstrcpy,addr buf1,CTXT("&Close")
mov fPortStat,0033CC33h
mov uiOpen,1
invoke lstrcpy,offset sbText2,CTXT("Opened")
.endif
invoke ModifyMenu,hMnu,IDM_OPENCLOSE,MF_BYCOMMAND or MF_STRING,IDM_OPENCLOSE,addr buf1
invoke DrawMenuBar,hMnu  ;does not seem to have any influence!
invoke DoStatus
ret
OpenClose endp


It works BUT it updates the text ONLY after the mouse cursor (after click) hovers outside the menuitem button shape, which is enormously annoying.
Ollydbg shows that the entire menu bar gets refreshed very often (too often, that I gave up doing F8...)

Does anybody have a trick for  this?

Best regards,

Bogdan
Posted on 2012-02-26 11:56:17 by bogroca
I don't understand what you are trying to do.  When you select a menu item, the menu closes.
Attachments:
Posted on 2012-02-26 16:15:14 by Gunner
Hi Gunner,

I am using a menu (menuitem not popup) as on/off button. It does function. The problem is that I am also changing the text on it (to reflect the state) which has this "wait to move the cursor from it" issue.

Regards,

Bogdan
Posted on 2012-02-27 06:03:01 by bogroca
You are passing a menu handle to DrawMenuBar, instead pass the handle of the window that owns the menu.

In your WM_CREATE/INITDIALOG do
		push    hWnd
pop    hMain

Then this will work:
        invoke ModifyMenu, hMnu,0,MF_BYCOMMAND or MF_STRING,0,addr buf1
        invoke DrawMenuBar, hMain  ;<---- handle to window that owns the menu

Posted on 2012-02-27 18:39:30 by Gunner
Thanks Gunner!!

That was it! I'am ashamed!

Best regards,

Bogdan
Posted on 2012-02-28 07:53:06 by bogroca