首先,在主窗體上生成兩個大小一樣的按鈕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