wwalschaerts
asked on
Modal Dialog 'time out'...
Hello all,
Regarding Dialogs : I am trying to find a way to automatically exit from a Dialog called like this : DlgOpen.DoModal();
It is a CDialog class.
In fact I have a OK button but I also want to close this dialog after 30 seconds (for example). I dont know which
Message I am supposed to use with my Dialog object.
I am using VC++ 5,
Many thanks,
WW
Regarding Dialogs : I am trying to find a way to automatically exit from a Dialog called like this : DlgOpen.DoModal();
It is a CDialog class.
In fact I have a OK button but I also want to close this dialog after 30 seconds (for example). I dont know which
Message I am supposed to use with my Dialog object.
I am using VC++ 5,
Many thanks,
WW
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In case that you need more help , let me know :)
ASKER
Hum, Don't really understand !
I am working with Classes so I have tried to insert :
"k = ::SetTimer(0,0,TimeInMilli seconds,(T IMERPROC)M yProc);"
into the CDialog definition like this (not sure it is correc) :
COpen_dlg::COpen_dlg(CWnd* pParent /*=NULL*/)
: CDialog(COpen_dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(COpen_dl g)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
Timer = ::SetTimer(0,0,10000,(TIME RPROC)Time r_Proc);
}
Then I don't know how I can find the HWND du Dialog?
Thanks for your help,
WW
I am working with Classes so I have tried to insert :
"k = ::SetTimer(0,0,TimeInMilli
into the CDialog definition like this (not sure it is correc) :
COpen_dlg::COpen_dlg(CWnd*
: CDialog(COpen_dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(COpen_dl
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
Timer = ::SetTimer(0,0,10000,(TIME
}
Then I don't know how I can find the HWND du Dialog?
Thanks for your help,
WW
Hmm you should check if the CDialog class , has a public member ( e.g. Borland's TDialog has HWindow , in which one stores the HWND of the window ) . Or find a function like GetWindowHandle() , or something , to get the HWND of the window
If you do not find anything , you must do this :
Instead of using ::SetTimer() API , you should use CDialog :: SetTimer() ( I believe that CDialog will have such a function )
This will not call a TIMERPROC function after the timeout , but rather it passes WM_TIMER messages to the window proc . You can handle messages from CDialog :: WindowProc ( Again I am not sure for the name , because I use borland ) .
In all cases , the message that you will send is WM_CLOSE
If you do not find anything , you must do this :
Instead of using ::SetTimer() API , you should use CDialog :: SetTimer() ( I believe that CDialog will have such a function )
This will not call a TIMERPROC function after the timeout , but rather it passes WM_TIMER messages to the window proc . You can handle messages from CDialog :: WindowProc ( Again I am not sure for the name , because I use borland ) .
In all cases , the message that you will send is WM_CLOSE
And please note that a HWND public member of CDialog , will be set only after the window has been created . Thats why you should not take the HWND from the constructor , but rather from a function that is called after the Window is created , but before it is executed . Borland has TDialog :: SetupWindow for this job
This is an example of a code
void COpen_dlg :: SetupWindow() (?)
{
CDialog :: SetupWindow(); (?) // Call the parent SetupWindow
HWNDDialog = HWindow; // or something like CWindow , CWnd or else
}
and then you have the HWND for the dialog , and you can use it in your timer function
This is an example of a code
void COpen_dlg :: SetupWindow() (?)
{
CDialog :: SetupWindow(); (?) // Call the parent SetupWindow
HWNDDialog = HWindow; // or something like CWindow , CWnd or else
}
and then you have the HWND for the dialog , and you can use it in your timer function
ASKER
Thanks a lot,
WW
WW
int k;
k = ::SetTimer(0,0,TimeInMilli
....
void CALLBACK MyProc(HWND,UINT,UINT,DWOR
{
KillTimer(0,k);
SendMessage(HwndOfDialog,W
}