改變大小用Me.Width和Me.Height就行了,樓主想問的是允許用戶改變無邊框窗體的大小吧?
創(chuàng)新互聯(lián)是一家以成都網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計、品牌設(shè)計、軟件運維、成都網(wǎng)站推廣、小程序App開發(fā)等移動開發(fā)為一體互聯(lián)網(wǎng)公司。已累計為成都石涼亭等眾行業(yè)中小客戶提供優(yōu)質(zhì)的互聯(lián)網(wǎng)建站和軟件開發(fā)服務(wù)。
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
設(shè)置主窗體Opacity屬性為0,F(xiàn)ormBorderStyle屬性為None,ShowInTaskbar屬性為 False,這樣窗體將在啟動后隱藏。在窗體上放置一個NotifyIcon組件NotifyIcon1,一個ContextMenu(彈出菜單)組件 ContextMenu1,并根據(jù)需要為ContextMenu1添加菜單項。
設(shè)置NotifyIcon1的ICON屬性,這個圖標就是應(yīng)用程序出現(xiàn)在系統(tǒng)托盤中的快捷圖標;設(shè)置NotifyIcon1的Text屬性為“VB.NET托盤程序”,這就是鼠標移動到托盤圖標時彈出的文字說明;設(shè)置NotifyIcon1的ContextMenu屬性為ContextMenu1,也就是右鍵單擊快捷圖標時的彈出菜單為 ContextMenu1。OK,按F5運行
form窗體有一個屬性是startposition,把它設(shè)置為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