vb.net在设计过程中,发现当窗口化的窗体最大化后,里面的组件不能被放大~~这个问题vb.net窗体停靠 , 如有可能你应当先把大的控件停靠在窗体的某部分,其vb.net窗体停靠他的控件用form的resize事件触发控件宽高的数值或控件位置坐标的数值 。例:
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Dim pLabel1, pTextBox1, pButton1 As New Point
pLabel1.X = CInt(Me.Width / 7)
pLabel1.Y = CInt(Me.Height / 8) + 4
pTextBox1.X = CInt(Me.Width / 5)
pTextBox1.Y = CInt(Me.Height / 8)
pButton1.X = CInt(Me.Width / 3)
pButton1.Y = CInt(Me.Height / 8) - 1
Me.Label1.Location = pLabel1
Me.TextBox1.Location = pTextBox1
Me.Button1.Location = pButton1
End Sub
以上只是改变了控件的位置,如需改变控件的大小 , 重新定义计算控件的size属性
vb.net窗体靠屏幕边缘触发事件建立新的form,加入一个timer,interval设为100
Option Explicit
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Dim p As POINTAPI
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_TOPMOST = -1
Private Const SWP_NOMOVE = H2
Private Const SWP_NOSIZE = H1
Private Sub Form_Load()
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE '加载窗口是指定窗口在最顶层
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
GetCursorPos p
If Me.Top = 0 Then 'form1 is not hide and form1's top is 0
'hide form
If p.YMe.Height / 15 + Me.Top / 15 Or p.XMe.Width / 15 + Me.Left / 15 Or p.XMe.Left / 15 Then 'mouse is not over form1
Me.Top = 0 - Me.Height + 50
End If
'show form
If p.XMe.Left / 15 And p.XMe.Left / 15 + Me.Width / 15 And p.Y3 Then 'mouse is over form
Me.Top = 0
End If
End If
【vb.net窗体停靠 vb中窗体是什么意思】If Me.Left = 0 Then ''form1 is not hide form1's left is 0
'hide form
If p.YMe.Height / 15 + Me.Top / 15 Or p.YMe.Top / 15 Or p.XMe.Width / 15 + Me.Left / 15 Then 'mouse is not over form1
Me.Left = 0 - Me.Width + 50
End If
'show form
If p.X3 And p.YMe.Top / 15 And p.YMe.Height / 15 + Me.Top / 15 Then 'mouse is over form
Me.Left = 0
End If
End If
If Me.Left = Screen.Width - Me.Width Then
'hide form
If p.YMe.Height / 15 + Me.Top / 15 Or p.YMe.Top / 15 Or p.XMe.Left / 15 Then 'mouse is not over form1
Me.Left = Screen.Width - 50
End If
'show form
If p.XScreen.Width / 15 - 3 And p.YMe.Top / 15 And p.YMe.Height / 15 + Me.Top / 15 Then 'mouse is over form
Me.Left = Screen.Width - Me.Width
End If
End If
End Sub
VB.NET的窗体是通过什么属性来控制在屏幕上的位置的?.Top 和 .Left
.Top 是距离屏幕顶端的距离,也就是Y坐标
.Left 是距离屏幕左边的距离,也就是X坐标
例如
Private Sub Form_Load()
With Me
.Top = 0
.Left = 0
End With
End Sub
把自己的位置调到最左上角
VB.NET怎么做永远停靠在屏幕上的东西本质是一个不规则形状的窗体,把窗体的 TopMost 属性设为 True 即可 。
vb.net窗体停靠的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vb中窗体是什么意思、vb.net窗体停靠的信息别忘了在本站进行查找喔 。
推荐阅读
- 好玩的手游电脑射击游戏,电脑射击类手游排行榜前十名
- postgresql数据完整性的简单介绍
- chatgpt违规发言,违规发言题答案2020
- linuxaux命令 linux aux
- java怎么替换代码,java中怎么替换字符串
- 捕鱼夺宝游戏开发,捕鱼夺宝天天赢话费
- 包含黄播直播平台排名的词条
- 怎么开启mysql 怎么开启mysqlbinlog
- 怎么正常启动旧电脑硬盘,怎么把老电脑的硬盘装到新电脑上