改变大小用Me.Width和Me.Height就行了,楼主想问的是允许用户改变无边框窗体的大小吧?
创新互联建站是一家专注于成都网站制作、做网站、外贸营销网站建设与策划设计,赤峰网站建设哪家好?创新互联建站做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:赤峰等地区。赤峰做网站价格咨询:028-86922220
Public Class Form1
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Int32, ByVal nIndex As Int32) As Int32
Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Int32, ByVal nIndex As Int32, ByVal dwNewLong As Int32) As Int32
Private Const GWL_STYLE As Int32 = -16
Private Const WS_THICKFRAME As Int32 = H40000
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Dim style As Int32 = GetWindowLong(Me.Handle, GWL_STYLE) Or WS_THICKFRAME
SetWindowLong(Me.Handle, GWL_STYLE, style)
End Sub
End Class
用API GetCursorPos
用Timer隔一段时间获取一次鼠标位置。
键盘输入,用 GetKeyboardState
加点分的话就给你完整的代码
Public Class NativeMethods
'获取鼠标位置
Declare Function GetCursorPos Lib "user32.dll" _
(ByRef lpPoint As System.Drawing.Point) as boolean
Private Shared keyState() As Byte
DllImport("user32.dll") _
Private Shared Function GetKeyboardState(ByVal keyState() As Byte) As Boolean
End Function
Private Shared Sub Update()
keyState = New Byte(256) {}
Dim result As Boolean = GetKeyboardState(keyState)
' Check for error:
If result = False Then
Debug.WriteLine("GetKeyBoardState error: " Marshal.GetLastWin32Error)
Throw New Exception("GetKeyBoardState error: " Marshal.GetLastWin32Error)
End If
End Sub
Public Enum LightState
Off
[On]
End Enum
' Example - the keyboard lights...
Public Shared ReadOnly Property CapsLockState() As LightState
Get
Update()
Dim isOn As Boolean = (keyState(Keys.CapsLock) = 1)
Return IIf(isOn, LightState.On, LightState.Off)
End Get
End Property
Public Shared ReadOnly Property NumLockState() As LightState
Get
Update()
Dim isOn As Boolean = (keyState(Keys.NumLock) = 1)
Return IIf(isOn, LightState.On, LightState.Off)
End Get
End Property
Public Shared ReadOnly Property ScrollLockState() As LightState
Get
Update()
Dim isOn As Boolean = (keyState(Keys.Scroll) = 1)
Return IIf(isOn, LightState.On, LightState.Off)
End Get
End Property
End Class
pinvoke.net: GetCursorPos (user32)
pinvoke.net: GetKeyboardState (user32)
窗体初始化时,设定Windowstate= maximized.
窗体分辨率仍然可以设成1920x1080。设计元素的时候拖拽,或者使用代码初始化控件。
'窗体有个属性ClientSize 是除去边框及标题栏部分的为工作区
'你要的应该就是这个了。
'设置窗体工作区的大小 例为400*300
Me.ClientSize = New Size(400,300)