Dialog BOx Question
-
I have a dialog with a timer that check to see if it can close itself when it can I kill the timer and send a PostMessage(WM_CLOSE); The dialog is very slow to close , If I click the system close button, it is immediate Also Tried SendMessage. Whats the best way to close the dialog ? NB: THe main dialog has a timer doing serial comms. Win CE 3.0 Thanks .Confused
-
I have a dialog with a timer that check to see if it can close itself when it can I kill the timer and send a PostMessage(WM_CLOSE); The dialog is very slow to close , If I click the system close button, it is immediate Also Tried SendMessage. Whats the best way to close the dialog ? NB: THe main dialog has a timer doing serial comms. Win CE 3.0 Thanks .Confused
-
I have a dialog with a timer that check to see if it can close itself when it can I kill the timer and send a PostMessage(WM_CLOSE); The dialog is very slow to close , If I click the system close button, it is immediate Also Tried SendMessage. Whats the best way to close the dialog ? NB: THe main dialog has a timer doing serial comms. Win CE 3.0 Thanks .Confused
I do it the following way:
...
class CConnMsgDlg : public CDialog
{
...// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CConnMsgDlg)
virtual BOOL OnInitDialog();
...
//}}AFX_MSG
afx_msg LRESULT OnEnd(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()...
private:
static const UINT MY_WM_END;
};...
/////////////////////////////////////////////////////////////////////////////
// Message tableconst UINT CConnMsgDlg::MY_WM_END =
RegisterWindowMessage(_T("MY_WM_END-{29813B84-DD1E-11d7-9B13-0002B32C4875}"));BEGIN_MESSAGE_MAP(CConnMsgDlg, CDialog)
//{{AFX_MSG_MAP(CConnMsgDlg)
...
//}}AFX_MSG_MAP
ON_REGISTERED_MESSAGE(MY_WM_END, OnEnd)
END_MESSAGE_MAP()BOOL CConnMsgDlg::OnInitDialog()
{
CDialog::OnInitDialog();// TODO: Add extra initialization here // Create the thread and start it return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE
}
LRESULT CConnMsgDlg::OnEnd(WPARAM wParam, LPARAM lParam)
{
EndDialog(wParam);return 0L;
}
void CConnMsgDlg::ThreadFnc()
{
...PostMessage(MY\_WM\_END, IDOK); // destroy the dialog
}
I have a dialog that starts a thread in the 'OnInitDialog' function. The thread reads some data from the serial port. This can take a long time, so I do it in a own thread. When the thread is ready it post the message 'MY_WM_END', that I have registered in the message map. The 'OnEnd' function closes the dialog with 'EndDialog'. Cheers, Daniel. -- FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE. ;)