以编程方式关闭MFC消息框 [英] Programatically close an MFC message box

查看:133
本文介绍了以编程方式关闭MFC消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



是否可以通过编程方式关闭MFC MessageBox?
还是我需要创建一个自定义对话框?

TIA

Tony

Hi,

Is it possible to programmatically close a MFC MessageBox?
Or would I need to create a custom dialog?

TIA

Tony

推荐答案

您必须创建自定义消息框对话框. CodeProject [
You have to create your custom message box dialog. There are examples here at CodeProject [^].
:)


通过应用标题创建消息框
例如:: Messagebox(hWnd,"TEXT","YOURTITLE",MB_OK);

现在从其他窗口找到
HWND hWnd = :: FindWindow(NULL,"YOURTITLE");
if(hWnd)
{
:: PostMessage(hWnd,WM_CLOSE,0,0);

}
Create a Messagebox by applying its caption
for Example ::Messagebox(hWnd,"TEXT","YOURTITLE",MB_OK);

Now from other thred find window like
HWND hWnd = ::FindWindow(NULL,"YOURTITLE");
if(hWnd)
{
::PostMessage(hWnd,WM_CLOSE,0,0);

}


如果您指的是AfxMessageBox,则不会.您需要单击一个按钮或用"x"手动将其关闭.

如果您希望您的程序关闭MessageBox,那么它应该在之前创建它,这意味着您需要自己做一个.
If you are referring to AfxMessageBox, no. You need to click in a button or close it with the "x" manually.

if you want your programm to close your MessageBox then it should create it before, meaning you need to do your own one.


这篇关于以编程方式关闭MFC消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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