PRB: OFNHookProcOldStyle Doesn't Set Keyboard Focus By Default

Last reviewed: April 2, 1997
Article ID: Q166251
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with: - Microsoft Windows NT versions 3.51, 4.0 - Microsoft Windows 95

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: 95
Keywords : kbprg UsrHks
Version : 3.51 4.0
Platform : NT WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.