Click here to Skip to main content
15,905,614 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDo you write "precondition" and "postcondition" in your comment? Pin
Link260023-Sep-03 18:27
Link260023-Sep-03 18:27 
AnswerRe: Do you write "precondition" and "postcondition" in your comment? Pin
Michael Dunn23-Sep-03 18:46
sitebuilderMichael Dunn23-Sep-03 18:46 
GeneralRe: Do you write "precondition" and "postcondition" in your comment? Pin
Link260023-Sep-03 18:55
Link260023-Sep-03 18:55 
GeneralRe: Do you write "precondition" and "postcondition" in your comment? Pin
David Crow24-Sep-03 2:22
David Crow24-Sep-03 2:22 
GeneralRe: Do you write "precondition" and "postcondition" in your comment? Pin
Link260024-Sep-03 12:15
Link260024-Sep-03 12:15 
GeneralRe: Do you write "precondition" and "postcondition" in your comment? Pin
David Crow25-Sep-03 9:44
David Crow25-Sep-03 9:44 
GeneralQuestion about mmap Pin
George223-Sep-03 16:55
George223-Sep-03 16:55 
GeneralHooking keyboard events not working on Win98 Pin
tommyfotak23-Sep-03 16:53
tommyfotak23-Sep-03 16:53 
Hi all,

I am attempting to hook the keyboard to allow it to behave as a mouse device. The application works fine on 2K and XP but not on 98 or ME. If the controlling application Window is active all works fine but if it isn't things go pear shaped. This would indicate to me that I am not get a system hook rather a thread one, but that seems improbable given it works on other platforms and the hook code resides in a dll.

Any ideas?

Here is the code I use to hook the event:

/**
* Installs the hook.
*/
KEYHOOK_API bool InstallKeyboardHook()
{
if(g_hKeyboardHook == NULL) {
g_hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, g_hInstance, NULL);
}

// Fail if the hook fails to install
if(g_hKeyboardHook == NULL) {
return false;
}

return true;
}

/**
* Removes the hook
*/
KEYHOOK_API void RemoveKeyboardHook()
{
while(!UnhookWindowsHookEx(g_hKeyboardHook)) {
Sleep(100);
}
g_hKeyboardHook = NULL;
}

/**
* Called by the hook when there is a keyboard event.
*/
KEYHOOK_API LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode >= 0) {
// Check to see if the action belongs to the space key, if so we trap it
if(wParam == VK_SPACE) {
// Only perform an action if the space key is being released
if((::GetAsyncKeyState(VK_SPACE) & 0x80000000) != 0x80000000) {
// Determine the controller and perform the appropriate action
if(GetController() == SI_SCANNER) {
SetClicked();
}
else if(GetController() == SI_MOUSE) {
SetState((GetState() + 1) % NUM_STATES);
}
}
// Trap this message
return 1;
}
}

return CallNextHookEx(g_hKeyboardHook, nCode, wParam, lParam);
}
GeneralPlatform SDK Pin
esepich23-Sep-03 15:58
esepich23-Sep-03 15:58 
GeneralRe: Platform SDK Pin
David Stone23-Sep-03 16:10
sitebuilderDavid Stone23-Sep-03 16:10 
GeneralPointer to Function for Phase Management Pin
wogerdoger23-Sep-03 15:38
wogerdoger23-Sep-03 15:38 
GeneralRe: Pointer to Function for Phase Management Pin
David Crow23-Sep-03 16:32
David Crow23-Sep-03 16:32 
GeneralCheers Pin
wogerdoger23-Sep-03 17:31
wogerdoger23-Sep-03 17:31 
GeneralWarning: The wheels have fallen off the camel Pin
wogerdoger24-Sep-03 9:04
wogerdoger24-Sep-03 9:04 
GeneralFinding hardware Device Infomation... Pin
Member 40481323-Sep-03 15:25
Member 40481323-Sep-03 15:25 
GeneralRe: Finding hardware Device Infomation... Pin
David Crow23-Sep-03 16:34
David Crow23-Sep-03 16:34 
GeneralRe: Finding hardware Device Infomation... Pin
Manikandan23-Sep-03 21:08
Manikandan23-Sep-03 21:08 
GeneralRe: Finding hardware Device Infomation... Pin
David Crow24-Sep-03 2:09
David Crow24-Sep-03 2:09 
GeneralAfter OnInitDialog() Pin
Anonymous23-Sep-03 14:07
Anonymous23-Sep-03 14:07 
GeneralRe: After OnInitDialog() Pin
Anonymous23-Sep-03 15:28
Anonymous23-Sep-03 15:28 
GeneralRe: After OnInitDialog() Pin
David Crow23-Sep-03 16:39
David Crow23-Sep-03 16:39 
GeneralRe: After OnInitDialog() Pin
Anonymous23-Sep-03 22:41
Anonymous23-Sep-03 22:41 
GeneralRe: After OnInitDialog() Pin
David Crow24-Sep-03 2:28
David Crow24-Sep-03 2:28 
GeneralRe: After OnInitDialog() Pin
thowra24-Sep-03 0:58
thowra24-Sep-03 0:58 
GeneralRe: After OnInitDialog() Pin
DougW4823-Sep-03 16:06
DougW4823-Sep-03 16:06 

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.