
Если же панель задач активировать, то она перекроет моё окно:

Как можно это решить?






   <DllImport("user32.dll", SetLastError:=True)> _
   Private Shared Function SetWindowPos(ByVal hwnd As IntPtr, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
   End Function
   Private Const HWND_TOPMOST = -1
   Private Sub frmFloating_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
     SetWindowPos(Me.Handle, HWND_TOPMOST, Me.Left, Me.Top, Me.Width, Me.Height, 0)
   End Sub

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Select Case m.Msg
            Case WM_WINDOWPOSCHANGING
                If Me.TopMost Then
                    Dim wp As Win32API.WINDOWPOS
                    wp = DirectCast(Marshal.PtrToStructure(m.LParam, GetType(WINDOWPOS)), WINDOWPOS)
                    wp.hwndInsertAfter = HWND_TOPMOST
                    Marshal.StructureToPtr(wp, m.LParam, True)
                End If
        End Select
        MyBase.WndProc(m)
    End Sub
<StructLayout(LayoutKind.Sequential)> _
        Public Structure WINDOWPOS
            Public hwnd As IntPtr
            Public hwndInsertAfter As IntPtr
            Public x As Integer
            Public y As Integer
            Public cx As Integer
            Public cy As Integer
            Public flags As Integer
        End Structure
        Public Const HWND_BOTTOM = 1
        Public Const HWND_TOPMOST = -1






    Declare Function SetWindowPos Lib "user32" (ByVal hwnd As IntPtr, _
                                                ByVal hWndInsertAfter As Integer, _
                                                ByVal x As Integer, _
                                                ByVal y As Integer, _
                                                ByVal cx As Integer, _
                                                ByVal cy As Integer, _
                                                ByVal wFlags As Integer) As Integer
    Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Integer
    Public Const SM_CXSCREEN As Integer = 0
    Public Const SM_CYSCREEN As Integer = 1
    Public Const HWND_TOP As Integer = 0
    Public Const SWP_SHOWWINDOW As Integer = &H40
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim x As Integer
        Dim y As Integer
        If Me.WindowState = FormWindowState.Maximized Then
            Me.TopMost = False
            Me.WindowState = FormWindowState.Normal
        End If
        Me.TopMost = True
        x = GetSystemMetrics(SM_CXSCREEN)
        y = GetSystemMetrics(SM_CYSCREEN)
        SetWindowPos(Me.Handle, HWND_TOP, 0, 0, x, y, SWP_SHOWWINDOW)
    End Sub



Сейчас этот форум просматривают: AhrefsBot и гости: 9