隐藏和显示对话框 [英] Hiding & displaying dialog box

查看:71
本文介绍了隐藏和显示对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个应用程序,在其中单击对话框的按钮时将显示消息框.显示消息框后,我想再次显示相同的对话框.
我不知道该怎么做.我尝试了ShowWindow(SW_SHOW),但是它不起作用.
请帮助我做到这一点,并告诉我如何隐藏对话框.

在此先感谢......

Hi,
I have an application in which I am displaying messagebox on button click of the dialog box. After displaying messagebox, I want to show same dialog box again.
I don''t know how to do it. I tried ShowWindow(SW_SHOW) but it''s not working.
Please help me to do this & also tell me how to hide dialogbox.

Thanks in advance......

推荐答案

您的问题对我来说还不太清楚,但根据我的意思,您想采用以下解决方案...
在显示到消息框之前,请调用对话框的OnCancel()方法,并从消息框返回控件后,请使用对话框的DoModal()方法.
Your question is little unclear to me but according me you want following solution...

Before showing to message box call OnCancel() method of dialog box and after returning the control from message box use DoModal() method of dialog box.


首先,如果您调用消息框在OnOk()
然后
Hey first thing That if you called message box on OnOk()
then
void YourDialog::OnOk()
{
  AfxMessageBox("HELLO");
  OnOk();
}


然后它显示消息,并且Di8alog将不可见,
所以
对于显示消息框后保留在同一对话框中,请删除OnOk();


Then it display message and Di8alog will invisible,
So
For Remain in Same dialog after displaying messagebox please remove OnOk();

void YourDialog::OnOk()
{
  AfxMessageBox("HELLO");
  //OnOk();

}



现在,如果要隐藏对话框,则只需调用OnCancel()或OnOk();
如果无法理解,那么请在执行所有这些活动的地方提供代码块.



Now if you want to Hide the dialog then just Called OnCancel() or OnOk();
If Not understand then please provide your code block where you doing all this activities.


我想您正在关闭对话框,因此showwindow无法正常工作,因为您应该通过以下方式再次创建对话框DoModal或其他方法...

如果您通过按确定"或取消"按钮来执行此操作,则可以执行第二个解决方案上发布的操作,或者创建具有所需特定功能的另一个按钮...这可能会更清楚,您可以使用确定/"如果在未知的将来需要它们,请取消按钮...

如果您按下另一个按钮,则始终可以:

1.隐藏对话框(显示窗口...).
2.创建消息框.
3.显示对话框(显示窗口...).

HTH!
I guess you are closing the dialog and therefore showwindow won''t work because you should create the dialog again via a DoModal or another method...

If you are doing that via pressing the OK or CANCEL buttons, then you could do what has been posted on the second solution or create another button with the specific functionality you need... which probably would be clearer and you could use the OK/CANCEL buttons if they are needed in a unknown future...

If you make another button, you can always:

1. hide your dialog (showwindow...).
2. create the messagebox.
3. show the dialog (showwindow...).

HTH!


这篇关于隐藏和显示对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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