Keyboard Event

I am trying to create a Win32 Dialog based program to accept keystrokes from the keyboard, then I will have some sort of lookup table to convert those keystrokes into another format and then I will send that out the comm port.

The problem I need help with is how to use the
SetWindowsHookEx() function to intercept the keystrokes.

I first tried to look for WM_KEYDOWN and WM_KEYUP , but apparently a Dialog based app does not get keyboard focus.

I have seen mention of SetWindowsHookEx()function but no clear explanation on how to use it. I have also looked at some info on MSDN and the code examples seem to be written for Windows 3.1 and it looks unfamiliar to what I am used to in Dev Studio.

Thanks,
Louis

Comments

  • Instead of displaying the dialog with DialogBoxParam, use CreateDialog to create the dialog and don't call IsDialogMessage in the message loop. Remember to set the WM_VISIBLE bit on the dialog template. Another way is to make a control within the dialog that will receive the keyboard messages. There's no reason to use SetWindowsHookEx for this, you only want to do that when you want to steal another program's input.

  • I am trying to create a simple dialog based app from AppWizard. From what I can tell it creates the dialog with DoModal. I have tried to create the Dialog with CreateDialog, but I am unsuccessful since there is no parent window.

    What I am trying to do is make an app with a small dialog box that you can change a few parameter. While the box has focus, I want to capture keystrokes, process them and send something out the comm port. Basically it would be like a terminal program without the view.

    If I create a single document based app, I can capture keystrokes, but I don't want the view.

  • oh, don't bother with MFC. Just make it a normal application. Then you won't have to worry about all that.

  • If you specify 0 as the parent window, the window will be a top-level window. Just remember to set the WS_VISIBLE style bit in the template.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories