Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Modal Dialog 'time out'...

Posted on 1998-06-07
7
Medium Priority
?
318 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:wwalschaerts
  • 5
  • 2
7 Comments
 
LVL 6

Accepted Solution

by:
WxW earned 600 total points
ID: 1165338
Create a timer and send a WM_CLOSE message to the window
0
 
LVL 6

Expert Comment

by:WxW
ID: 1165339
Set Timer :
int k;

k = ::SetTimer(0,0,TimeInMilliseconds,(TIMERPROC)MyProc);

....

void CALLBACK MyProc(HWND,UINT,UINT,DWORD)
  {
  KillTimer(0,k);
  SendMessage(HwndOfDialog,WM_CLOSE,0,0);
  }

0
 
LVL 6

Expert Comment

by:WxW
ID: 1165340
In case that you need more help , let me know :)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:wwalschaerts
ID: 1165341
Hum, Don't really understand !

I am working with Classes so I have tried to insert :
"k = ::SetTimer(0,0,TimeInMilliseconds,(TIMERPROC)MyProc);"
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_dlg)
  // NOTE: the ClassWizard will add member initialization here
  //}}AFX_DATA_INIT
  Timer = ::SetTimer(0,0,10000,(TIMERPROC)Timer_Proc);
  }

Then I don't know how I can find the HWND du Dialog?

Thanks for your help,
WW
0
 
LVL 6

Expert Comment

by:WxW
ID: 1165342
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

0
 
LVL 6

Expert Comment

by:WxW
ID: 1165343
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
0
 

Author Comment

by:wwalschaerts
ID: 1165344
Thanks a lot,
WW

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question