f you want to hide the title bar, tool buttons, and window decorations of an .
exe
running inside a Panel in a C# WinForms application, you can use the Windows API
(user32.dll) to modify the window style.
---
Solution: Remove Title Bar & Borders
You need to remove window decorations by modifying the GWL_STYLE attribute of the
window using the SetWindowLong function.
---
Updated Code to Hide Toolbars and Borders
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace EmbedExeWinForms
{
public partial class MainForm : Form
{
// Import necessary Windows API functions
[DllImport("user32.dll")]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr
hWndNewParent);
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int
dwNewLong);
private const int GWL_STYLE = -16; // Window Style
private const int WS_BORDER = 0x00800000;
private const int WS_DLGFRAME = 0x00400000;
private const int WS_CAPTION = 0x00C00000; // Includes title bar and
borders
public MainForm()
{
InitializeComponent();
RunExternalAppInsidePanel();
}
private void RunExternalAppInsidePanel()
{
Process process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = @"C:\Path\To\YourApp.exe", // Replace with your EXE
file path
WindowStyle = ProcessWindowStyle.Normal
}
};
process.Start();
process.WaitForInputIdle();
if (process.MainWindowHandle != IntPtr.Zero)
{
// Embed the EXE window into the panel
SetParent(process.MainWindowHandle, this.panelContainer.Handle);
// Remove the title bar and borders
int style = GetWindowLong(process.MainWindowHandle, GWL_STYLE);
SetWindowLong(process.MainWindowHandle, GWL_STYLE, style &
~WS_CAPTION & ~WS_BORDER & ~WS_DLGFRAME);
}
}
}
}
---
How This Works
1. SetParent → Embeds the external .exe inside a WinForms Panel.
2. GetWindowLong / SetWindowLong → Modifies the window style to remove the title
bar, toolbar, and borders.
3. Removes WS_CAPTION, WS_BORDER, and WS_DLGFRAME to ensure the embedded window has
no decorations.
---
Expected Outcome
The external application runs inside your Panel without a title bar, menu, or
borders.
The application behaves like a native part of your WinForms UI.
Let me know if you need more tweaks!