Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timers with no-MFC classes 1

Status
Not open for further replies.

Nosferatu

Programmer
Jun 9, 2000
412
RO
Hello....

I'm in a weird situation here: I need a timer for a Non-MFC class and I am not sure how to handle it.
The weirdness of the situation consists actually in the weirdness of the solution I developed so far, so I wonder if there is a better way to do it:
I am declaring inside the non-mfc class a CWND derived class which handles the OnTimer event.
This leads to some weird member access issues and I would like to know if there's a wiser way to accomplish this.

TIA.
[red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Can you not just create a timer and pass a pointer to a timer callback routine instead of handling the WM_TIMER in a window class ?
Rum am Morgen vorkommt Kummer und Sorgen... Cheers !

Mr. Rum
 
Well.. I said that that's NOT an MFC class;
Can I create a timer without a function? Or am I missing something here?

Thanks for your reply... [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
You do not need an MFC class to create a timer...

Check out the SetTimer API.
Rum am Morgen vorkommt Kummer und Sorgen... Cheers !

Mr. Rum
 
You do not need MFC or a Window when you use the [tt]SetTimer()[/tt] API call.
tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
Sorry for my probably short description of the problem...
I was trying to create a timer without WINDOWS, be it MFC or native win API created.

Any timer I found needs a HWND (SetTimer from CWnd calls at its turn the lower level functions) and that's just what I don't want to have.

I need to know if is there a way to implement a timer in windows, without having to have a message queue (attached to a window).

Thanks... [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Just pass NULL as the HWND parameter of the API function [tt]SetTimer()[/tt] and it will not associate the timer with any particular window. :)
tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
???

err...

Duh...
I actually am more fond of the low level API's, regardless of their flavor (C, win32 API, rather that C# or MFC), but I was drown into MFC... And if you pass NULL to CWnd::SetTimer, it will just assert, so I figured that the same should happen to SetTimer API and did not check further.

Thanks for your helpful tip! I was having my eyes wide shut (loved that movie :))

[red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
I believe though that the best reference is still in the MSDEV (as usual).
The article :
Using a TimerProc Function in MFC Application
Is right on the target. Also, looking up a reference to Hood0397.exe will lead to another excellent article on this issue.
Try them out... [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top