PRB: Modeless Dialog Box in a DLL Does Not Process TAB Key
来源:互联网 发布:在线制图软件 编辑:程序博客网 时间:2024/05/16 15:00
SYMPTOMS
When a modeless dialog box is launched from a dynamic-link library (DLL), the TAB key and the arrow keys do not move the focus from control to control as you would expect.
CAUSE
For a modeless dialog box to process a TAB key, the message pump needs to call the IsDialogMessage API. However, if you are writing a DLL and do not have access to the .exe's source code, you cannot modify the message pump to do this.
RESOLUTION
To work around this problem, you can use a WH_GETMESSAGE hook to capture the keystroke messages and call the IsDialogMessage API. If IsDialogMessage returns TRUE, then do not pass the message on to the message pump. Set the hook when handling WM_INITDIALOG and unset it when handling the WM_DESTROY message.
STATUS
This behavior is by design.
MORE INFORMATION
The following code illustrates how to set and unset the hook as well as how to use IsDialogMessage() to process TAB key messages:
BOOL CALLBACK DllDlgProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ){ switch ( uMsg ) { case WM_INITDIALOG: hHook = SetWindowsHookEx( WH_GETMESSAGE, GetMsgProc, NULL, GetCurrentThreadId() ); return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { DestroyWindow( hwndDlg ); hwndDllDlg = NULL; } return TRUE; case WM_DESTROY: UnhookWindowsHookEx( hHook ); return FALSE; } return FALSE;}
The hook procedure, GetMsgProc, should resemble the following:LRESULT FAR PASCAL GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam){ LPMSG lpMsg = (LPMSG) lParam; if ( nCode >= 0 && PM_REMOVE == wParam ) { // Don't translate non-input events. if ( (lpMsg->message >= WM_KEYFIRST && lpMsg->message <= WM_KEYLAST) ) { if ( IsDialogMessage(hwndDllDlg, lpMsg) ) { // The value returned from this hookproc is ignored, // and it cannot be used to tell Windows the message has been handled. // To avoid further processing, convert the message to WM_NULL // before returning. lpMsg->message = WM_NULL; lpMsg->lParam = 0; lpMsg->wParam = 0; } } } return CallNextHookEx(hHook, nCode, wParam, lParam);}
http://support.microsoft.com/default.aspx?kbid=233263
- PRB: Modeless Dialog Box in a DLL Does Not Process TAB Key
- modeless dialog box
- Modeless dialog
- modeless dialog.
- Using a modeless .NET dialog to display AutoCAD object properties
- modeless dialog(转)
- ALV in a Pop up window and ALV in a dialog box
- How to load a dll resource dialog box at an application Dialog box (怎么在一个应用程序对话框动态加载DLL里的资源对话框)
- 解决Virtual Box UUID does not match the value stored in the media registry
- 091112(星期四)To use a common control in a dialog box
- Error: ‘shared_ptr’ in namespace ‘std’ does not name a type
- Parameter XXX does not exist as a named parameter in[.....]
- Trigger a button click with JavaScript on the Enter key in a text box
- Trigger a button click with JavaScript on the Enter key in a text box
- Balloons in a Box
- opencord in a box
- Update Command UI Handlers Do Not Work for Menu Attached to a Dialog Box
- Win32 Series - Modeless Dialog Boxes
- 结合substrc与instr处理字符串一例
- 发现一个好网站,it公司速查手册
- 可变参数函数
- “读书无用论”,“房奴”?
- VM Rootkits: The Next Big Threat?
- PRB: Modeless Dialog Box in a DLL Does Not Process TAB Key
- 创建显示桌面图标
- 系统出错信息及解决方案(菜菜学习贴)
- Print assembler hex in one pass
- C 运算符的优先次序
- Openlaszlo调用JavaRPC和JAVA类通信
- VIRUS RESEARCH UNIT
- 将word存入数据库并在网页中显示
- ASP分页程式之分页类AC/MS SQL