vb.net窗体停靠 vb窗体布局怎么设置

vb.net窗体靠屏幕边缘触发事件建立新vb.net窗体停靠的formvb.net窗体停靠,加入一个timervb.net窗体停靠 , 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
【vb.net窗体停靠 vb窗体布局怎么设置】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 / 15Me.Top / 15 Or p.XMe.Width / 15Me.Left / 15 Or p.XMe.Left / 15 Then 'mouse is not over form1
Me.Top = 0 - Me.Height50
End If
'show form
If p.XMe.Left / 15 And p.XMe.Left / 15Me.Width / 15 And p.Y3 Then 'mouse is over form
Me.Top = 0
End If
End If
If Me.Left = 0 Then ''form1 is not hide form1's left is 0
'hide form
If p.YMe.Height / 15Me.Top / 15 Or p.YMe.Top / 15 Or p.XMe.Width / 15Me.Left / 15 Then 'mouse is not over form1
Me.Left = 0 - Me.Width50
End If
'show form
If p.X3 And p.YMe.Top / 15 And p.YMe.Height / 15Me.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 / 15Me.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 / 15Me.Top / 15 Then 'mouse is over form
Me.Left = Screen.Width - Me.Width
End If
End If
End Sub
VB.NET怎么做永远停靠在屏幕上的东西本质是一个不规则形状的窗体,把窗体的 TopMost 属性设为 True 即可 。
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 可视化窗体应用程序设计的时候窗体在屏幕的位置StartPosition属性有如下选项,分别含义如下:
CenterParent窗体在其父窗体中居中 。
CenterScreen窗体在当前显示窗口中居中,其尺寸在窗体大小中指定 。
Manual窗体的位置由Location属性确定 。
WindowsDefaultBounds窗体定位在Windows默认位置 , 其边界也由Windows默认决定 。
WindowsDefaultLocation窗体定位在Windows默认位置,其尺寸在窗体大小中指定 。
CenterScreen的意思并不是屏幕居中(是相对的),它是在"当前显示窗口"中居中 。当用Show()方法时应选择CenterScreen,用ShowDialog()方法时应选择CenterParent,这样才能让要显示的窗口居中 。
关于vb.net窗体停靠和vb窗体布局怎么设置的介绍到此就结束了 , 不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息 , 记得收藏关注本站 。

    推荐阅读