-1

Hello everyone.

    [DllImport("user32.dll")]
    public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
    
    public void DockAllNote(System.Windows.Forms.Panel panel)
    {
        Process[] MultiClients = Process.GetProcessesByName("notepad");
        foreach (Process Client in MultiClients)
        {
            hWndOriginalParent = Client.MainWindowHandle;
            SetParent(Client.MainWindowHandle, panel.Handle);
            panel.Refresh();
        }
    }`enter code here`

worked above code. i want to undock notepad windows.

    public void UndockNoteAll(System.Windows.Forms.Panel panel)
    {
        Process[] MultiClients = Process.GetProcessesByName("notepad");
        foreach (Process Client in MultiClients)
        {
            SetParent(Client.MainWindowHandle, IntPtr.Zero);
            panel.Refresh();
        }
    }

I tried this undock code but Undock did not work. Notepad remained on the panel. How to undock window? tried undock a year ago using IntPtr.Zero. I don't remember what the code is.

Sorry for Bad English Thanks

ÖMER
  • 15
  • 6

1 Answers1

0

Solved.

IntPtr DockedHandle = IntPtr.Zero;
IntPtr OrjinalHandle = IntPtr.Zero;
//Dock
OrjinalHandle = process.MainWindowHandle
DockedHandle = SetParent(process.MainWindowHandle, panel.Handle);
//Undock
SetParent(OrjinalHandle, DockedHandle);
ÖMER
  • 15
  • 6
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 20 '22 at 10:16