Article ID: 124835
Article Last Modified on 5/14/2004
LRESULT CALLBACK JournalPlaybackProc(
int nCode,
WPARAM wParam,
LPARAM lParam)
{
static BOOL fDelay;
static EVENTMSG event;
static LRESULT ticks_delay;
BOOL fCallNextHook = FALSE;
LRESULT lResult = 0;
switch( nCode )
{
case HC_SKIP:
fDelay = TRUE; // <<<< CORRECT PLACE TO RESET fDelay
// Get the next event from the list. If the routine returns
// FALSE, then we are done - release the hook.
if( !GetNextEvent( &event, &ticks_delay ))
SetJournalHook( FALSE, NULL );
break;
case HC_GETNEXT:
{
// Structure information returned from previous GetNextEvent
// call.
LPEVENTMSG lpEvent = (LPEVENTMSG) lParam;
// Set the event
*lpEvent = event;
if( fDelay )
{
// Toggle pause variable so that the next call will not
// pause. Return the pause length specified by
// ticks_delay since this is the first time the event
// has been requested.
fDelay = FALSE; // <<<< CORRECT PLACE TO CLEAR fDelay
return( ticks_delay );
}
break;
}
case HC_SYSMODALOFF:
// System modal dialog is going away. Something was
// corrupted. Windows took care of removing our
// JournalPlayback hook, so no need to call
// SetJournalHook( FALSE ).
fCallNextHook = TRUE;
break;
case HC_SYSMODALON:
default:
// Something is not right here. Let the next hook handle
// it.
fCallNextHook = TRUE;
break;
}
// If the event was not processed by our code, call next hook.
if( fCallNextHook )
lResult = CallNextHookEx( s_journalHook, nCode, wParam,
lParam );
// fDelay = TRUE; // <<<< WRONG PLACE TO RESET bDelay !!!
return lResult;
}
Keywords: kbhook kbprb KB124835