Re: Pointers... again... f-n noobs...

From: Jarmo (jarmo_at_jarmo.com)
Date: 03/27/04


Date: Fri, 26 Mar 2004 21:45:04 -0500


"TheEngine" <zmengine@shaw.ca> wrote in message
news:qOZ8c.13027$R27.11563@pd7tw2no...
> I'm a bit lost trying to setup a multimedia timer using the Win32 API -
I'm
> pretty sure I'm not using the parameters correctly (timeSetEvent and
> TestProc callback). Can anyone tell me how I can I do this?
>
> UINT uTimerID = 0;
> void CALLBACK TestProc(UINT, UINT, DWORD, DWORD, DWORD);
> typedef struct Test {
> int a;
> int b;
> } Test;
>
> // Called before the Win32 message loop begins
> uTimerID = timeSetEvent(100, 10, (LPTIMECALLBACK)TestProc, (DWORD)&tTimer,
> TIME_PERIODIC);
>
>
> // The Timer Proc
> void CALLBACK TestProc(UINT wTimerID, UINT msg, DWORD dwUser, DWORD dw1,
> DWORD dw2) {
> Test *tTimerData = (Test *)dw1;
> cout << tTimerData.a; // also tried with tTimerData '->'
> didn't work
> }
>
> Can anyone tell me what's wrong here?

Plenty of example on the web. Looks like dw1 and dw2 are reserved and
should not be used. You should be using dwUser to retrieve your user data
(Test *tTimerData).



Relevant Pages

  • BUG: timeSetEvent() wraps after inteval of 429496
    ... There is a bug in timeSetEvent, which is used to schedule a callback ... milliseconds the actual time period will wrap back to x-429496. ... The actual exports for these time functions are in winmm.dll, and this bug ... void CALLBACK TimerProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: timeSetEvent() wraps after inteval of 429496
    ... setting a period of 430000 which generate a callback in 504ms. ... > The actual exports for these time functions are in winmm.dll, and this bug ... > // This code reproduces a bug in timeSetEvent() where if a periodic timing ... > void CALLBACK TimerProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: Using a callback function name as an argument in a function
    ... changing your design, making it more C++ and less C? ... Having defined a class (and not just a C-function callback), ... void lineCallbackFunc(DWORD hDevice, DWORD dwMsg, DWORD ... DWORD dwParam1, DWORD dwParam2, DWORD dwParam3); ...
    (microsoft.public.vc.mfc)
  • Re: Using a callback function name as an argument in a function
    ... The API callbacks are truly quaint, and the worst of them don't allow passing an arbitrary ... Since it is a callback function, you should have supplied a CALLBACK ... changing your design, making it more C++ and less C? ... void lineCallbackFunc(DWORD hDevice, DWORD dwMsg, DWORD ...
    (microsoft.public.vc.mfc)