IE插件的问题

Meteorlet 2004-10-15 10:38:48
采用ATL+MFC制作IE工具栏的时候,动态创建了下拉框,可以输入,但是这个控件不接受Backspace键,不知道为什么?跟踪过WndProc, CComboBox和CToolbarCtrl的wndproc都没有任何message.输入字符等其他键都有message,但是输入Enter是CBN_GETDROPPEDSTATE消息,为什么没有WM_KEYDOWN啊,谁遇到过这种问题,请帮忙一下,谢谢
...全文
139 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Meteorlet 2004-10-16
  • 打赏
  • 举报
回复
该问题已经圆满解决,weiziyuner说的方法应该是可行的,因为确实是加速键被IE解释了就不会发送到控件窗口里。msdn的杂志里有很详细的描述。http://msdn.microsoft.com/msdnmag/issues/01/08/c/default.aspx
只要实现IInputObject接口就可以了
weiziyuner 2004-10-15
  • 打赏
  • 举报
回复
This behavior is by design.
这句话最恶心了。
weiziyuner 2004-10-15
  • 打赏
  • 举报
回复
This article was previously published under Q233263
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);
}
weiziyuner 2004-10-15
  • 打赏
  • 举报
回复
好象要用HOOK
我再做MFC ActiveX的时候也碰到过这个问题
参考一下下面的文章你就知道了
PRB: Modeless Dialog Box in a DLL Does Not Process TAB Key

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧