|
-
October 22nd, 2004, 03:47 AM
#1
Enable/Disable button
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....
-
October 22nd, 2004, 04:36 AM
#2
Re: Enable/Disable button
 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.
-
October 22nd, 2004, 08:04 AM
#3
Re: Enable/Disable button
 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);
-
October 24th, 2004, 08:30 PM
#4
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..
-
May 5th, 2005, 06:53 AM
#5
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);
Last edited by rafraf; May 5th, 2005 at 07:04 AM.
-
May 5th, 2005, 07:48 AM
#6
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.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
-
May 5th, 2005, 02:10 PM
#7
Re: Enable/Disable button
 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... ...
-
May 5th, 2005, 02:51 PM
#8
Re: Enable/Disable button
-
May 5th, 2005, 03:03 PM
#9
Re: Enable/Disable button
 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.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
-
May 5th, 2005, 04:37 PM
#10
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..
-
May 6th, 2005, 07:13 AM
#11
Re: Enable/Disable button
 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.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|