Codeexemoi
Codeexemoi
exe
running inside a Panel in a C# WinForms application, you can use the Windows API
(user32.dll) to modify the window style.
---
You need to remove window decorations by modifying the GWL_STYLE attribute of the
window using the SetWindowLong function.
---
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")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int
dwNewLong);
public MainForm()
{
InitializeComponent();
RunExternalAppInsidePanel();
}
process.Start();
process.WaitForInputIdle();
if (process.MainWindowHandle != IntPtr.Zero)
{
// Embed the EXE window into the panel
SetParent(process.MainWindowHandle, this.panelContainer.Handle);
---
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.