?
Solved

SetTimer without CWnd but using Class Member as TimerProc

Posted on 2000-04-07
3
Medium Priority
?
1,300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 150 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses

762 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