今天图老师小编给大家精心推荐个自定义的TShockwaveflash教程,一起来看看过程究竟如何进行吧!喜欢还请点个赞哦~
--------------------------------------------------- -------自定义的TShockwaveflash.ocx---------------- --------------------------------------------------- --------------------------------------------------- 添加功能:对鼠标在 flash.ocx 中的信息捕获.---------- --------------------------------------------------- 可捕获鼠标信息有: 1.鼠标在控件中移动时的坐标值; 2.鼠标右击时弹出菜单的设置; 3.鼠标点击控件时移动窗体; 4.鼠标是否移入控件; --------------------------------------------------- 编写原因: 我一直在作一个flash播放器:D-Flasher. 所以,要在其中捕获鼠标的一些消息. 但原 TShockwaveFlash 组件没有这些方法. 只能通过:Application.OnMessage:=Form.Msgproc; 这样的并不高级的办法.所以作了这么一个东西. 对 TShockwaveFlash 组件作了自定义. 在原来控件上加了对鼠标的行为的监控. 使得对 Flash 控件的鼠标消息处理的效率提高了. 用起来也方便了不少. 所以共享出来.若存在什么错误,还请指正. 由于本人水平有限,也是处于学习中. 也有许多不完善的地方,欢迎大家进行修改. --------------------------------------------------- 源文件:CustomFlash.pas.你可以对它进行编译. 源码: {---------------------------------------------------------------} {---------------自定义的TShockwaveflash.ocx---------------------} {检测:1.鼠标在控件中移动时的坐标值;2.鼠标右击时弹出菜单的设置; } { 3.鼠标点击控件时移动窗体;4.鼠标是否移入控件; } {---------------------------------------------------------------} {制作日期: 2004-8-23 [ending722] e-mail:ending722@163.com } {-----------------------------------------孤血雁工作室 杨光-----} unit CustomFlash; interface uses SysUtils,Classes,Controls,Menus,windows,forms, Messages,OleCtrls, ShockwaveFlashObjects_TLB; type TCustomFlash= class(TShockwaveFlash) private MPosX:integer; MPosY:integer; //鼠标在控件上的 X Y. FPopupMenu:TPopupMenu; LMoveFrm:Boolean; //窗体是否可以移动 MIsEnter:Boolean; FMoveFrmHwnd:TForm;//接收消息的窗体 protected procedure WMMMOVE(var message:tmessage);message WM_MOUSEMOVE; procedure WMMRDOWN(var message:tmessage);message WM_RBUTTONDOWN; procedure WMMENTER(var message:tmessage);message CM_MOUSEENTER; procedure WMMLEAVE(var message:tmessage);message CM_MOUSELEAVE; public published property mouseposX:integer read MPosX; property mouseposY:integer read MPosY; property PopupMenu:TPopupMenu read FPopupMenu write FPopupMenu; property IsMoveFrm:Boolean read LMoveFrm write LMoveFrm default false; property IsEnterFrm:Boolean read MIsEnter default false; property MoveFrmName:TForm read FMoveFrmHwnd write FMoveFrmHwnd; end; procedure Register; implementation procedure Register; begin RegisterComponents('Samples', [TCustomFlash]); end; //得到鼠标移动的 X,Y 值. procedure TCustomFlash.WMMMOVE(var message:tmessage); begin MPosX:=message.LParamLo; MPosY:=message.LParamHi; //并发送给窗体. SendMessage(FMoveFrmHwnd.Handle,WM_MOUSEMOVE,message.WParam,message.LParam); if message.WParam=MK_LBUTTON then //左击,移动主窗体. if (Mouse.CursorPos.Y345) and (LMoveFrm) Then begin // 加入 标志 判断. ReleaseCapture; SendMessage(FMoveFrmHwnd.Handle,WM_SYSCOMMAND,SC_MOVE+HTCAPTION, 0); end; //在 MOUSEMOVE 时判断left是否按下, inherited; //比检测 WM_LBUTTONDOWN 效果要好的多. end; procedure TCustomFlash.WMMRDOWN(var message:tmessage); begin If Assigned(FPopupMenu) Then //右击,弹出菜单. FPopupMenu.popup(Mouse.CursorPos.X,Mouse.CursorPos.Y); end; //鼠标进入 flash.ocx procedure TCustomFlash.WMMENTER(var message:tmessage); begin MIsEnter:=true; end; //鼠标移出 flash.ocx procedure TCustomFlash.WMMLEAVE(var message:tmessage); begin MIsEnter:=false; end; end. --------------------------------------------------- 编写语言及环境: Delphi7+windows2k+sp4 完成日期: 2004-8-23 --------------------------------------------------- E-MAIL:Ending722@163.com ending722@yahoo.com.cn QQ:154041260 --------------------------------------------------