Created
November 1, 2017 12:10
-
-
Save nmfisher/08a7574f759da308a99de7826adfc4d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hwndSource = HwndSource.FromHwnd(handle); | |
if (hwndSource != null) | |
{ | |
hwndSource.AddHook(WindowProc); | |
} | |
WinAPI.ShowWindowAsync(new WindowInteropHelper(OverlayForm).Handle, 0); | |
private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) | |
{ | |
switch (msg) | |
{ | |
case 0x0003: | |
uint uFlags = WinAPI.SWP_NOACTIVATE | WinAPI.SWP_NOZORDER; | |
int parent = Application.ActiveWindow.Hwnd; | |
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(); | |
WinAPI.GetWindowRect((IntPtr)parent, ref rect); | |
WinAPI.SetWindowPos((uint)hwnd.ToInt32(), parent, 0, 0, rect.Right, rect.Bottom, uFlags); | |
break; | |
} | |
return (IntPtr)0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[DllImport("user32.dll")]
public static extern IntPtr SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hWnd, int id);