Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在不失去控制框的情况下从alt选项卡隐藏表单_C#_Windows_Forms_Winapi - Fatal编程技术网

C# 在不失去控制框的情况下从alt选项卡隐藏表单

C# 在不失去控制框的情况下从alt选项卡隐藏表单,c#,windows,forms,winapi,C#,Windows,Forms,Winapi,我正在使用Windows API隐藏第三方申请表 使用以下代码从alt选项卡: [DllImport("user32.dll")] public static extern int SetWindowLong(IntPtr window, int index, int value); [DllImport("user32.dll")] public static extern int GetWindowLong(IntPtr window, int index); int GWL_EXSTYL

我正在使用Windows API隐藏第三方申请表
使用以下代码从alt选项卡:

[DllImport("user32.dll")]
public static extern int SetWindowLong(IntPtr window, int index, int value);
[DllImport("user32.dll")]
public static extern int GetWindowLong(IntPtr window, int index);

int GWL_EXSTYLE = -20;
int WS_EX_TOOLWINDOW = 0x00000080;
int WS_EX_APPWINDOW;

private void Hide_AltTab(IntPtr x)
{
     //Get and store Current Style before Hide
     WS_EX_APPWINDOW = GetWindowLong(Handle, GWL_EXSTYLE);
     //Hide
     SetWindowLong(x, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
}

private void Show_AltTab(IntPtr x)
{
     //Restore Default Style
     SetWindowLong(x, GWL_EXSTYLE, WS_EX_APPWINDOW);
}
此代码可以很好地从alt tab隐藏表单
但是我的问题是:
当我从alt选项卡隐藏表单时,控制框消失

之后


那么我必须使用WS_EX_TOOLWINDOW中的值来从alt tab隐藏表单并保留ControlBox?

你的hide_AltTab()方法毫无意义,它根本不会更改样式标志。您必须发布您实际使用的代码。@HansPassant这是我的错误,我更正了,谢谢这是一个工具窗口。你需要你的窗口被一个不可见的窗口所拥有。@DavidHeffernan我要修改的标志是什么?不是那么简单。正常窗口。不是工具窗口,也不是应用程序窗口。但你必须让窗户归一扇看不见的窗户所有。