Click here to Skip to main content
15,914,447 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: sizeof() question Pin
Ravi Bhavnani18-Mar-05 11:21
professionalRavi Bhavnani18-Mar-05 11:21 
GeneralRe: sizeof() question Pin
Blake Miller18-Mar-05 11:44
Blake Miller18-Mar-05 11:44 
GeneralRe: sizeof() question Pin
Ravi Bhavnani18-Mar-05 11:53
professionalRavi Bhavnani18-Mar-05 11:53 
QuestionHow do I treat a key combination? Pin
Anonymous18-Mar-05 10:10
Anonymous18-Mar-05 10:10 
AnswerRe: How do I treat a key combination? Pin
includeh1018-Mar-05 10:33
includeh1018-Mar-05 10:33 
GeneralRe: How do I treat a key combination? Pin
Anonymous18-Mar-05 10:43
Anonymous18-Mar-05 10:43 
AnswerRe: How do I treat a key combination? Pin
Blake Miller18-Mar-05 11:47
Blake Miller18-Mar-05 11:47 
GeneralCOM question Pin
act_x18-Mar-05 9:14
act_x18-Mar-05 9:14 
GeneralDeveloper with MP3 Library Pin
fishwolf18-Mar-05 5:38
fishwolf18-Mar-05 5:38 
GeneralRe: Developer with MP3 Library Pin
Ravi Bhavnani18-Mar-05 10:24
professionalRavi Bhavnani18-Mar-05 10:24 
Generalcximage Pin
Lampros Giampouras18-Mar-05 4:22
Lampros Giampouras18-Mar-05 4:22 
GeneralRe: cximage Pin
Iain Clarke, Warrior Programmer18-Mar-05 4:28
Iain Clarke, Warrior Programmer18-Mar-05 4:28 
GeneralRe: cximage Pin
tim63518-Mar-05 4:58
tim63518-Mar-05 4:58 
Generalsend value from .dll to application Pin
Member 178485318-Mar-05 3:56
Member 178485318-Mar-05 3:56 
GeneralRe: send value from .dll to application Pin
JohnCz18-Mar-05 8:06
JohnCz18-Mar-05 8:06 
GeneralTimers Pin
bouli18-Mar-05 2:02
bouli18-Mar-05 2:02 
GeneralRe: Timers Pin
Prakash Nadar18-Mar-05 2:20
Prakash Nadar18-Mar-05 2:20 
GeneralRe: Timers Pin
Iain Clarke, Warrior Programmer18-Mar-05 4:51
Iain Clarke, Warrior Programmer18-Mar-05 4:51 
As Mr Prakash points out, you could use:

class CMyObject : public CObject
{
    ...
    void SetMyTimer ()
    {
        ....
        SetTimer (NULL, 0, m_dwDelayInMilliseconds, MyTimerCallBack);
        ....
    }

    static VOID CALLBACK MyTimerCallBack ( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime )
    {
        // Do some work here
    }
);


but if you read the docs, you'll find none of the parameters can be used to identify *which* CMyObject
needs to be dealt with.

The other option is to use SetWaitableTimer...

class CMyObject : public CObject
{
    CMyObject ()
    {
        m_hTimer = CreateWaitableTimer (NULL, TRUE, NULL); // Manual reset.
    }
    ~CMyObject ()
    {
        CancelWaitableTimer (m_hTimer);
        CloseHandle (m_hTimer);
    }

    ...
    void SetMyTimer ()
    {
        ....
        SetWaitableTimer (m_hTimer, &lintDelay, 0, &MyTimerCallBack, this, FALSE);
        ....
    }

    VOID CALLBACK MyTimerCallBack( LPVOID lpArgToCompletionRoutine, DWORD dwTimerLowValue, DWORD dwTimerHighValue)
    {
        // lpArg = this, remember?
        CMyObject *pThis = (CMyObject *)lpArgToCompletionRoutine;
        pThis->MyTimerCallback ();
    }
    void MyTimerCallBack () // We can use the same name, as we are overloading
    {
        // Do some timed work.
        ...
    }
);


Tada!

Just as well I'm avoiding doing real work, eh?

Iain.
GeneralRe: Timers Pin
Prakash Nadar19-Mar-05 18:16
Prakash Nadar19-Mar-05 18:16 
QuestionWhich collection to use? Pin
Pauwl18-Mar-05 1:41
Pauwl18-Mar-05 1:41 
AnswerRe: Which collection to use? Pin
Prakash Nadar18-Mar-05 2:21
Prakash Nadar18-Mar-05 2:21 
GeneralRe: Which collection to use? Pin
Pauwl18-Mar-05 3:48
Pauwl18-Mar-05 3:48 
GeneralRe: Which collection to use? Pin
David Crow18-Mar-05 4:01
David Crow18-Mar-05 4:01 
Generalsocket programming with threads Pin
shaans18-Mar-05 0:55
shaans18-Mar-05 0:55 
QuestionHow can browser load img from memory? Pin
Tcpip200518-Mar-05 0:53
Tcpip200518-Mar-05 0:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.