Share via

Embedding Notepad++ in WinForms using SetParent does not dock (opens as separate window on Windows 11 local machine)

Researcher 56 Reputation points
2026-04-22T12:57:53.8233333+00:00

We are developing a WinForms application where I need to host Notepad++ inside my application UI as a docked child window. This is done launching Notepad++ and using Win32 APIs like SetParent to reparent its main window into a container control (e.g., an MDI container or panel). However, on Windows 11 local machine, the Notepad++ window remains a separate top-level window. It does not dock or resize correctly within the parent container, even after calling SetParent and modifying window styles.

This works properly on Windows 10, Windows 11 (Virtual Machine), Windows 11 (Remote Desktop).

Question

  1. Why does this behavior occur only on a Windows 11 local machine but not in VM or Remote Desktop sessions?
  2. Is there a reliable way to embed (dock) an external application like Notepad++ inside a WinForms application on modern Windows versions?
  3. Are there any OS-level restrictions or changes in Windows 11 (e.g., windowing, DPI, security, or process isolation) that could prevent SetParent from working as expected?
Developer technologies | Windows Forms
0 comments No comments

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2026-04-22T12:58:16.37+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more
    1. The difference in behavior on a local Windows 11 machine versus Windows 10 / VM / Remote Desktop is not documented in the provided material. The context only covers general windowing and layout behavior, not low-level changes to SetParent or cross‑process reparenting semantics between OS versions or session types. No specific OS‑level explanation for this discrepancy is available in the context.
    2. The context does not describe or endorse any reliable, supported way to embed a full external application (like Notepad++) into a Windows Forms application using SetParent on modern Windows. The only supported “embedding” scenarios covered are:
      • Hosting Win32 content in WPF via HwndHost, where the hosted HWND is created specifically for that purpose and dialog styles are adjusted (for example, changing a dialog’s style to WS_CHILD | WS_BORDER | DS_CONTROL and still calling IsDialogMessage() so Win32 can process messages correctly).
      • Hosting Windows Forms controls in WPF and WPF controls in Windows Forms via WindowsFormsHost and ElementHost, where layout‑related properties are automatically managed and must not be overridden directly.
      These scenarios assume that the hosted content is designed to be embedded (same process or a dedicated child HWND), not an arbitrary external application. There is no guidance in the context that embedding an arbitrary external app’s main window via SetParent is supported or reliable.
    3. The context does describe modern Windows expectations around window behavior and layout, but it does not list any explicit Windows 11 change that blocks SetParent for external processes. It does, however, emphasize that:
      • Applications are expected to follow standard window behaviors and shell integration patterns on Windows 11, including title bar, caption buttons, and Snap Layouts.
      • Modern Windows app frameworks (like WinUI) and high‑DPI support introduce additional complexity for window sizing and layout.
      None of the provided documentation states that Windows 11 introduces a specific restriction that would prevent SetParent from working, nor does it describe any security or isolation change that directly targets cross‑process reparenting.

    Based on the available context, only supported hybrid scenarios (Win32/WPF/WinForms interop and control hosting) are documented. Embedding a third‑party application such as Notepad++ into a Windows Forms UI via SetParent is not covered or recommended, and no OS‑level workaround or guarantee of correct docking behavior is provided.


    References:

    1 person found this answer helpful.
  2. Nancy Vo (WICLOUD CORPORATION) 2,900 Reputation points Microsoft External Staff Moderator
    2026-04-23T06:33:47.1033333+00:00

    Hello @Researcher ,

    Thanks for your question.

    1. Why does this behavior occur only on a Windows 11 local machine but not in VM or Remote Desktop sessions?

    This difference is typically caused by environmental factors rather than a single documented OS change.

    On Windows 11 local, SetParent() moves the window logically but the window rendering system (DWM) still draws it visually as a separate top-level window, they go out of sync. This does not happen in other environments:

    • VM: Uses a simplified/software rendering pipeline (limited or no GPU acceleration), which appears to allow cross-process SetParent() to work visually
    • RDP: Uses GDI-based pixel remoting instead of local GPU compositing, bypassing the rendering layer that causes the issue
    • Windows 10: The same SetParent() trick works, suggesting Microsoft tightened window rendering isolation in Windows 11, likely to support new UI features like rounded corners, Snap Layouts, and Mica effects — though this specific change is not officially documented
    1. Is there a reliable way to embed (dock) an external application like Notepad++ inside a WinForms application on modern Windows versions?

    No, SetParent() across two separate processes was not officially supported . You can use an embedded editor component like ScintillaNET. Or run Notepad++ as a separate application

    While this is a non-Microsoft link, it’s official Github documentation and is safe to visit.

    1. Are there any OS-level restrictions or changes in Windows 11 (e.g., windowing, DPI, security, or process isolation) that could prevent SetParent from working as expected?
    • UIPI: If Notepad++ runs as Administrator and your app does not, Windows silently blocks SetParent() with no error or exception.
    • DPI awareness mismatch: If your WinForms app and Notepad++ run at different DPI scales, the embedded window may appear at the wrong position or outside your panel entirely

    I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.