Click to See Complete Forum and Search --> : [RESOLVED] Block F11 (Full Screen) in Internet Explorer


sanx72
February 13th, 2009, 09:34 AM
Hi,

- IE7
- Windows Vista/XP

I have an C++ ActiveX control that sits within a HTML web-page Internet Explorer which uses function keys to carry out options within the application. When I press any function key in the main window it fires as expected. However, if I open a child popup window, and press F11 or F1 I get the keypress as expected but IE also seems to get the keypress and maximises (F11) or shows its help (F1).

I am using the following styles to CreateWindowEx to open the window...

HWND hPopUp = CreateWindowEx(WS_EX_DLGMODALFRAME | WS_EX_APPWINDOW,
"MYCLASS", " ", WS_CAPTION | WS_CLIPSIBLINGS | WS_POPUP, 0, 0, 0, 0, hParent, 0, hAppInstance, NULL);

The Window is sized and positioned using SetWindowPos after creation. hParent is the hwnd of the ActiveX control embeded in the web-page which is just implementation of COleControl.

In the WndProc of the popup I put code to detect the FKey and block it from doing further processing which made no difference.

I've put some script into the web page to see if that is getting a onkeydown event and block if it does but that hasn't changed the behaviour.

I used Spy++ to see if I could see any WM_KEYDOWNs going to IE but they don't appear to get any key messages.

I'm proper stumped. Any ideas?

Cheers
sanx72

Igor Vartanov
February 13th, 2009, 11:47 AM
Please explain how do those keys bother you? An activex never should block anything in browser unless it's something ultimately critical. Critical for user, of course, not for programmer. :D

sanx72
February 16th, 2009, 03:34 AM
Well F1 is used for help in my application so showing 2 lots of help is confusing to the user and the F11 causes unecessary re-paint and scaling to occur and sometimes doesn't go to the application at all so the function is unusable making parts of the application inaccessible using keyboard. Changing the keys is not possible.

It is the users who are complaining, and ultimately, they are the guys with the money so I do my best to keep them happy, especially at the moment! ;)

Igor Vartanov
February 16th, 2009, 04:50 AM
Again, my point is an activex must not intercept anything specific to browser, and therefore must be designed not to sit on F1 and F11. But anyway, you can try to set a local keyboard hook in your activex to intercept those F keys and decide whether to pass them to IE.

sanx72
February 16th, 2009, 07:38 AM
At the moment, I am using SetWindowsHookEx to hook all the messages in the current thread to a common routine and when I get WM_KEYUP or WM_KEYDOWN for F11 I am blocking the message by returning 0. e.g.

CWinThread * pCWinThread = AfxGetThread();
hHook = SetWindowsHookEx (WH_GETMESSAGE, SmuggleKeystrokes, hInstance, pCWinThread->m_nThreadID);

In the Ole control there is also a PreTranslateMessage method that I have overriden which seems to get the WM_KEYUP event for the F11. I return TRUE here to say the message has been consumed.

Its a weird sequnce of events as I get the F11 KeyDown message in my "SmuggleKeystrokes" routine against the current edit field control within the popup, which i blocked. I then get a Keyup in the same routine but the window handle is that of the OLE control. I also block that but still get the message go through to PreTranslateMessage, which I block again but it still seems to get through to IE!!!

When you suggested a "keyboard hook" is this what you meant or is there another method I can use?

sanx72
February 16th, 2009, 10:40 AM
Just to clarify a typo, in the SmuggleKeystrokes routine I am returning the value 1 to block the WM_KEYDOWN/UP messages (as the docs I've seen imply this will cause no other WndProc to process the message) and not 0.

Igor Vartanov
February 16th, 2009, 01:24 PM
When you suggested a "keyboard hook" is this what you meant or is there another method I can use?WH_KEYBOARD_LL, that's what I meant. ;)

sanx72
February 17th, 2009, 06:52 AM
Thank you very much Igor.

I hadn't I realised I needed to go down to such a low-level to get the message before it hit the Windows message loop. I've been able to only process F11 when my app or one of its children has focus, otherwise it goes to IE as usual.