|
-
August 12th, 1999, 11:24 PM
#1
How to enable\disable a button at runtime
Im new to VC++ and I've been wondering how you can enable\disable a button at runtime. For example I would like to disable a button(I'm not talking about a toolbar button) when a text box is blank and enable it when a user enters text (like the Run program in the start menu). I think that it has something to do with the EnableButton function, but im not really sure. Thanks for the help.
-
August 12th, 1999, 11:32 PM
#2
Re: How to enable\disable a button at runtime
You have to get a pointer to your button and after this use
pBut->EnableWindow(FALSE);
-
August 12th, 1999, 11:54 PM
#3
Re: How to enable\disable a button at runtime
When you make a pointer to your button you do this in classwizard under member variables right? Because when I do that, i get the following compile errors:
error C2819: type 'CButton' does not have an overloaded member 'operator ->'
error C2227: left of '->EnableButton' must point to class/struct/union
Thanks.
-
August 13th, 1999, 12:06 AM
#4
Re: How to enable\disable a button at runtime
I assume that we are somewhwre in your class dialog wich contain your button
CButton* pBut=(CButon*)GetDlgItem(IDC_BUTTON);
pBut->EnableWindow(FALSE);
of corse IDC_BUTTON is ID of your button, you may check for its name in resurs editor.
-
August 13th, 1999, 12:16 AM
#5
Re: How to enable\disable a button at runtime
Thanks for you help. It worked. But I have one more thing to ask. How do you make it so you can toggle it? Like when you click on one button to enable or disable it.
Thanks.
-
August 13th, 1999, 12:19 AM
#6
Re: How to enable\disable a button at runtime
If you create a member variable (m_button for example) from Class Wizard, you have to enter:
m_button.EnableWindow(FALSE);
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
|