Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When can I enable/disable buttons on a dialog bar ?

Status
Not open for further replies.

bulgakov

Programmer
Apr 24, 2003
26
GB
All,
I have a dialog bar that is created thus...

void CMainFrame::OnCreate()
{
if(!m_wndDlgBar.Create(this,IDD,CBRS_LEFT,IDD)
.
.
.;
}

The MainFrame is created from MyApp::InitInstance()

what I need to know is when can I set the button states
(i.e. Grayed - SetWindow(false)) I need some kind of event
or is there a method I can override ? Thanks in advance.

Marcus
 
>> what I need to know is when

Yes you do

>> I need some kind of event

Yes you do

The event(s) need to be defined in the requirements for the application.

Once you have the event identified and the event handler code in place you can call CWnd::EnableWindow(..) to enable/disable the button(s).

-pete
I just can't seem to get back my IntelliSense
 
pete,
I will rephrase my question for you

I have a dialog bar with buttons on, when the dialog
bar is created I want to gray those buttons out,
however I am unsure as to which function I can use to do it.
I have tried the function that creates the dialog bar
(CMainFrame::OnCreate) and it crashes on trying to
get the buttons presumably becase the frame is not displayed yet ? So can anyone help me ?

Marcus
 
after the call to create the dialogbar, i.e.; if(!m_wndDlgBar.Create(this,IDD,CBRS_LEFT,IDD)

The dialogbar window and all child windows have been created and are therefore accessable. If your code is crashing when accessing the windows after the create call then the problem is in your code.

-pete
I just can't seem to get back my IntelliSense
 
ok,
pete thanks for your help so far, I can make the button
disabled using enablewindow (false), and i check the
state afterwards using iswindowenabled and it returns false
as I would expect, but the button is not disabled in the
dialog bar. There are no other actions performed on this button. Funnily enough I can make the button invisible in
the function and it stays invisible. Do you know why the
enable state is being set back to true ?
Thanks.
 
This is a known fault see the

Microsoft Knowledge Base Article - 152376

How to disable buttons in a dialog bar.

The problem was I had the correct method (ie after the
create), and the correct resource name etc. It didn't work
due to the fact microsoft don't understand words
such as consistency, so even though the buttons
are buttons, on a dialog bar they are bitmaps, clever
chaps, ye hah.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top