I have created one WPF window and added some control to it. Now I will get the window handle and hide the window.
I'll create separate application (console) and use the same windowHandle
to show the window using below api
[DllImport("User32")]
private static extern int ShowWindow(int hwnd, int nCmdShow);
but the issue is the window is coming with the black background. Not showing the control.
Can anyone help how to get it done. (Showing WPF window using window handle)
WPF window Code
var windowInteropHelper = new WindowInteropHelper(this);
int tempHandle = (int)windowInteropHelper.Handle;
string filePath = @"C:\windowHandleLog.txt";
if (File.Exists(filePath))
{
File.Delete(filePath);
}
File.AppendAllText(filePath, tempHandle.ToString());
this.Hide();
Console Application Code:
string filePath = @"C:\windowHandleLog.txt";
string handle = File.ReadAllText(filePath);
int windowHandle = Convert.ToInt32(handle);
ShowWindow(windowHandle, SW_SHOW);