System.Windows.Forms.Control.FromHandle(System.IntPtr)

Here are the examples of the csharp api class System.Windows.Forms.Control.FromHandle(System.IntPtr) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

56 Examples 7

1. Example

Project: Krypton
Source File: KryptonInputBox.cs
private static string InternalShow(IWin32Window owner,
                                           string prompt, 
                                           string caption,
                                           string defaultResponse)
        {
            IWin32Window showOwner = null;

            // If do not have an owner passed in then get the active window and use that instead
            if (owner == null)
                showOwner = Control.FromHandle(PI.GetActiveWindow());
            else
                showOwner = owner;

            // Show input box window as a modal dialog and then dispose of it afterwards
            using (KryptonInputBox ib = new KryptonInputBox(prompt, caption, defaultResponse))
            {
                if (showOwner == null)
                    ib.StartPosition = FormStartPosition.CenterScreen;
                else
                    ib.StartPosition = FormStartPosition.CenterParent;

                if (ib.ShowDialog(showOwner) == DialogResult.OK)
                    return ib.InputResponse;
                else
                    return string.Empty;
            }
        }

2. Example

Project: Krypton
Source File: KryptonMessageBox.cs
private static DialogResult InternalShow(IWin32Window owner,
                                       /n ..... /n //View Source file for more details /n }

3. Example

Project: ContinuousTests
Source File: GoDiagramSequenceDiagramGenerator.cs
public void GenerateAndShowDiagramFor(TestInformationGeneratedMessage message)
        {
            if (frm == null)
            {
                frm = new SequenceDiagram(_mode, _dte, _transparent);
                frm.Closed += frm_Closed;
                frm.WindowState = FormWindowState.Maximized;
            }
            var parent = Control.FromHandle(new IntPtr(_dte.MainWindow.HWnd));
            frm.Parent = parent;
            frm.Location = NativeWinPlacementAPI.GetPlacement(new IntPtr(_dte.MainWindow.HWnd));
            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.CreateDiagramFor(message);
            frm.Show();
            _lastSignature = message.Item;
        }

4. Example

Project: Cyotek.Windows.Forms.ImageBox
Source File: ImageBoxMouseWheelMessageFilter.cs
bool IMessageFilter.PreFilterMessage(ref Message m)
    {
      bool result;

      switch (m.Msg)
 /n ..... /n //View Source file for more details /n }

5. Example

Project: ImageGlass
Source File: ImageBoxMouseWheelMessageFilter.cs
bool IMessageFilter.PreFilterMessage(ref Message m)
    {
      bool result;

      switch (m.Msg)
 /n ..... /n //View Source file for more details /n }

6. Example

Project: MarkdownViewerPlusPlus
Source File: MarkdownViewer.cs
private void AboutCommand()
        {
            using (AboutDialog about = new AboutDialog())
            {
                about.ShowDialog(Control.FromHandle(PluginBase.GetCurrentScintilla()));
            }
        }

7. Example

Project: kit-kat
Source File: InputRedirection.cs
private void Game1_VisibleChanged(object sender, EventArgs e)
        {
            if (System.Windows.Forms.Control.FromHandle((Window.Handle)).Visible == true)
                System.Windows.Forms.Control.FromHandle((Window.Handle)).Visible = false;
        }

8. Example

Project: PdfViewer
Source File: PanningZoomingScrollControl.cs
public bool PreFilterMessage(ref Message m)
            {
                if (m.Msg != NativeMethods.WM_MOUSEWHEEL)
                    return false;

                var control = Control.FromHandle(NativeMethods.WindowFromPoint(Cursor.Position));

                while (control != null && !(control is PanningZoomingScrollControl))
                {
                    control = control.Parent;
                }

                if (control == null)
                    return false;

                NativeMethods.SendMessage(control.Handle, m.Msg, m.WParam, m.LParam);
                return true;
            }

9. Example

Project: PdfiumViewer
Source File: PanningZoomingScrollControl.cs
public bool PreFilterMessage(ref Message m)
            {
                if (m.Msg != NativeMethods.WM_MOUSEWHEEL)
                    return false;

                var control = Control.FromHandle(NativeMethods.WindowFromPoint(Cursor.Position));

                while (control != null && !(control is PanningZoomingScrollControl))
                {
                    control = control.Parent;
                }

                if (control == null)
                    return false;

                NativeMethods.SendMessage(control.Handle, m.Msg, m.WParam, m.LParam);
                return true;
            }

10. Example

Project: RomTerraria
Source File: ScreenHelpers.cs
public static void CooperativeFullScreenStep2(Object terrariaMain)
        {
            Game g = (Game)terrariaMain;
            System.Windows.Forms.Form mainForm = (System.Windows.Forms.Form)System.Windows.Forms.Form.FromHandle(g.Window.Handle);

            mainForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            mainForm.Location = new System.Drawing.Point(0, 0);
            mainForm.TopLevel = true;
        }

11. Example

Project: ATF
Source File: WinFormsUtil.cs
public static Control GetFocusedControl()
        {
            Control focusedControl = null;
            // To get hold of the focused control:
            IntPtr focusedHandle = User32.GetFocus();
            while (focusedHandle != IntPtr.Zero)
            {
                // Note that if the focused Control is not a .Net control, then this will return null.
                focusedControl = Control.FromHandle(focusedHandle);
                if (focusedControl != null)
                    break;
                focusedHandle = User32.GetParent(focusedHandle);
            }
            return focusedControl;
        }

12. Example

Project: ATF
Source File: WinFormsUtil.cs
private static Control GetControlFromHandle(IntPtr handle)
        {
            var control = Contr/n ..... /n //View Source file for more details /n }

13. Example

Project: bdhero
Source File: ExceptionDialog.cs
private static bool IsFormValid(IWin32Window owner)
        {
            var control = Control.FromHandle(owner.Handle);
            return !(control == null || control.IsDisposed);
        }

14. Example

Project: xenadmin
Source File: TestWrapper.cs
private static TClass GetControlFromWindow(IWin32Window window)
        {
            Control control = Control.FromHandle(window.Handle);

            if (!(control is TClass))
            {
                throw new ArgumentException("window is not a " + typeof(TClass).Name, "window");
            }

            return control as TClass;
        }

15. Example

Project: duality
Source File: EditorHelper.cs
public static Control GetFocusedControl()
		{
			IntPtr nativeFocusControl = NativeMethods.GetFocus();

			// Early-out if nothing is focused
			if (nativeFocusControl == IntPtr.Zero)
				return null;

			// Retrieve the managed Control reference and return it
			Control focusControl = Control.FromHandle(nativeFocusControl);
			return focusControl;
		}

16. Example

Project: Krypton
Source File: KryptonTaskDialog.cs
public DialogResult ShowDialog()
        {
            return ShowDialog(Control.FromHandle(PI.GetActiveWindow()));
        }

17. Example

Project: Krypton
Source File: ModalWaitDialog.cs
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
        public bool PreFilterMessage(ref Message m)
        {
            // Prevent mouse messages from activating any application windows
            if (((m.Msg >= 0x0200) && (m.Msg <= 0x0209)) || 
                ((m.Msg >= 0x00A0) && (m.Msg <= 0x00A9)))  
            {
                // Discover target control for message
                if (Control.FromHandle(m.HWnd) != null)
                {
                    // Find the form that the control is inside
                    Form f = Control.FromHandle(m.HWnd).FindForm();

                    // If the message is for this dialog then let it be dispatched
                    if ((f != null) && (f == this))
                        return false;
                }

                // Eat message to prevent dispatch
                return true;
            }
            else
                return false;
        }

18. Example

Project: ContinuousTests
Source File: MsAGLVisualization.cs
public void GenerateAndShowGraphFor(VisualGraphGeneratedMessage message)
        {
            if (_visualizer == null)
            {
                _visualizer = new AGLVisualizer(_mode, _dte, _transparent, _client);
                _visualizer.Closed += _visualizer_Closed;
                _visualizer.WindowState = FormWindowState.Maximized;
            }
            var parent = Control.FromHandle(new IntPtr(_dte.MainWindow.HWnd));
            _visualizer.Parent = parent;
            _visualizer.Location = NativeWinPlacementAPI.GetPlacement(new IntPtr(_dte.MainWindow.HWnd));
            _visualizer.StartPosition = FormStartPosition.CenterScreen;
            Logger.Write("Location is " + _visualizer.Location);
            var root = message.Nodes.First(x => x.IsRootNode);
            if(root != null)
                _lastSignature = root.FullName;
            _visualizer.Display(message);
            _visualizer.Visible = false;
            _visualizer.Show();
            
        }

19. Example

Project: lua-tilde
Source File: DocumentSwitchWindow.cs
private void DocumentSwitchWindow_KeyUp(object sender, KeyEventArgs e)
		{
			if (!e.Control)
			{
				Control focused = Control.FromHandle(Win32.GetFocus());
				this.DialogResult = DialogResult.OK;
				if (focused is Button)
				{
					DockContent content = (focused as Button).Tag as DockContent;
					ActivateDockContent(content);
				}
				e.Handled = true;
			}
		}

20. Example

Project: logwizard
Source File: win32.cs
public static Control focused_ctrl() {
            Control focusedControl = null;
            IntPtr focusedHandle = GetFocus();
            if(focusedHandle != IntPtr.Zero)
                // Note that if the focused Control is not a .Net control, then this will return null.
                focusedControl = Control.FromHandle(focusedHandle);
            return focusedControl;
        }

21. Example

Project: WzComparerR2
Source File: FrmMapRender2.cs
private void SwitchResolution(Resolution r)
        {
            Form gameWindow = (Form)Form.FromHandle(this.Window.Handle);
            switch (r)
            {
                case Resolution.Window_800_600:
                case Resolution.Window_1024_768:
                case Resolution.Window_1366_768:
                    gameWindow.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
                    break;
                case Resolution.WindowFullScreen:
                    gameWindow.SetDesktopLocation(0, 0);
                    gameWindow.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                    break;
                default:
                    r = Resolution.Window_800_600;
                    goto case Resolution.Window_800_600;
            }

            this.resolution = r;
            this.renderEnv.Camera.DisplayMode = (int)r;
            this.ui.Width = this.renderEnv.Camera.Width;
            this.ui.Height = this.renderEnv.Camera.Height;
            engine.Renderer.ResetNativeSize();
        }

22. Example

Project: mbrc-plugin
Source File: InvokeHandler.cs
public void Invoke(MethodInvoker function)
        {
            var hwnd = _api.MB_GetWindowHandle();
            var mb = (Form) Control.FromHandle(hwnd);
            mb.Invoke(function);
        }

23. Example

Project: MarkdownViewerPlusPlus
Source File: MarkdownViewer.cs
private void OptionsCommand()
        {
            using (MarkdownViewerOptions options = new MarkdownViewerOptions(ref this.configuration))
            {
                if (options.ShowDialog(Control.FromHandle(PluginBase.GetCurrentScintilla())) == DialogResult.OK)
                {
                    //Update after something potentially changed in the settings dialog
                    Update(true, true);
                }
            }
        }

24. Example

Project: Artemis-Engine
Source File: DisplayManager.cs
internal void ReinitDisplayProperties(bool overrideDirty = false)
        {
            graphicsMana/n ..... /n //View Source file for more details /n }

25. Example

Project: Toolkit
Source File: KeyboardPlatformDesktop.cs
protected override void BindWindow(object nativeWindow)
        {
            if (nativeWindow == null) throw new ArgumentNullException("nativeWindow");

            var control = nativeWindow as Control;
            if (control == null && nativeWindow is IntPtr)
            {
                control = Control.FromHandle((IntPtr)nativeWindow);
            }

            if (control != null)
            {
                control.PreviewKeyDown += HandlePreviewKeyDown;
                control.KeyDown += HandleKeyDown;
                control.KeyUp += HandleKeyUp;

                return;
            }

            throw new InvalidOperationException(string.Format("Unsupported native window: {0}", nativeWindow));
        }

26. Example

Project: Toolkit
Source File: MousePlatformDesktop.cs
protected override void BindWindow(object nativeWindow)
        {
            if (nativeWindow == null) throw new ArgumentNullException("nativeWindow");

            control = nativeWindow as Control;
            if (control == null && nativeWindow is IntPtr)
            {
                control = Control.FromHandle((IntPtr)nativeWindow);
            }

            if (control == null)
                throw new InvalidOperationException(string.Format("Unsupported native window: {0}", nativeWindow));

            control.MouseDown += HandleMouseDown;
            control.MouseUp += HandleMouseUp;
            control.MouseMove += HandleMouseMove;
            control.MouseWheel += HandleMouseWheel;
        }

27. Example

Project: Gmail-Notifier-Plus
Source File: Main.cs
private void _Preview_TabbedThumbnailClosed(object sender, TabbedThumbnailEventArgs e) {
			(Control.FromHandle(e.WindowHandle) as Form).Close();
		}

28. Example

Project: StackBuilder
Source File: Program.cs
bool IMessageFilter.PreFilterMessage(ref Message m)
            {
                // Use a switch so we can trap other messages in the future
                switch (m.Msg)
                {
                    case 0x100: // WM_KEYDOWN

                        if ((int)m.WParam == (int)Keys.F1)
                        {
                            HelpUtility.ProcessHelpRequest(Control.FromHandle(m.HWnd));
                            return true;
                        }
                        break;
                }
                return false;
            }

29. Example

Project: ReoGrid
Source File: AddressFieldControl.cs
void addressBox_LostFocus(object sender, EventArgs e)
		{
			if (dropdown != null)
			{
				// find next focus control 
				// (is there any better method to do this than WindowFromPoint?)
				try
				{
					IntPtr hwnd = unvell.Common.Win32Lib.Win32.WindowFromPoint(Cursor.Position);

					if (hwnd != IntPtr.Zero)
					{
						Control ctrl = Control.FromHandle(hwnd);
						if (ctrl == dropdown.ListBox || ctrl == dropdown)
						{
							return;
						}
					}
				}
				catch { }
			}

			if (!focused)
			{
				EndEditAddress();
			}
		}

30. Example

Project: Gum
Source File: SelectionManager.cs
private Control GetFocusedControl()
        {
            Control focusedControl = null;
            // To get hold of the focused control:
            IntPtr focusedHandle = GetFocus();
            if (focusedHandle != IntPtr.Zero)
                // Note that if the focused Control is not a .Net control, then this will return null.
                focusedControl = Control.FromHandle(focusedHandle);
            return focusedControl;
        }

31. Example

Project: xenadmin
Source File: EditTagsCommandTest.cs
public void TestMultipleSelectRbacMidnightRide()
        {
            foreach (SelectedItemCollection selection in RunTest(GetMultipleSelections()))
            {
                HandleModalDialog<NewTagDialogWrapper>("Edit Tags", Command.Execute, d =>
                {
                    // switch checkboxes for all tags
                    Util.PopulateList<ListViewItem>(d.TagsListView.Items).ForEach(i => i.Checked = !i.Checked);
                    d.OkButton.PerformClick();
                });

                // sudo dialog should now appear.
                HandleModalDialog<RoleElevationDialogWrapper>(Messages.XENCENTER, () => { }, d => d.ButtonCancel.PerformClick());

                // check there are no extra sudo dialogs (this was a bug once.)
                MWWaitFor(() => null == Win32Window.GetWindowWithText(Messages.XENCENTER, w => Control.FromHandle(w.Handle) is RoleElevationDialog), "Extra sudo dialog(s) found.");
            }
        }

32. Example

Project: ice-builder-visualstudio
Source File: CSharpConfigurationView.cs
public int ProcessAccelerator(ref Message keyboardMessage)
        {
            if(FromHandle(keyboardMessage.HWnd).PreProcessMessage(ref keyboardMessage))
            {
                return VSConstants.S_OK;
            }
            return VSConstants.S_FALSE;
        }

33. Example

Project: ice-builder-visualstudio
Source File: PropertyPage.cs
public void Activate(IntPtr parentHandle, RECT[] pRect, int modal)
        {
            try
            {
                RECT rect = pRect[0];
                ConfigurationView.Initialize(Control.FromHandle(parentHandle),
                                             Rectangle.FromLTRB(rect.left, rect.top, rect.right, rect.bottom));
            }
            catch(Exception ex)
            {
                Package.UnexpectedExceptionWarning(ex);
                throw;
            }
        }

34. Example

Project: My-FyiReporting
Source File: RdlDesigner.cs
public bool PreFilterMessage(ref Message m)
        {
#if MONO
            return false;
#else
            if (m.Msg == 0x20a)
            {
                // WM_MOUSEWHEEL, find the control at screen position m.LParam
                Point pos = new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16);
                IntPtr hWnd = WindowFromPoint(pos);
                if (hWnd != IntPtr.Zero && hWnd != m.HWnd && Control.FromHandle(hWnd) != null)
                {
                    SendMessage(hWnd, m.Msg, m.WParam, m.LParam);
                    return true;
                }
            }
            return false;
#endif
        }

35. Example

Project: My-FyiReporting
Source File: MapFile.cs
public bool PreFilterMessage(ref Message m)
        {
#if MONO
            return false;
#else
            if (m.Msg == 0x20a)
            {
                // WM_MOUSEWHEEL, find the control at screen position m.LParam
                Point pos = new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16);
                IntPtr hWnd = WindowFromPoint(pos);
                if (hWnd != IntPtr.Zero && hWnd != m.HWnd && Control.FromHandle(hWnd) != null)
                {
                    SendMessage(hWnd, m.Msg, m.WParam, m.LParam);
                    return true;
                }
            }
            return false;
#endif
        }

36. Example

Project: My-FyiReporting
Source File: RdlReader.cs
public bool PreFilterMessage(ref Message m)
        {
#if MONO
            return false;
#else
            if (m.Msg == 0x20a)
            {
                // WM_MOUSEWHEEL, find the control at screen position m.LParam
                Point pos = new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16);
                IntPtr hWnd = WindowFromPoint(pos);
                if (hWnd != IntPtr.Zero && hWnd != m.HWnd && Control.FromHandle(hWnd) != null)
                {
                    SendMessage(hWnd, m.Msg, m.WParam, m.LParam);
                    return true;
                }
            }
            return false;
#endif
        }

37. Example

Project: hexer
Source File: MainForm.cs
public bool PreFilterMessage(ref Message m)
        {
            if(m.Msg == WM_MOUSEWHEEL) {
                // WM_MOUSEWHEEL, find the control at screen position m.LParam
                var hWnd = WindowFromPoint(Cursor.Position);

                if(hWnd != IntPtr.Zero && hWnd != m.HWnd && Control.FromHandle(hWnd) != null) {
                    SendMessage(hWnd, WM_MOUSEWHEEL, m.WParam, m.LParam);
                    return true;
                }
            }
            return false;
        }

38. Example

Project: Toolkit
Source File: PointerPlatformDesktop.cs
protected override void BindWindow(object nativeWindow)
        {
            if (nativeWindow == null) throw new ArgumentNullException("nativeWindow");

            control = nativeWindow as Control;
            if (control == null && nativeWindow is IntPtr)
            {
                control = Control.FromHandle((IntPtr)nativeWindow);
            }

            if (control == null)
                throw new InvalidOperationException(string.Format("Unsupported native window: {0}", nativeWindow));

            control.MouseLeave += (o, e) => CreateAndAddPoint(PointerEventType.Exited, PointerUpdateKind.Other, 0);
            control.MouseEnter += (o, e) => CreateAndAddPoint(PointerEventType.Entered, PointerUpdateKind.Other, 0);
            control.MouseMove += (o, e) => CreateAndAddPoint(PointerEventType.Moved, PointerUpdateKind.Other, e.Delta);
            control.MouseWheel += (o, e) => CreateAndAddPoint(PointerEventType.WheelChanged, PointerUpdateKind.Other, e.Delta);

            // these events have more complex handling, so they are moved to separate methods
            control.MouseDown += HandleMouseDown;
            control.MouseUp += HandleMouseUp;

            // try register touch events
            TryRegisterTouch();
        }

39. Example

Project: ZetaResourceEditor
Source File: MyMessageBoxInformation.cs
internal static IWin32Window findOwner(IWin32Window owner)
		{
			if (owner == null)
			{
				return checkForm(Form.ActiveForm);
			}
			else
			{
				if (owner is Form)
				{
					return checkForm(owner as Form);
				}
				else
				{
					var c = Control.FromHandle(owner.Handle);
					if (c == null)
					{
						return checkForm(Form.ActiveForm);
					}
					else
					{
						var f = c.FindForm();
						if (f == null)
						{
							return checkForm(Form.ActiveForm);
						}
						else
						{
							return checkForm(f);
						}
					}
				}
			}
		}

40. Example

Project: NuBuild
Source File: SettingsPage.cs
public virtual void Activate(IntPtr parent, RECT[] pRect, int bModal)
		{
			if(this.panel == null)
			{
                if (pRect == null)
                {
                    throw new ArgumentNullException("pRect");
                }

				this.panel = new Panel();
				this.panel.Size = new Size(pRect[0].right - pRect[0].left, pRect[0].bottom - pRect[0].top);
                this.panel.Text = SR.GetString(SR.Settings, CultureInfo.CurrentUICulture);
				this.panel.Visible = false;
				this.panel.Size = new Size(550, 300);
				this.panel.CreateControl();
				NativeMethods.SetParent(this.panel.Handle, parent);
			}

			if(this.grid == null && this.project != null && this.project.Site != null)
			{
				IVSMDPropertyBrowser pb = this.project.Site.GetService(typeof(IVSMDPropertyBrowser)) as IVSMDPropertyBrowser;
				this.grid = pb.CreatePropertyGrid();
			}

			if(this.grid != null)
			{
				this.active = true;


				Control cGrid = Control.FromHandle(new IntPtr(this.grid.Handle));

				cGrid.Parent = Control.FromHandle(parent);//this.panel;
				cGrid.Size = new Size(544, 294);
				cGrid.Location = new Point(3, 3);
				cGrid.Visible = true;
				this.grid.SetOption(_PROPERTYGRIDOPTION.PGOPT_TOOLBAR, false);
				this.grid.GridSort = _PROPERTYGRIDSORT.PGSORT_CATEGORIZED | _PROPERTYGRIDSORT.PGSORT_ALPHABETICAL;
				NativeMethods.SetParent(new IntPtr(this.grid.Handle), this.panel.Handle);
				UpdateObjects();
			}
		}

41. Example

Project: gitextensions
Source File: MouseWheelRedirector.cs
public bool PreFilterMessage(ref Message m)
        {
            const int WM_MOUSEWHEEL = 0x20a;
            const int WM_MOUSEHWHEEL = 0x20e;
            if (m.Msg == WM_MOUSEWHEEL || m.Msg == WM_MOUSEHWHEEL)
            {
                // WM_MOUSEWHEEL, find the control at screen position m.LParam
                Point pos = new Point(m.LParam.ToInt32());
                IntPtr hWnd = NativeMethods.WindowFromPoint(pos);
                if (hWnd != IntPtr.Zero && hWnd != m.HWnd && Control.FromHandle(hWnd) != null)
                {
                    if (_previousHWnd != hWnd)
                    {
                        Control control = Control.FromHandle(hWnd);
                        while (control != null && !(control is GitExtensionsControl))
                            control = control.Parent;
                        _previousHWnd = hWnd;
                        _GEControl = control != null;
                    }
                    if (_GEControl)
                    {
                        NativeMethods.SendMessage(hWnd, m.Msg, m.WParam, m.LParam);
                        return true;
                    }
                }
            }
            return false;
        }

42. Example

Project: mbrc-plugin
Source File: TrackApiAdapter.cs
public LastfmStatus GetLoveStatus(string action)
        {
            var hwnd = _api.MB_GetWindowHandle();
            var mb = (Form)Control.FromHandle(hwnd);

            if (action.Equals("toggle", StringComparison.OrdinalIgnoreCase))
            {
                if (GetLfmStatus() == LastfmStatus.love || GetLfmStatus() == LastfmStatus.ban)
                {
                    mb.Invoke(new MethodInvoker(SetLfmNormalStatus));
                }
                else
                {
                    mb.Invoke(new MethodInvoker(SetLfmLoveStatus));
                }
            }
            else if (action.Equals("love", StringComparison.OrdinalIgnoreCase))
            {
                mb.Invoke(new MethodInvoker(SetLfmLoveStatus));
            }
            else if (action.Equals("ban", StringComparison.OrdinalIgnoreCase))
            {
                mb.Invoke(new MethodInvoker(SetLfmLoveBan));
            }
            else if (action.Equals("normal", StringComparison.OrdinalIgnoreCase))
            {
                mb.Invoke(new MethodInvoker(SetLfmNormalStatus));
            }

            return GetLfmStatus();
        }

43. Example

Project: referencesource
Source File: WorkflowView.cs
bool IMessageFilter.PreFilterMessage(ref Message m)
        {
            bool handled = false;
            if (m.Msg == NativeMethods.WM_KEYDOWN || m.Msg == NativeMethods.WM_SYSKEYDOWN ||
                m.Msg == NativeMethods.WM_KEYUP || m.Msg == NativeMethods.WM_SYSKEYUP)
            {
                Control control = Control.FromHandle(m.HWnd);
                if (control != null && (control == this || Controls.Contains(control)))
                {
                    KeyEventArgs eventArgs = new KeyEventArgs((Keys)(unchecked((int)(long)m.WParam)) | ModifierKeys);
                    if (m.Msg == NativeMethods.WM_KEYDOWN || m.Msg == NativeMethods.WM_SYSKEYDOWN)
                        OnKeyDown(eventArgs);
                    else
                        OnKeyUp(eventArgs);

                    handled = eventArgs.Handled;
                }
            }

            return handled;
        }

44. Example

Project: MB_SubSonic
Source File: SubSonicPlugin.cs
public bool Configure(IntPtr panelHandle)
        {
            // panelHandle will only be set if y/n ..... /n //View Source file for more details /n }

45. Example

Project: SPEDBr.NET
Source File: frmPrincipal.cs
public bool PreFilterMessage(ref Message m)
        {
            if (m.Msg == WM_LBUTTONDOWN &&
                 _controlsToMove.Contains(Control.FromHandle(m.HWnd)))
            {
                ReleaseCapture();
                SendMessage(this.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
                return true;
            }
            return false;
        }

46. Example

Project: HOPE
Source File: Program.cs
public bool PreFilterMessage(ref Message m)
		{
			if (m.Msg == WM_MOUSEWHEEL)
			{
				// LParam contains the location of the mouse pointer
				Point pos = new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16);
				IntPtr hWnd = WindowFromPoint(pos);
				if (hWnd != IntPtr.Zero && hWnd != m.HWnd && Control.FromHandle(hWnd) != null)
				{
					// redirect the message to the correct control
					SendMessage(hWnd, m.Msg, m.WParam, m.LParam);
					return true;
				}
			}
			return false;
		}

47. Example

Project: DarkUI
Source File: DockResizeFilter.cs
public bool PreFilterMessage(ref Message m)
        {
            // We only care about mouse events/n ..... /n //View Source file for more details /n }

48. Example

Project: xenadmin
Source File: Win32Window.cs
public static bool ModalDialogIsVisible()
        {
            int currentProcess = Process.GetCurrentProcess().Id;
            IntPtr mainWindowHandle = Process.GetCurrentProcess().MainWindowHandle;
            bool output = false;

            EnumWindows(delegate(IntPtr handle, int i)
            {
                Win32Window w = new Win32Window(handle);
                if (w.ProcessId == currentProcess)
                {
                    Form f = Form.FromHandle(w.Handle) as Form;

                    if (f != null && w.Handle != mainWindowHandle && f.GetType().Namespace.StartsWith("XenAdmin"))
                    {
                        output = true;
                        return false;
                    }
                }
                return true;
            }, 0);
            
            return output;
        }

49. Example

Project: bukkitgui2
Source File: AddonManager.cs
public static void LoadAddons()
		{
			if (AddonsLoaded) return;

			// construct the dictionary that we'll use to store addons during runtime
			AddonsDictionary = new Dictionary<string, IAddon>();
			TabsDictionary = new Dictionary<IAddon, UserControl>();
			SettingsDictionary = new Dictionary<IAddon, UserControl>();

			// auto unload on exit
			MainForm form = (MainForm) Control.FromHandle(Share.MainFormHandle);
			form.Closing += HandleFormClose;

			// Create and store a list with the loaded tabs, then load them to the UI.
			// max 16 addons for now

			Dictionary<string, Type> addonsToLoad = GetAvailableAddons();

			foreach (Type T in addonsToLoad.Values)
			{
				try
				{
					if (String.IsNullOrEmpty(T.Name)) continue;
					if ((T.Name != "Console" && T.Name != "Settings" && T.Name != "Starter") &&
					    Config.ReadBool(CfgIdent, "enable_" + T.Name, true) == false) continue;

					CreateAddon(T.FullName);
				}
				catch (Exception exception)
				{
					Logger.Log(LogLevel.Severe, "AddonManager", "Failed to load addon! " + T.Name, exception.Message);
				}
			}

			AddonsLoaded = true;
			RaiseAddonsReadyEvent();
		}

50. Example

Project: duality
Source File: EditorHelper.cs
public static List<Form> GetZSortedAppWindows()
		{
			List<Form> result = new List<Form>();

			// Generate a list of handles of this application's top-level forms
			List<IntPtr> openFormHandles = new List<IntPtr>();
			foreach (Form form in Application.OpenForms)
			{
				if (!form.TopLevel)
				{
					bool belongsToAnother = Application.OpenForms.OfType<Form>().Contains(form.TopLevelControl);
					if (belongsToAnother)
						continue;
				}
				openFormHandles.Add(form.Handle);
			}

			// Use WinAPI to iterate over windows in correct z-order until we found all our forms
			IntPtr hwnd = NativeMethods.GetTopWindow((IntPtr)null);
			while (hwnd != IntPtr.Zero)
			{
				// Get next window under the current handle
				hwnd = NativeMethods.GetNextWindow(hwnd, NativeMethods.GW_HWNDNEXT);

				try
				{
					if (openFormHandles.Contains(hwnd))
					{
						Form frm = Form.FromHandle(hwnd) as Form;
						result.Add(frm);

						// Found all of our windows? No need to continue.
						if (result.Count == openFormHandles.Count)
							break;
					}
				}
				catch
				{
					// Weird behaviour: In some cases, trying to cast to a Form, a handle of an object 
					// that isn't a Form will just return null. In other cases, will throw an exception.
				}
			}
			
			return result;
		}