Question Problem in disabling close button(X) of window.

priyamtheone

Well-known member
Joined
Sep 20, 2007
Messages
96
Programming Experience
Beginner
Hi,
I am trying to work on an application that disables the close button (X) on the upper right hand corner of a window. In order to do that I need to use calls to API methods like GetSystemMenu, EnableMenuItem and RemoveMenu. I can figure out how these methods work but there are certain parameters that these methods have whose values that need to be passed to them as argument is unknown to me. How can I know them.

E.G.- for EnableMenuItem, the parameters are- hMenu (handle to the menu), uIDEnableItem (The menu item to be enabled, disabled, or grayed), uEnable (This parameter must be a combination of at least two of the following:
MF_BYCOMMAND or MF_BYPOSITION
MF_ENABLED, MF_DISABLED, or MF_GRAYED)

Now when I call this method from my application I supply the current window handle as the first argument, the item no. to be disabled/enabled as the second argument but I CAN'T UNDERSTAND WHAT TO SEND AS THE THIRD ARGUMENT. What exactly are the possible values for those parameters- MF_BYCOMMAND or MF_DISABLED. I checked certain examples where they are supplying hexadecimal values like &HF060, &H1, 0x400, 0x1000, 0x2 etc. or integer values like 1024, 2 etc. But how would I know what exactly these values are and when to use which value. The same problem arises in case of calling RemoveMenu method. If you know about any chart or tutorial that lists the values of these parameters then plz refer. Waiting for your help. Thanks.
 
Look into this directory : C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include

There should be a winuser.h file that contain the C declarations for the user32.dll which contains the API calls you are using. I would send you the file, but I'm not sure I actually have the legal rights to do so...
 
The ApiViewer 2004 app found here: ActiveVB - ApiViewer (en) is helpful for getting approx declarations for API functions etc for VB.Net. (configure language syntax in Options) It has all the declarations and constants you mention.
This site pinvoke.net: the interop wiki! is also helpful in some cases, there you may also find related code samples.
 
Back
Top