While working on the visual Designer I ran in to a problem with enabling/disabling menuitems with the ENABLEMENUITEM command
If you use a user defined idle message in a windows handler to constantly check the status of things and enable/disable menu items you can run into a flicker problem by repeatedly turning an item either off or on.
One way to solve it is to setup a last pass flag to see if the desired state has changed since the last pass.
I used that for a couple of menu items but I didn't want 30-40 flags cluttering up the code just for that.
So I created a little function to read if a menuitem is currently enabled or disabled.
So, in my idle routine I compare what the state is and what I need it to be and if there is a difference I use the proper ENABLEMENUITEM code.
There are probably many other ways to do it but this one works great for me.
Also, most of you may never even see the problem to begin with.
But for those who have, here is my soluton.
It assumes you are using Sapero's "windowssdk.inc" file (I don't program without it.
If you don't then you will need to declare the API functions and constants I'm using.
LarryMc
global sub IsMenuItemEnabled(win as WINDOW,id as UINT),int
DEF hmenu as UINT
if(win.hwnd)
hmenu = GetMenu(win.hwnd)
if(hmenu)
uint flag = GetMenuState(hMenu, id, MF_BYCOMMAND)
flag =!(Flag & (MF_DISABLED | MF_GRAYED))
return flag
endif
endif
return 0
endsub