我們經常可以看到許多生動有趣的動畫鼠標,其實利用Delphi強大的功能,我們完全可以隨心所欲地制作有個人特色的鼠標。我制作了一個名為face的動畫鼠標,在常態時,它是一張圓圓的臉,臉上有一雙咕嚕嚕亂轉的大睛眼。當按下左(右)鍵時,臉的左(右)眼就眨一下。如果持續按住,則左(右)眼眨個不停。下面我以這個動畫鼠標為例,簡述如何制作動畫鼠標。 首先,在Delphi的主菜單工具下選圖像編輯器,編輯一個名為face.res的資源文件,它應該包括個人制作的五個.cur文件:faceleft.cur(圖為:圓臉上一雙向左看的眼睛),faceright.cur(圖為:圓臉上一雙向右看的眼睛),plainface.cur(圖為:圓臉上一雙向前看的眼睛),leftshrink.cur(圖為:閉著左眼的圓臉),rightshrink.cur(圖為:閉著右眼的圓臉)。 做好資源文件后,打開一個新的窗體FORM1并放置PopupMenu組件,把FORM1的屬性PopupMenu置為PopupMenu1。然后在UNIT1的INTERFACE段下加入以下代碼: {$ R face.res} 并在TForm1.FormCreate事件內加入以下代碼: screen.cursors[1]:=LoadCursor(hInstance, pChar(′lfaceleft′)); screen.cursors[2]:=LoadCursor(hInstance, pChar(′faceright′)); screen.cursors[3]:=LoadCursor(hInstance, pChar(′plainface′)); screen.cursors[4]:=LoadCursor(hInstance, pChar(′leftshrink′)); screen.cursors[5]:=LoadCursor(hInstance, pChar(′rightshrink′)); screen.cursor:=plainface; 在TForm1.FormClick事件內加入以下代碼: screen.cursor:=faceleft; screen.cursor:=plainface; 在TForm1.FormKeyDown事件內加入以下代碼: if button=MbLeft then begin screen.cursor:=leftshrink; screen.cursor:=plainface; end; if button=MbRight then begin screen.cursor:=rightshrink; screen.cursor:=plainface; end; …… 其余細節,請讀者補充。做完一切,運行它,生成exe文件,OK!一個趣味動畫鼠標就編制完成,運行它你就可以看到一張生動幽默的圓臉了。當然,你還可以依你的喜好和想象來任意設計其他有趣的動畫鼠標。
|