'Process MainWindowHandle return 0 after used SetParent
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr SetParent(IntPtr MainWindowHandle, IntPtr Panel);
public static void Dock(IntPtr OrjinalHandle, Panel panel)
{
IntPtr DockedHandle = Native.SetParent(OrjinalHandle, panel.Handle);
}
private void button1_Click(object sender, EventArgs e)
{
IntPtr handle = Process.GetProcessesByName("notepad")[0].MainWindowHandle;
Dock(handle, panel1);
IntPtr newhandle = Process.GetProcessesByName("notepad")[0].MainWindowHandle;
MessageBox.Show("Handle value: " + newhandle.ToString("X"));
}
show 0 value in messagebox. Worked without SetParent. Why return 0? How to solve this problem? Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
