Re: CHtmlView - disabling keyboard control functions
"JWF" <firstname.lastname@example.org> wrote in message
I am using the CHtmlView to host a web application within my MFC
application. I wish to disable all navigation (via the keyboard and
menu) functionality. I want all navigation to be handled only by the web
application. I don't want the user to be able to hit he backspace key,
alt-left arrow, etc... to navigate back and forward. The web application
is being hosted does not handle this well.
I have disabled the context menu easily enough by overriding the virtual
However, I have not been able to figure out a way to disable navigation.
Any help would be appreciated.
I'll share what I did in my CDhtmlDialog app:
HRESULT CDHtmlPopupDlg::TranslateAccelerator(LPMSG lpMsg, const GUID
*pguidCmdGroup, DWORD nCmdID)
// F5 key refreshes browser contents to initial HTML contents and does not
// to be fired... therefore the translated text does not re-appear! Block
F5 key from taking effect.
if ( (lpMsg->message == WM_KEYDOWN) && (lpMsg->wParam == VK_F5) )
return CDHtmlDialog::TranslateAccelerator(lpMsg, pguidCmdGroup, nCmdID);
// Disable features of the web browser that are inappropriate when embedded
into our application
// Embedded HTML will not allow text to be selected
// Will use XP themes
// No scrollbars
// Links opened in external window
info.cbSize = sizeof(info);
SetHostFlags (info.dwFlags | DOCHOSTUIFLAG_DIALOG | DOCHOSTUIFLAG_THEME |
DOCHOSTUIFLAG_SCROLL_NO); // DOCHOSTUIFLAG_OPENNEWWIN - caused error
windows to open in Win2K/IE5; // DOCHOSTUIFLAG_DIALOG !!!! must enable
selection so OnHtmlDragStart() is called!
// Don't allow user to drop shortcut onto this window and have the browser
navigate to show that web site