VB.NET通知控件基本概念解析
VB.NET開發語言的出現為我們帶來了非常大的好處。今天我們會從VB.NET通知控件的一些基本概念來對這款語言進行一個詳細的了解,希望可以對又需要的朋友有所幫助,提高大家的認知程度。
VB.NET通知控件有兩個基本的類組成:
一個 form (會實際顯示出來的部分). 一個包含所有可在form中包含的屬性的類.
類包含兩個timers, 一個用來控制漸隱漸出的動畫效果,另一個可配置為定義彈出窗口顯示多久.下面是一個演示:
- fPopup.Size = Size
- fPopup.Opacity = 0
- fPopup.Location = _ New
Point(Screen.PrimaryScreen.
WorkingArea.Right_ -
fPopup.Size.Width - 1,- _ Screen.PrimaryScreen.
WorkingArea.Bottom)- fPopup.Show()
form在Paint事件中完成繪制. 筆者使用了一下函數來獲取比指定顏色更淺/更深的顏色,但不確定是否有更好的方法.
- Private Function GetDarkerColor()
- Function GetDarkerColor(ByVal
Color As Color) As Color- Dim clNew As Color clNew =
Drawing.Color.FromArgb(255,
DedValueMin0(CInt(Color.R), _
Parent.GradientPower), DedValueMin0
(CInt(Color.G), _ Parent.GradientPower),
DedValueMin0(CInt(Color.B), _
Parent.GradientPower))- Return clNew
- End
- Function
- 為避免閃爍: Me.SetStyle(ControlStyles.
OptimizedDoubleBuffer, True)- Me.SetStyle(ControlStyles.
ResizeRedraw, True)- Me.SetStyle(ControlStyles.
AllPaintingInWmPaint, True)
如何為VB.NET通知控件實現一個隱藏窗體的方法
在PopupNotifier.vb 類中加入:
- Sub Hide()
- Sub Hide()
- tmWait.Stop()
- tmAnimation.Start()
- End Sub
在form中如此調用:
- Private Sub PopupNoti
fier1_Close()- Sub PopupNotifier1_Close()
- Handles PopupNotifier1.Close
- PopupNotifier1.Hide()
- End Sub
VB.NET通知控件的一些基本概念就為大家介紹到這里。
【編輯推薦】