Re: Enable/Disable button
Quote:
Originally Posted by whaTHell
I had heard about EnableWindow(); but i don't know how to associate HWND for that button because i don't create the button on run-time. It's already in the dialog box.
Have anyone got some clue....
Yes - you can call GetDlgItem() to get the control's window handle.
Re: Enable/Disable button
Quote:
Originally Posted by whaTHell
I had create button called IDC_PLAY on the design view in a dialog box call IDD_CONTROL. How can i disable it.
I had heard about EnableWindow(); but i don't know how to associate HWND for that button because i don't create the button on run-time. It's already in the dialog box.
Have anyone got some clue....
You also can use SendDlgItemMessage() with the ID of your button defined in resource.h:
Code:
// enable button IDC_BUTTON1 in dialog hDialog
SendDlgItemMessage(hDialog, IDC_BUTTON1, WM_ENABLE, (WPARAM)TRUE, 0);
// disable button:
SendDlgItemMessage(hDialog, IDC_BUTTON1, WM_ENABLE, (WPARAM)FALSE, 0);
Re: Enable/Disable button
Thanx all..
It's work. I use GetDlgItem() to get the button handle and enable/disable it with EnableWindow().
But if I use:
SendDlgItemMessage(hDialog, IDC_PLAY, WM_ENABLE, (WPARAM) FALSE, 0);
it didn't work. Am I missing something there? Actually I had try this method before I post this thread and it didn't work also..
Anyway, thanx again..
Re: Enable/Disable button
SendDlgItemMessage(hDialog, IDC_PLAY, WM_ENABLE, (WPARAM) FALSE, 0);
I have the same problem...if anyone knows why it does not work...???
by now I solve this with the folllowing:
EnableWindow(GetDlgItem(hDialog, IDC_PLAY), TRUE);
Re: Enable/Disable button
WM_ENABLE is a notification message. It is sent to your parent window in response to the enabling/disabling of a child window. It cannot be used to alter it.
Re: Enable/Disable button
Quote:
Originally Posted by Bond
WM_ENABLE is a notification message. It is sent to your parent window in response to the enabling/disabling of a child window. It cannot be used to alter it.
I always mix those two up... :thumbd: ...
Re: Enable/Disable button
Re: Enable/Disable button
Quote:
Originally Posted by Quell
Ws_disabled
WS_DISABLED is a window style, not a message, and would have to be used in conjunction with SetWindowLong() to change the window's current style. I'm not even sure if it affects the window other than when it is initially created but one could test it.
Re: Enable/Disable button
WS_DISABLED worlks after the application has been created//or can be made to work in a few cases....adn windows style is as good as a message is..
Re: Enable/Disable button
Quote:
Originally Posted by Quell
adn windows style is as good as a message is..
It may be as effective, but I would think:
Code:
EnableWindow(hwnd, FALSE);
would be much more readable than:
Code:
LONG lStyle = GetWindowLong(hwnd, GWL_STYLE);
SetWindowLong(hwnd, GWL_STYLE, lStyle & WS_DISABLED);
I would only use WS_DISABLED if I wanted a window/control to be initially disabled during creation.