Solved

SetTimer without CWnd but using Class Member as TimerProc

Posted on 2000-04-07
3
1,247 Views
Last Modified: 2013-11-20
Trying to figure out how to get a call to SetTimer to work with a generic class member function as TimerProc instead of a global TimerProc function.  I do not want to use CWnd and cannot seem to do this with the Windows SDK SetTimer Function.  Any help would be appreciated. Thanks.
0
Comment
Question by:Pope
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 2694953
That class member function must be a static member function. Otherwise, a non-static member function has a implicit paramter, which is the this pointer. Thus, the function prototype does not comply the one required by SetTimer.
0
 

Author Comment

by:Pope
ID: 2695013
error C2664: 'SetTimer' : cannot convert parameter 4 from 'void (struct HWND__ *,unsigned int,unsigned int,unsigned long)' to 'void (__stdcall *)(struct HWND__ *,unsigned int,unsigned i
nt,unsigned long)'

this is the error I get. Are you saying that I cannot give SetTimer a Class member function.

so CClass::TimerProc(etc...) will not work? I need the this pointer.
0
 
LVL 23

Expert Comment

by:chensu
ID: 2695127
CClass::TimerProc has to be a static member function. If you want to access the this pointer, you may use a static member variable to record the this pointer.

class CClass
{
//...

public:
    static CClass *m_pThis;

//...
};


// Initialization
CClass *CClass::m_pThis = NULL;


// Set m_pThis before calling SetTimer in a member function of CClass.
m_pThis = this;


CClass::TimerProc
{

CClass::m_pThis->...

}
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from 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

Suggested Solutions

Title # Comments Views Activity
ORA-01403: no data found 43 98
maven archtype selection in eclipse 1 57
zeroFront challenge 7 95
scoreUp challenge 14 61
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

813 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now