Guest_imported
New member
- Jan 1, 1970
- 0
I have writen a program with GUI in C++. It is used to get the many kinds of system message by using SetWindowsHookEx.
I have two functions.
The first is:
void createHook()
{
hMouseHook = SetWindowsHookEx( WH_MOUSE, (HOOKPROC) MouseHookProc, hInst, 0L );
}
The second is:
LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam )
{
LPMOUSEHOOKSTRUCT MouseHookParam;
if ( nCode >= 0 )
if ( wParam == WM_MOUSEMOVE )
{
if ( nCode == HC_NOREMOVE )
strcpy(szType, "NOT Removed from Queue"
else
strcpy(szType, "REMOVED from Queue"
MouseHookParam = (MOUSEHOOKSTRUCT *) lParam;
printf("Mouse at X = %d, Y = %d is %s\n\n", MouseHookParam->pt.x, MouseHookParam->pt.y, szType );
/// write to file to show result
f1=fopen("c:\\report.txt","a+"
fprintf(f1, "Mosue Location At ( %d, %d )\n", MouseHookParam->pt.x, MouseHookParam->pt.y);
fclose(f1);
///
}
return ( CallNextHookEx(hMouseHook, nCode, wParam, lParam) );
}
The problem is that if the mouse moves inside the GUI frame, the data can be saved in a text file and printed out on the screen, but the mouse moves outside the GUI frame, the mouse data can be only saved in a text file, but it cannot be printed on the console screen.
The printf seems not to run and by-pass this statement.
Why? plz help me, Hero!!! Thz a lot!!!
I have two functions.
The first is:
void createHook()
{
hMouseHook = SetWindowsHookEx( WH_MOUSE, (HOOKPROC) MouseHookProc, hInst, 0L );
}
The second is:
LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam )
{
LPMOUSEHOOKSTRUCT MouseHookParam;
if ( nCode >= 0 )
if ( wParam == WM_MOUSEMOVE )
{
if ( nCode == HC_NOREMOVE )
strcpy(szType, "NOT Removed from Queue"
else
strcpy(szType, "REMOVED from Queue"
MouseHookParam = (MOUSEHOOKSTRUCT *) lParam;
printf("Mouse at X = %d, Y = %d is %s\n\n", MouseHookParam->pt.x, MouseHookParam->pt.y, szType );
/// write to file to show result
f1=fopen("c:\\report.txt","a+"
fprintf(f1, "Mosue Location At ( %d, %d )\n", MouseHookParam->pt.x, MouseHookParam->pt.y);
fclose(f1);
///
}
return ( CallNextHookEx(hMouseHook, nCode, wParam, lParam) );
}
The problem is that if the mouse moves inside the GUI frame, the data can be saved in a text file and printed out on the screen, but the mouse moves outside the GUI frame, the mouse data can be only saved in a text file, but it cannot be printed on the console screen.
The printf seems not to run and by-pass this statement.
Why? plz help me, Hero!!! Thz a lot!!!