Sign in to follow this  

hide a button

This topic is 4749 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

With the Windows API How does one hide a button on a dialog box? Using a SendDlgItemMessage? I would assume it's some SHOW or VISIBLE thing, but can only find methods of altering button styles... So how does one hide/show a button? How does one enable/disable it(gray it out)?

Share this post


Link to post
Share on other sites
Funkymunky,

yes, use the SendDlgItemMessage and use the WM_SHOWWINDOW message. check out msdn for more. As for graying an item, for instance a menu item, you would send the WM_MENUSELECT notification, and once again check msdn for more info.

-brad

Share this post


Link to post
Share on other sites
Quote:
Original post by Funkymunky
With the Windows API
How does one hide a button on a dialog box? Using a SendDlgItemMessage? I would assume it's some SHOW or VISIBLE thing, but can only find methods of altering button styles...

So how does one hide/show a button? How does one enable/disable it(gray it out)?


You can also accompish it like this *I believe*:

HWND hwnd; // handle to the button
ShowWindow(hwnd, SW_HIDE) // to hide
ShowWindow(hwnd, SW_SHOW) // to show
EnableWindow(hwnd,true) // to enable
EnableWindow(hwnd,false) // to disable



If im wrong I'm sorry, I remember doing this before via MFC, but these functions are Win32 API, so they should work. You should be able to save the button HWND when you create it, if I remember Win32 programming. I hope this helps! Goodluck.

Share this post


Link to post
Share on other sites
Drew,

Those will work for non-dialog windows. Dialog windows need the SendDlgItemMessage sent, because it requires the IDI_* value for which window in the dialog that needs to be changed.

-brad

Share this post


Link to post
Share on other sites

This topic is 4749 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this