Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Runtime.InteropServices
- Public Class WindowTopmost
- <DllImport("user32.dll", SetLastError:=True)> _
- Private Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, _
- ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, _
- ByVal cy As Integer, ByVal wFlags As Long) As Boolean
- End Function
- '常に手前 引数は対象のウィンドウハンドル
- Public Sub SetWindowTop(ByVal hWnd As Long)
- Const HWND_TOPMOST = -&H1 '常に最前面
- Const SWP_NOSIZE = &H1 'サイズ変更しない
- Const SWP_NOMOVE = &H2 '位置変更しない
- Call SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
- End Sub
- '常に手前を解除 引数は対象のウィンドウハンドル
- Public Sub CancelWindowTop(ByVal hWnd As Long)
- Const HWND_NOTOPMOST = -&H2
- Const SWP_NOSIZE = &H1 'サイズ変更しない
- Const SWP_NOMOVE = &H2 '位置変更しない
- Const SWP_SHOWWINDOW = &H40 'ウィンドウを表示
- Call SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_SHOWWINDOW)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement