我在表单应用程序中使用tabcontrol,我希望在一个选项卡中显示来自其他进程的WPF窗口。我能够使用以下代码显示WPF窗口,但如果我在WPF窗口中设置Allowtransparency = true
,则不会在选项卡内部呈现它。谁能解释我为什么会这样?
void Form1_HandleCreated(object sender, EventArgs e)
{
var process = Process.Start(@"wpfWindow.exe");
process.WaitForInputIdle();
while (process.MainWindowHandle == IntPtr.Zero)
{
Thread.Sleep(10);
}
SetParent(process.MainWindowHandle, tabPage1.Handle);
SetWindowPos(process.MainWindowHandle, 0, 0, 0, (int)tabPage1.ClientSize.Width, (int)tabPage1.ClientSize.Height, WindowsConstants.SWP_NOZORDER | WindowsConstants.SWP_NOACTIVATE);
}