Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi!

I have dialog based application.

1. In Settings Dialod there are two buttons. 1. Configure and 2. OK button.
2. If i click on Configure Button, Configure dialog will open.
3. In Configure Dialog there are 1.combo boxes and 2.OK button.

If combobox dont have any elements i'm disabling the OK button of Configure Dialog.

Similarly i wanna to disable OK Button of Settings dialog, when no items present in combo box of configure dialog.

Please help me how to do it ?

Thanks
Sam.
Posted
Updated 15-Mar-13 19:52pm
v2

wont it work?

GetDlgItem(BUTTONID)->EnableWindow(false);
 
Share this answer
 
If the Configure dialog is a modal dialog, you don't have to worry about the OK button of your settings dialog. While the Configure dialog is running, the user won't be able to click anything in the Settings dialog. And if I understand you correctly, the user will not be allowed to leave the Configure dialog before entering all the choice in the combo boxes.

Now, let's assume you put an additional Cancel button on the Configure dialog (certainly a good idea). Then the user can in fact return without entering the required information.

Here is how you handle that: Add a member function to your Configure dialog
C++
bool ConfigInfoComplete() const;

Then, in your OnConfigureButton function of the settings dialog, call that function after the return from the Configure dialog, for example:
C++
void SettingsDlg::OnConfigureButton()
{
    ...
    ConfigureDlg dlg (this);
    dlg.RunModal();
    m_okButton.EnableWindow (dlg.ConfigInfoComplete());
}

Note that after the ConfigureDlg returns from RunModal, the dlg object is still alive. And you can execute member functions like ConfigInfoComplete or test public member variables. That is usually the way in which you pass information from a modal dialog to its caller.

I hope that gets you going.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900