重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
改变大小用Me.Width和Me.Height就行了,楼主想问的是允许用户改变无边框窗体的大小吧?
创新互联是一家以成都网站建设、网页设计、品牌设计、软件运维、成都网站推广、小程序App开发等移动开发为一体互联网公司。已累计为成都石凉亭等众行业中小客户提供优质的互联网建站和软件开发服务。
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
设置主窗体Opacity属性为0,FormBorderStyle属性为None,ShowInTaskbar属性为 False,这样窗体将在启动后隐藏。在窗体上放置一个NotifyIcon组件NotifyIcon1,一个ContextMenu(弹出菜单)组件 ContextMenu1,并根据需要为ContextMenu1添加菜单项。
设置NotifyIcon1的ICON属性,这个图标就是应用程序出现在系统托盘中的快捷图标;设置NotifyIcon1的Text属性为“VB.NET托盘程序”,这就是鼠标移动到托盘图标时弹出的文字说明;设置NotifyIcon1的ContextMenu属性为ContextMenu1,也就是右键单击快捷图标时的弹出菜单为 ContextMenu1。OK,按F5运行
form窗体有一个属性是startposition,把它设置为centerscreen就是居中。
代码为
me.startposition
=
formstartposition.centerscreen。
如果是非要计算分辨率的话:
my.computer.screen.bounds.width
是分辨率中的宽度
my.computer.screen.bounds.height
是分辨率中的高度
那么
me.top
=
(my.computer.screen.bounds.height
-
me.height)
/
2
me.left
=
(my.computer.screen.bounds.width
-
me.width)
/
2
就是让窗体居中啦~
'通过timer控件控制窗口从右下角上升显示
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Top = My.Computer.Screen.WorkingArea.Height - (Me.Height * intCnt * 0.1)
intCnt += 1
If intCnt 10 Then
Timer1.Stop()
intCnt = 1
End If
End Sub