【发布时间】:2012-09-07 16:28:08
【问题描述】:
更新:可能的解决方案。在标题中声明 CWait 对话框似乎可以解决这个问题。
UPDATE2:消息泵可能是罪魁祸首。显式“抽水”似乎可以解决问题。
我试图在应用程序中执行某些功能时显示一个模式“请稍候”对话框。我要显示的对话框是这样的:
我正在使用此代码来调用对话框。
CWait dialog;
dialog.Create(IDD_WAIT);
dialog.SetWindowTextW(L"Geocoding");
dialog.ShowWindow(SW_SHOW);
mastImageGeocode(); //Working here
slvImageGeocode();
interfImageGeocode();
cohImageGeocode();
dialog.CloseWindow();
最终显示的是这样的:
我似乎无法弄清楚为什么控件不呈现。
我尝试在使用这种方法初始化对话框后手动处理消息循环:
MSG stMsg;
while (::PeekMessage (&stMsg, NULL, 0, 0, PM_REMOVE))
{
::TranslateMessage (&stMsg);
::DispatchMessage (&stMsg);
}
确实没用。
我也试过指针方法
Cwait * dialog; //THis is in header
dialog = new CWait(this);
dialog->Create(IDD_WAIT);
dialog->SetWindowTextW(L"Geocoding");
dialog->ShowWindow(SW_SHOW);
mastImageGeocode(); //Some work here
slvImageGeocode();
interfImageGeocode();
cohImageGeocode();
dialog->CloseWindow();
delete dialog;
我是不是做错了什么。
感谢您的帮助。
更新:如果我在单个函数中调用它,它工作正常!
【问题讨论】:
-
作为一个快速测试,dialog.ShowModal();工作好吗?
-
@JBRWilkinson 你的意思是 doModal() 对吧?
CWait dialog; dialog.DoModal();对我有用。 -
如果我在 3 个函数中的每一个中都放了相同的代码,它会工作一次,下次就不能工作了(显示)
-
更新:可能的解决方案。在标题中声明 CWait 对话框似乎可以解决这个问题。
标签: c++ visual-studio-2010 visual-c++ mfc