禁用基于对话框的应用程序中的按钮。 [英] Disable the Button in Dialog based application.

查看:61
本文介绍了禁用基于对话框的应用程序中的按钮。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!



我有基于对话框的应用程序。



1.在设置拨号盘中有两个按钮。 1.配置和2.确定按钮。

2.如果我单击配置按钮,将打开配置对话框。

3.在配置对话框中有1.combo框和2.OK按钮。



如果组合框没有任何元素,我将禁用配置对话框的确定​​按钮。



同样我想在配置对话框的组合框中没有项目时禁用OK按钮设置对话框。



请帮我怎么做它?



谢谢

Sam。

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.

推荐答案

不会有用吗?



GetDlgItem(BUTTONID) - > EnableWindow(false);
wont it work?

GetDlgItem(BUTTONID)->EnableWindow(false);


如果配置对话框是模态对话框,则不要不必担心设置对话框的确定按钮。 配置对话框正在运行时,用户无法单击设置对话框中的任何内容。如果我理解正确,在输入组合框中的所有选项之前,将不允许用户离开配置对话框。



现在,让's'假设你在Configure对话框上放了一个额外的Cancel按钮(当然是个好主意)。然后用户实际上可以在不输入所需信息的情况下返回。



以下是处理方法:在配置对话框中添加成员函数

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
bool ConfigInfoComplete() const;



然后,在设置对话框的OnConfigureButton函数中,从Configure对话框返回后调用该函数,例如:


Then, in your OnConfigureButton function of the settings dialog, call that function after the return from the Configure dialog, for example:

void SettingsDlg::OnConfigureButton()
{
    ...
    ConfigureDlg dlg (this);
    dlg.RunModal();
    m_okButton.EnableWindow (dlg.ConfigInfoComplete());
}



请注意,在ConfigureDlg从RunModal返回后,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.


这篇关于禁用基于对话框的应用程序中的按钮。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆