1

嗨,伙计,我在此链接中找到了有关如何在无边框窗口应用程序中使用 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个错误

首先: “不能将属性‘CreateParams’声明为‘覆盖’,因为它不会覆盖基类中的属性。”

第二: “‘CreateParams’不是‘System.Windows.Window’的成员”

4

1 回答 1

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
于 2012-05-24T20:44:31.390 回答