Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Outlook Newsgroups
Outlook Program Addins
Outlook eating up delete keypress Options
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Reinwald, post: 4815911"] Hey, Well this article helped me also and now the keystrokes work on the internet explorer control. Also thanks Dmitry for the help. ------------i have pasted the article below -------------------------------- ATL and Standard C++ When hosting the WebBrowser control in either an ATL application or one written in standard C++, the solution is sometimes rather simple. All you have to do is query the WebBrowser control for the IOleInPlaceActiveObject interface and call its TranslateAccelerator method. Typically, you call this method in your handler function for the WM_KEYDOWN message. Figure 2 contains ATL and standard C++ code that shows how to call the TranslateAccelerator method to fix the keystroke problem. Sometimes your application will not automatically be sent WM_KEYDOWN messages for accelerator keys. In this case, you must manually send this message to your window. Here is a sample message pump that sends all keyboard messages to the window of your application: while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); // Send all keyboard messages to the window of your // application. hwndApp is the window handle of // your application. // if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) ::SendMessage(hwndApp, msg.message, msg.wParam, msg.lParam); DispatchMessage(&msg); } Win32 SDK Modal Dialogs The Win32? dialog box functions (DialogBox, DialogBoxIndirect, DialogBoxIndirectParam, and DialogBoxParam) are very helpful when creating modal dialog boxes. They take care of handling the message pump for your application. However, this creates a problem when you are trying to fix these keystroke problems. Where do you put the call to TranslateAccelerator? Unfortunately, if you need to host the WebBrowser control in a dialog, it is not a good idea to use these functions to create the modal dialog. The reason for this is simple. When focus is set to a control on a dialog, the control is sent the WB_GETDLGCODE message. Controls typically respond to this message by returning DLGC_WANTALLKEYS. Then the control is given a chance to handle all keys entered by the user. The WebBrowser control returns DLGC_WANTARROWS| DLGC_WANTCHARS in response to the WM_GETDLGCODE message. This means that it will not handle certain keys such as Tab and Delete. Therefore, to work around these keystroke problems, you need to have control of the message pump so that you can call TranslateAccelerator. For these reasons, I recommend that you do not use the Win32 dialog box functions to create your modal dialog box. Create the dialog window yourself so you have control of the message pump. You can use MFC or ATL to create this dialog. In addition, if you just need a modal dialog that displays a Web page, you can use the DHTML showModalDialog function provided by Microsoft Internet Explorer. There is one other option you can use to fix these problems, instead of creating the dialog window manually. You can use a Windows hook. This will enable you to retrieve all keyboard messages for the current thread and then call TranslateAccelerator so that accelerator keys will be processed. There is one problem with this approach, however. When the focus is on the WebBrowser control and you attempt to change focus between controls on the Web page by pressing tab, the focus will never leave the WebBrowser window. This means that you can Tab between controls on the Web page or between controls in your application, but not both. There are four steps required to set up a Windows hook to work around the keystroke problems in a Win32 SDK dialog. First, declare your hook procedure in your header file. static LRESULT CALLBACK GetMsgHookProc(int nCode, WPARAM wParam, LPARAM lParam); Next, set your hook procedure during initialization by calling SetWindowsHookEx. Also, make sure to save the returned hook handle so that you can unhook the procedure when you are shutting down or when it is no longer needed. // Declare this global handle in one of your project files. HHOOK g_hook; // Place this code inside an initialization // method in your implementation file (.cpp) g_hook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgHookProc, NULL, GetCurrentThreadId()); After that, implement your hook procedure and call TranslateAccelerator. LRESULT CALLBACK CYourClass::GetMsgHookProc(int nCode, WPARAM wParam, LPARAM lParam) { LPCKFSEARCH pThis = (LPCKFSEARCH)GetWindowLong(hwndMain, DWL_USER); if (pThis && nCode >= 0) { MSG* pMsg = (MSG*)lParam; // m_pOleInPlaceActObj is an IOleInPlaceActiveObject // data member of the view class that is initialized // after the WebBrowser control is loaded. if (pThis->m_pOleInPlaceActObj) pThis->m_pOleInPlaceActObj->TranslateAccelerator(pMsg); // This causes the tab to work in the WebBrowser window. If you do not do // this, tabbing will happen in the dialog only. You have the choice of // tabbing in the dialog or the WebBrowser window, not both. if (pMsg->wParam == VK_TAB) ZeroMemory(pMsg, sizeof(MSG)); } return CallNextHookEx(g_hook, nCode, wParam, lParam); } Finally, when your application is shutting down or when you no longer need the hook, unhook the procedure. UnhookWindowsHookEx(g_hook); [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Outlook Newsgroups
Outlook Program Addins
Outlook eating up delete keypress Options
Top