modeless dialog trouble
-
I've created 2 classes with baseclass CDialog. The first class should show the other dialog while working. I've done it that way:
void CTestDlg::OnTest() { UpdateData(TRUE); CWaitDialog *wd=new CWaitDialog; if (!::IsWindow(wd->GetSafeHwnd())) wd->Create(IDD_DIALOG2, this); wd->ShowWindow(SW_SHOW); // work to do wd->EndDialog(0); wd=NULL; // some clearing UpdateData(FALSE); delete wd; }
The second dialog shows up, but I can not move it or it doesn't react on input. When I show the dialog only without letting the first dialog do his work the second reacts as expected. So my question is how to create modeless windows like the one when copying or saving files? I think of the typical "work in progess" dialogs, showing the effort and let you quit the action. -
I've created 2 classes with baseclass CDialog. The first class should show the other dialog while working. I've done it that way:
void CTestDlg::OnTest() { UpdateData(TRUE); CWaitDialog *wd=new CWaitDialog; if (!::IsWindow(wd->GetSafeHwnd())) wd->Create(IDD_DIALOG2, this); wd->ShowWindow(SW_SHOW); // work to do wd->EndDialog(0); wd=NULL; // some clearing UpdateData(FALSE); delete wd; }
The second dialog shows up, but I can not move it or it doesn't react on input. When I show the dialog only without letting the first dialog do his work the second reacts as expected. So my question is how to create modeless windows like the one when copying or saving files? I think of the typical "work in progess" dialogs, showing the effort and let you quit the action. -
I've created 2 classes with baseclass CDialog. The first class should show the other dialog while working. I've done it that way:
void CTestDlg::OnTest() { UpdateData(TRUE); CWaitDialog *wd=new CWaitDialog; if (!::IsWindow(wd->GetSafeHwnd())) wd->Create(IDD_DIALOG2, this); wd->ShowWindow(SW_SHOW); // work to do wd->EndDialog(0); wd=NULL; // some clearing UpdateData(FALSE); delete wd; }
The second dialog shows up, but I can not move it or it doesn't react on input. When I show the dialog only without letting the first dialog do his work the second reacts as expected. So my question is how to create modeless windows like the one when copying or saving files? I think of the typical "work in progess" dialogs, showing the effort and let you quit the action.ryuki wrote: wd->EndDialog(0);
EndDialog()
is specific to modal dialog boxes.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
-
here's a basic MsgPump function:
void MsgPump(DWORD dwLen /* =200 */) { MSG m_msgCur; // current message CWinApp *pWinApp = AfxGetApp(); DWORD dInitTime = GetTickCount(); while (::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE) && (GetTickCount() - dInitTime < dwLen) ) { pWinApp->PumpMessage(); } }
Call this periodically in the code where you do your work. You don't have to call it all the time, just once in a while. The dwLen is the number of ticks to wait. 200 is a good default. -c Software | Cleek -
I've created 2 classes with baseclass CDialog. The first class should show the other dialog while working. I've done it that way:
void CTestDlg::OnTest() { UpdateData(TRUE); CWaitDialog *wd=new CWaitDialog; if (!::IsWindow(wd->GetSafeHwnd())) wd->Create(IDD_DIALOG2, this); wd->ShowWindow(SW_SHOW); // work to do wd->EndDialog(0); wd=NULL; // some clearing UpdateData(FALSE); delete wd; }
The second dialog shows up, but I can not move it or it doesn't react on input. When I show the dialog only without letting the first dialog do his work the second reacts as expected. So my question is how to create modeless windows like the one when copying or saving files? I think of the typical "work in progess" dialogs, showing the effort and let you quit the action. -
here's a basic MsgPump function:
void MsgPump(DWORD dwLen /* =200 */) { MSG m_msgCur; // current message CWinApp *pWinApp = AfxGetApp(); DWORD dInitTime = GetTickCount(); while (::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE) && (GetTickCount() - dInitTime < dwLen) ) { pWinApp->PumpMessage(); } }
Call this periodically in the code where you do your work. You don't have to call it all the time, just once in a while. The dwLen is the number of ticks to wait. 200 is a good default. -c Software | Cleek