Click here to Skip to main content
15,891,828 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
AnswerRe: How can browser load img from memory? Pin
Prakash Nadar18-Mar-05 2:14
Prakash Nadar18-Mar-05 2:14 
AnswerRe: How can browser load img from memory? Pin
Ravi Bhavnani18-Mar-05 3:01
professionalRavi Bhavnani18-Mar-05 3:01 
AnswerRe: How can browser load img from memory? Pin
Tcpip200518-Mar-05 3:58
Tcpip200518-Mar-05 3:58 
Generalconvert string to ascii in vc++ Pin
nehathoma17-Mar-05 23:05
nehathoma17-Mar-05 23:05 
GeneralRe: convert string to ascii in vc++ Pin
ThatsAlok18-Mar-05 0:03
ThatsAlok18-Mar-05 0:03 
GeneralRe: convert string to ascii in vc++ Pin
nehathoma18-Mar-05 0:22
nehathoma18-Mar-05 0:22 
GeneralRe: convert string to ascii in vc++ Pin
Bob Stanneveld18-Mar-05 0:26
Bob Stanneveld18-Mar-05 0:26 
GeneralRe: convert string to ascii in vc++ Pin
nehathoma18-Mar-05 0:31
nehathoma18-Mar-05 0:31 
GeneralRe: convert string to ascii in vc++ Pin
Bob Stanneveld18-Mar-05 1:05
Bob Stanneveld18-Mar-05 1:05 
GeneralRe: convert string to ascii in vc++ Pin
ThatsAlok18-Mar-05 0:31
ThatsAlok18-Mar-05 0:31 

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.