PRB: OFNHookProcOldStyle Doesn't Set Keyboard Focus By Default

ID: Q166251


The information in this article applies to:
  • Microsoft Win32 Software Development Kit (SDK)
  • Microsoft Windows 2000


SYMPTOMS

Keyboard inputs generate a system beep instead of affecting an old-style File Open dialog box that has a hook procedure installed.


CAUSE

When you use a hook procedure with an old-style File Open dialog box, the keyboard focus is not set by default. Since the focus is not set to a valid control, keyboard input is disabled and generates a system beep.


RESOLUTION

To prevent this behavior, an application should manually set the focus for the File Open dialog box. This can be accomplished by handling the WM_INITDIALOG message in the old-style hook procedure:


   UINT APIENTRY HookProcOldStyle(HWND hDlg,
                                 UINT uMsgId,
                                 WPARAM wParam,
                                 LPARAM lParam)
   {
      switch (uMsgId){
          // WPARAM of this message contains the handle of the control
          // to receive focus.
          case WM_INITDIALOG:
              SetFocus((HWND)wParam);
              return 1;
          ...
          default:
              return 0;
      }
   } 

Additional query words:

Keywords : kbHook kbNTOS kbWinOS2000 kbSDKWin32 kbGrpUser kbWinOS
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: February 1, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.