线程里弹DoModal框置顶以及禁止在处理DoModal框时MFC主界面最小化及对主界面进行操作 .

来源:互联网 发布:sql server2008r2下载 编辑:程序博客网 时间:2024/06/13 07:36
//基于对话框的MFC核心代码void CDLLDemoDlg::OnBnClickedButton1(){// TODO: 在此添加控件通知处理程序代码AfxBeginThread(TestThread, this);}UINT CDLLDemoDlg::TestThread(LPVOID lParam){CDLLDemoDlg* pDlg = (CDLLDemoDlg*)lParam;ShowDoModalDLg(pDlg->m_hWnd);return 0;}//动态库里的核心代码__int32 __stdcall ShowDoModalDLg(HWND hWnd){CWnd* pWnd = CWnd::FromHandle(hWnd);CDlg1 dlg;if (NULL != pWnd){pWnd->EnableWindow(FALSE);}dlg.DoModal();if (NULL != pWnd){pWnd->EnableWindow(TRUE);pWnd->SetFocus();pWnd->SetForegroundWindow();pWnd->SetActiveWindow();}return 0;}//改写OnInitDialog,实现Domodal框置顶BOOL CDlg1::OnInitDialog(){CDialog::OnInitDialog();SetWindowPos(&wndTopMost,0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);SetForegroundWindow();//将窗口置于前台,即强行置顶return TRUE;}

0 0
原创粉丝点击