/// <summary> /// Override F1 to prevent it from getting to MSHTML. Will fire the HelpRequested /// event when the F1 key is pressed /// </summary> protected override IntPtr OnKeyHooked(int nCode, UIntPtr wParam, IntPtr lParam) { // only process HC_ACTION if (nCode == HC.ACTION) { // We want one key event per key key-press. To do this we need to // mask out key-down repeats and key-ups by making sure that bits 30 // and 31 of the lParam are NOT set. Bit 30 specifies the previous // key state. The value is 1 if the key is down before the message is // sent; it is 0 if the key is up. Bit 31 specifies the transition // state. The value is 0 if the key is being pressed and 1 if it is // being released. Therefore, we are only interested in key events // where both bits are set to 0. To test for both of these bits being // set to 0 we use the constant REDUNDANT_KEY_EVENT_MASK. const uint REDUNDANT_KEY_EVENT_MASK = 0xC0000000; if (((uint)lParam & REDUNDANT_KEY_EVENT_MASK) == 0) { // extract the keyCode and combine with modifier keys Keys keyCombo = ((Keys)(int)wParam & Keys.KeyCode) | KeyboardHelper.GetModifierKeys(); if (_tabs.CheckForTabSwitch(keyCombo)) { return(new IntPtr(1)); } } } // key not handled by our hook, continue processing return(CallNextHook(nCode, wParam, lParam)); }
public void ViewContent(Control parent, Point menuLocation, int alternativeLocation, IDisposable disposeWhenDone) { try { if (!WinInet.InternetConnectionAvailable) { disposeWhenDone.Dispose(); DisplayMessage.Show(MessageId.InternetConnectionWarning); return; } // track resource that need to be disposed _disposeWhenDone = disposeWhenDone; using (new WaitCursor()) { // if the user is holding the CTRL button down then invalidate the cache bool forceResynchronize = (KeyboardHelper.GetModifierKeys() == Keys.Control); // setup download options int downloadOptions = DLCTL.DLIMAGES | DLCTL.NO_CLIENTPULL | DLCTL.NO_BEHAVIORS | DLCTL.NO_DLACTIVEXCTLS | DLCTL.SILENT; if (forceResynchronize) { downloadOptions |= DLCTL.RESYNCHRONIZE; } // determine cookies and/or network credentials WinInetCredentialsContext credentialsContext = null; try { credentialsContext = BlogClientHelper.GetCredentialsContext(_button.BlogId, _button.ContentUrl); } catch (BlogClientOperationCancelledException) { _disposeWhenDone.Dispose(); return; } // note that we have viewed the content _button.RecordButtonClicked(); // create the form and position it BrowserMiniForm form = new BrowserMiniForm(_button.ContentQueryUrl, downloadOptions, credentialsContext); form.StartPosition = FormStartPosition.Manual; form.Size = _button.ContentDisplaySize; if (!Screen.FromPoint(menuLocation).Bounds.Contains(menuLocation.X + form.Width, menuLocation.Y)) { menuLocation.X = alternativeLocation - form.Width; } form.Location = new Point(menuLocation.X + 1, menuLocation.Y); // subscribe to close event for disposal form.Closed += new EventHandler(form_Closed); // float above parent if we have one IMiniFormOwner miniFormOwner = parent.FindForm() as IMiniFormOwner; if (miniFormOwner != null) { form.FloatAboveOwner(miniFormOwner); } // show the form form.Show(); } } catch { disposeWhenDone.Dispose(); throw; } }