Ahmed Ashraf:
Well, my code is so simple but it doesn't do what i need
*First is the shaped wpf form which I make like that:
- Allow transparency = true in window
- Put a grid
Put an Image and put source as my png image
Second is the set parent which I did it like that:
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
private static int GWL_STYLE = -16;
private static int GWL_EXSTYLE = -20;
private static int WS_CHILD = 0x40000000;
private static int WS_EX_TOOLWINDOW = 0x00000080;
Process hostProcess = Process.GetProcessById(5964);
IntPtr hostHandle = hostProcess.MainWindowHandle;
var interop = new WindowInteropHelper(this);
interop.EnsureHandle();
interop.Owner = hostHandle;
IntPtr guestHandle = interop.Handle;
SetWindowLong(guestHandle, GWL_EXSTYLE, GetWindowLong(guestHandle, GWL_EXSTYLE) | WS_EX_TOOLWINDOW);
SetWindowLong(guestHandle, GWL_STYLE, GetWindowLong(guestHandle, GWL_STYLE) | WS_CHILD);
SetParent(guestHandle, hostHandle);
That's it.
Edited: When I put both together, it doesn't show on my external exe, it just disappear.
What I need is to put a shaped wpf form into an external exe
Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE