winform 프로젝트에서 form 위에 panel 컨트롤을 올리고, 이 panel 컨트롤 안에 응용프로그램이 실행 되도록 하였습니다. 이 응용 프로그램이 작업 표시줄에 표시 되지 않게 하고 싶어서 아래와 같이 해봤지만… 윈도우 7 32비트에서는 적용 되지가 않고, 윈도우 7 64비트 되는데, 윈도우 10 / 11 애서는 됩니다…
== Win32API 클래스 ==
[DllImport("user32.dll", EntryPoint = "GetWindowLongA", SetLastError = true)]
public static extern long GetWindowLong(IntPtr hwnd, int nIndex);
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr", SetLastError = true)]
public static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
public static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex)
{
if (IntPtr.Size == 4) // 32비트
{
return new IntPtr(GetWindowLong(hWnd, nIndex));
}
else // 64비트
{
return GetWindowLongPtr64(hWnd, nIndex);
}
}
== 메인 클래스 ==
// 작업 표시줄에 표시되지 않도록 설정
long exStyle = (long)Win32API.GetWindowLongPtr(app.MainWindowHandle, Win32API.GWL_EXSTYLE).ToInt64();
//Win32API.SetWindowLong(new HandleRef(this, app.MainWindowHandle), Win32API.GWL_EXSTYLE, (int)(exStyle | Win32API.WS_EX_TOOLWINDOW));
Win32API.SetWindowLong(new HandleRef(this, app.MainWindowHandle), Win32API.GWL_EXSTYLE, (int)(exStyle | Win32API.WS_EX_TOOLWINDOW | Win32API.WS_EX_APPWINDOW));
int exStyle = Win32API.GetWindowLong(app.MainWindowHandle, Win32API.GWL_EXSTYLE);
// Modify the style
exStyle |= Win32API.WS_EX_TOOLWINDOW;
exStyle &= ~Win32API.WS_EX_APPWINDOW;
// Set the new style
Win32API.SetWindowLong(app.MainWindowHandle, Win32API.GWL_EXSTYLE, exStyle);
// Hide and show the window for the new style to take effect
Win32API.ShowWindow(app.MainWindowHandle, Win32API.SW_HIDE);
Win32API.ShowWindow(app.MainWindowHandle, Win32API.SW_SHOW);
위와 같은 코드로 해도, 윈도우 7 ( Windows Embedded Standard ) 에서는 안되네요