1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| Imports System
Imports System.Diagnostics
Imports System.Runtime.InteropServices
Imports System.ComponentModel
Public Class Form1
<DllImport("User32.dll")> Public Shared Function _
MessageBox(ByVal hWnd As Integer, _
ByVal txt As String, ByVal caption As String, _
ByVal typ As Integer) As Integer
End Function
' Public Shared GetWindowRect As Void = {rcClient}
' Public Shared SetWindowPos As Void = {rcClient.left, rcClient.top, RECTWIDTH(), RECTHEIGHT()}
' Public Shared fCallDWP As Boolean = True
' Public Shared lRet As Integer = 0
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Integer, ByVal lpRect As RECT) As Integer
<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 uFlags As SetWindowPosFlags) As Boolean
End Function
<Serializable(), Flags()> _
Friend Enum SetWindowPosFlags
NoSize = &H1
NoMove = &H2
NoZOrder = &H4
NoRedraw = &H8
NoActivate = &H10
FrameChanged = &H20
' The frame changed: send WM_NCCALCSIZE
ShowWindow = &H40
HideWindow = &H80
NoCopyBits = &H100
NoOwnerZOrder = &H200
' Don't do owner Z ordering
NoSendChanging = &H400
' Don't send WM_WINDOWPOSCHANGING
DeferErase = &H2000
AsyncWindowPos = &H4000
End Enum
Structure RECT
Public Left As Integer
Public Top As Integer
Public Right As Integer
Public Bottom As Integer
End Structure
Public Sub New()
InitializeComponent()
Dim rcClient As RECT
GetWindowRect(Me.Handle, rcClient)
' Inform the application of the frame change.
SetWindowPos(Me.Handle, Nothing, rcClient.Left, rcClient.Top, rcClient.Right, rcClient.Bottom, _
SetWindowPosFlags.FrameChanged)
End Sub
End Class |
Partager