用VB制作即時動態按鈕
發表于:2007-07-14來源:作者:點擊數:
標簽:
首先,在主窗體上生成兩個大小一樣的按鈕Command1和Command2,將它們的Style屬性都設成1-Graphical,將Command1的Picture屬性設為d:\ vb \ico\mail01a.ico(變化前的圖案,一個關閉的信封),將Command2的Picture屬性設為d:\vb\ico\mail101b.ico(變化后的圖案
首先,在主窗體上生成兩個大小一樣的按鈕Command1和Command2,將它們的Style屬性都設成1-Graphical,將Command1的Picture屬性設為d:\
vb\ico\mail01a.ico(變化前的圖案,一個關閉的信封),將Command2的Picture屬性設為d:\vb\ico\mail101b.ico(變化后的圖案,一個打開的信封)。
其次,在主窗體的Private Sub Form-load()中加入以下代碼:
Form1.Command1.Top=Form1.Height-7000
Form1.Command1.Left=Form1.Width-1300
Form1.Command2.Top=Form1.Height-7000
Form1.Command2.Left=Form1.Width-1300′使這兩個按鈕重合并放置在窗體的右上角
Form1.Command1.Visible=TrueForm1.Command2.Visible=False
′隱藏Command2按鈕,顯示Command1按鈕
再次,在Command1-MouseMove事件里加入以下代碼:
If Form1.Command1.Visible=True Then
Form1.Command1.Visible=False
Form1.Command2.Visible=True
End If
最后,在Form-MouseMove事件里加入如下代碼:(如果按鈕放置在圖件框上,就在Picture1-MouseMove事件里加入代碼)
If Form1.Command1.Visible=False Then
Form1.Command2.Visible=False
Form1.Command1.Visible=True
End If
原文轉自:http://www.anti-gravitydesign.com