Microsoft KB Archive/166251

{|
 * width="100%"|

PRB: OFNHookProcOldStyle Doesn't Set Keyboard Focus By Default

 * }

Q166251

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK)

-

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 kbOSWinNT kbOSWin2000 kbSDKWin32 kbGrpDSUser kbOSWin

Issue type : kbprb

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch