首先,在主窗體上生成兩個大小一樣的按鈕Command1和Command2,將它們的Style屬性都設(shè)成1-Graphical,將Command1的Picture屬性設(shè)為d:\vb\ico\mail01a.ico(變化前的圖案,一個關(guān)閉的信封),將Command2的Picture屬性設(shè)為d:\vb\ico\mail101b.ico(變化后的圖案,一個打開的信封)。
其次,在主窗體的PrivateSubForm-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事件里加入以下代碼:
IfForm1.Command1.Visible=TrueThen
Form1.Command1.Visible=False
Form1.Command2.Visible=True
EndIf
′如果鼠標(biāo)移到按鈕上就顯示打開信封的圖案
最后,在Form-MouseMove事件里加入如下代碼:(如果按鈕放置在圖件框上,就在Picture1-MouseMove事件里加入代碼)
IfForm1.Command1.Visible=FalseThen
Form1.Command2.Visible=False
Form1.Command1.Visible=True
EndIf
′如果鼠標(biāo)移到按鈕外就顯示關(guān)閉信封的圖案
經(jīng)過以上幾步后,你的窗體上就有了一個即時的動態(tài)按鈕,這個按鈕的Click事件為Command2-Click??荚嚧筇崾荆罕境绦蛟赑100、32MRAM、中文版WIN95上運行通過。
其次,在主窗體的PrivateSubForm-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事件里加入以下代碼:
IfForm1.Command1.Visible=TrueThen
Form1.Command1.Visible=False
Form1.Command2.Visible=True
EndIf
′如果鼠標(biāo)移到按鈕上就顯示打開信封的圖案
最后,在Form-MouseMove事件里加入如下代碼:(如果按鈕放置在圖件框上,就在Picture1-MouseMove事件里加入代碼)
IfForm1.Command1.Visible=FalseThen
Form1.Command2.Visible=False
Form1.Command1.Visible=True
EndIf
′如果鼠標(biāo)移到按鈕外就顯示關(guān)閉信封的圖案
經(jīng)過以上幾步后,你的窗體上就有了一個即時的動態(tài)按鈕,這個按鈕的Click事件為Command2-Click??荚嚧筇崾荆罕境绦蛟赑100、32MRAM、中文版WIN95上運行通過。