你好我发现了一个关于如何在这个链接中的无边框窗口应用程序中使用alt + tab的代码 How to hide form from Alt-Tab dialog
但问题是它是用C#编码的,所以当我使用c#将其转换为vb.net进行vb.net在线转换时....
来自c#代码:
protected override CreateParams CreateParams {
get {
// Turn on WS_EX_TOOLWINDOW style bit
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x80;
return cp;
}
}
然后我使用在线转换转换为vb.net。在这里:
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
' Turn on WS_EX_TOOLWINDOW style bit
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H80
Return cp
End Get
结束财产
所以在我的代码中。在这里:
Imports System.Windows.Forms
Namespace OSOASA
Partial Public Class WindowLoginForm
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
' Turn on WS_EX_TOOLWINDOW style bit
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H80
Return cp
End Get
End Property
End Class
End Namespace
它给了我2个错误
第一: " Property' CreateParams'无法宣布'覆盖'因为它不会出现问题 基类中的属性。"
第二: 的"'的CreateParams'不是System.Windows.Window"
的成员答案 0 :(得分:2)
以下是从Alt + Tab
中删除窗口的一些方法。
只需调用方法Helper.RemoveFromAltTab(Me)
即可。
我已经测试了这段代码并且它成功运行了
当ShowInTaskbar="False"
中的Window
时。
Imports System
Imports System.Runtime.InteropServices
Imports System.Windows
Imports System.Windows.Interop
Public Class Helper
Friend Const GwlExstyle As Integer = -20
Friend Const WsExToolwindow As Integer = &H80
<DllImport("user32.dll", EntryPoint:="GetWindowLong", CharSet:=CharSet.Auto)> _
Private Shared Function GetWindowLong32(hWnd As IntPtr, nIndex As Integer) As IntPtr
End Function
<DllImport("user32.dll", EntryPoint:="SetWindowLong", CharSet:=CharSet.Auto)> _
Private Shared Function SetWindowLong(hWnd As IntPtr, nIndex As Integer, value As UInteger) As IntPtr
End Function
Friend Shared Sub RemoveFromAltTab(hwnd As IntPtr)
Dim ws As UInteger = GetWindowLong32(hwnd, GwlExstyle)
SetWindowLong(hwnd, GwlExstyle, ws Or WsExToolwindow)
End Sub
Friend Shared Sub RemoveFromAltTab(w As Window)
RemoveFromAltTab((New WindowInteropHelper(w)).Handle)
End Sub
End Class