Main.pas
上传用户:mjqmds
上传日期:2022-05-05
资源大小:2827k
文件大小:57k
源码类别:

DirextX编程

开发平台:

Delphi

  1. unit Main;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes,Controls, Forms,
  5.   Dialogs, StdCtrls, ExtCtrls, dxBar, XPMenu, Buttons, dxBarExtItems,
  6.   TFlatScrollbarUnit, ImgList, LMDCustomControl, LMDCustomPanel,
  7.   LMDCustomTrackBar, LMDTrackBar, ExtDlgs, Menus, Math, DrawPanel,
  8.   TFlatSplitterUnit, TFlatPanelUnit, ComCtrls, GIFImage, GraphicEx,
  9.   AppEvnts, LMDControl, LMDBaseControl, LMDBaseGraphicControl, Graphics,
  10.   LMDGraphicControl, LMDCustomGraphicLabel, LMDGraphicLabel, PlayList, ShellAPI,
  11.   CoolTrayIcon, DropTarget, DropSource, DropURLTarget, Registry, OleServer;
  12. Const
  13.   WM_FULLSCREEN=WM_USER+1001;
  14.   WM_PLAYNEXT=WM_USER+1002;
  15.   WM_PLAYPRIOR=WM_USER+1003;
  16.   WM_STARTSHOW=WM_USER+1006;
  17.   WM_OPENREMOTEFILE=WM_USER+1007;
  18.   WM_SHOWAPP=WM_USER+1108;
  19.   WM_HIDEAPP=WM_USER+1109;
  20.   WM_KILLAPP=WM_USER+1110;
  21. type
  22.   TPlayState=(psNone,psStop,psPlay,psPause,psOne,psLoad,psPreview);
  23.   TMainForm = class(TForm)
  24.     Timer1: TTimer;
  25.     OpenDialog1: TOpenDialog;
  26.     dxBarManager1: TdxBarManager;
  27.     dxBarButton1: TdxBarButton;
  28.     dxBarButton2: TdxBarButton;
  29.     dxBarButton3: TdxBarButton;
  30.     dxBarButton4: TdxBarButton;
  31.     Panel2: TPanel;
  32.     dxBarProgressItem1: TdxBarProgressItem;
  33.     XPMenu1: TXPMenu;
  34.     dxBarSubItem1: TdxBarSubItem;
  35.     dxBarButton5: TdxBarButton;
  36.     dxBarButton6: TdxBarButton;
  37.     dxBarSubItem2: TdxBarSubItem;
  38.     dxBarSubItem3: TdxBarSubItem;
  39.     dxBarSubItem4: TdxBarSubItem;
  40.     dxBarButton7: TdxBarButton;
  41.     dxBarButton8: TdxBarButton;
  42.     dxBarSubItem5: TdxBarSubItem;
  43.     dxBarButton9: TdxBarButton;
  44.     dxBarButton10: TdxBarButton;
  45.     dxBarButton11: TdxBarButton;
  46.     dxBarButton12: TdxBarButton;
  47.     dxBarSubItem6: TdxBarSubItem;
  48.     dxBarButton13: TdxBarButton;
  49.     LMDTrackBar2: TLMDTrackBar;
  50.     SavePictureDialog1: TSavePictureDialog;
  51.     dxBarButton14: TdxBarButton;
  52.     dxBarButton15: TdxBarButton;
  53.     dxBarButton16: TdxBarButton;
  54.     dxBarButton17: TdxBarButton;
  55.     dxBarButton18: TdxBarButton;
  56.     dxBarButton19: TdxBarButton;
  57.     dxBarSubItem7: TdxBarSubItem;
  58.     dxBarButton20: TdxBarButton;
  59.     dxBarButton21: TdxBarButton;
  60.     dxBarSubItem8: TdxBarSubItem;
  61.     dxBarButton22: TdxBarButton;
  62.     dxBarButton23: TdxBarButton;
  63.     dxBarSubItem9: TdxBarSubItem;
  64.     dxBarButton24: TdxBarButton;
  65.     dxBarButton25: TdxBarButton;
  66.     dxBarButton26: TdxBarButton;
  67.     dxBarButton27: TdxBarButton;
  68.     dxBarButton28: TdxBarButton;
  69.     dxBarButton29: TdxBarButton;
  70.     dxBarButton30: TdxBarButton;
  71.     dxBarButton31: TdxBarButton;
  72.     dxBarButton32: TdxBarButton;
  73.     dxBarButton33: TdxBarButton;
  74.     PopupMenu1: TPopupMenu;
  75.     N10: TMenuItem;
  76.     N11: TMenuItem;
  77.     Panel3: TPanel;
  78.     SpeedButton5: TSpeedButton;
  79.     LMDTrackBar1: TLMDTrackBar;
  80.     Panel4: TPanel;
  81.     Panel5: TPanel;
  82.     Panel6: TPanel;
  83.     Panel1: TDrawPanel;
  84.     dxBarSubItem10: TdxBarSubItem;
  85.     dxBarButton34: TdxBarButton;
  86.     dxBarButton35: TdxBarButton;
  87.     dxBarButton36: TdxBarButton;
  88.     dxBarButton37: TdxBarButton;
  89.     dxBarButton38: TdxBarButton;
  90.     dxBarButton39: TdxBarButton;
  91.     dxBarButton40: TdxBarButton;
  92.     dxBarButton41: TdxBarButton;
  93.     dxBarButton42: TdxBarButton;
  94.     dxBarButton43: TdxBarButton;
  95.     dxBarButton44: TdxBarButton;
  96.     dxBarButton45: TdxBarButton;
  97.     N1: TMenuItem;
  98.     N2: TMenuItem;
  99.     N3: TMenuItem;
  100.     N4: TMenuItem;
  101.     N5: TMenuItem;
  102.     N6: TMenuItem;
  103.     dxBarSubItem11: TdxBarSubItem;
  104.     dxBarButton46: TdxBarButton;
  105.     dxBarButton47: TdxBarButton;
  106.     ApplicationEvents1: TApplicationEvents;
  107.     dxBarListItem1: TdxBarListItem;
  108.     dxBarButton48: TdxBarButton;
  109.     dxBarInPlaceSubItem1: TdxBarInPlaceSubItem;
  110.     dxBarTreeViewCombo1: TdxBarTreeViewCombo;
  111.     dxBarListItem2: TdxBarListItem;
  112.     dxBarButton49: TdxBarButton;
  113.     dxBarLargeButton1: TdxBarLargeButton;
  114.     dxBarLargeButton2: TdxBarLargeButton;
  115.     dxBarStatic1: TdxBarStatic;
  116.     dxBarButton50: TdxBarButton;
  117.     dxBarButton51: TdxBarButton;
  118.     dxBarEdit1: TdxBarEdit;
  119.     dxBarToolbarsListItem1: TdxBarToolbarsListItem;
  120.     dxBarButton52: TdxBarButton;
  121.     Panel7: TPanel;
  122.     SpeedButton6: TSpeedButton;
  123.     SpeedButton14: TSpeedButton;
  124.     SpeedButton1: TSpeedButton;
  125.     SpeedButton2: TSpeedButton;
  126.     SpeedButton3: TSpeedButton;
  127.     SpeedButton4: TSpeedButton;
  128.     SpeedButton7: TSpeedButton;
  129.     SpeedButton8: TSpeedButton;
  130.     SpeedButton9: TSpeedButton;
  131.     SpeedButton10: TSpeedButton;
  132.     SpeedButton12: TSpeedButton;
  133.     SpeedButton13: TSpeedButton;
  134.     SpeedButton15: TSpeedButton;
  135.     Panel22: TPanel;
  136.     OpenDialog2: TOpenDialog;
  137.     SaveDialog1: TSaveDialog;
  138.     SaveDialog2: TSaveDialog;
  139.     Panel9: TPanel;
  140.     dxBarButton53: TdxBarButton;
  141.     ListView1: TListView;
  142.     dxBarButton54: TdxBarButton;
  143.     OpenDialog3: TOpenDialog;
  144.     SpeedButton11: TSpeedButton;
  145.     CoolTrayIcon1: TCoolTrayIcon;
  146.     PopupMenu2: TPopupMenu;
  147.     N7: TMenuItem;
  148.     N8: TMenuItem;
  149.     N9: TMenuItem;
  150.     N12: TMenuItem;
  151.     N13: TMenuItem;
  152.     N14: TMenuItem;
  153.     N15: TMenuItem;
  154.     dxBarButton55: TdxBarButton;
  155.     dxBarButton56: TdxBarButton;
  156.     ImageList1: TImageList;
  157.     N16: TMenuItem;
  158.     N17: TMenuItem;
  159.     dxBarButton57: TdxBarButton;
  160.     DropURLTarget1: TDropURLTarget;
  161.     DropFileTarget1: TDropFileTarget;
  162.     DropURLTarget2: TDropURLTarget;
  163.     DropFileTarget2: TDropFileTarget;
  164.     SpeedButton16: TSpeedButton;
  165.     dxBarButton58: TdxBarButton;
  166.     dxBarSubItem12: TdxBarSubItem;
  167.     dxBarButton59: TdxBarButton;
  168.     dxBarButton60: TdxBarButton;
  169.     dxBarButton61: TdxBarButton;
  170.     dxBarButton62: TdxBarButton;
  171.     Panel8: TPanel;
  172.     Shape1: TShape;
  173.     PopupMenu3: TPopupMenu;
  174.     Timer2: TTimer;
  175.     dxBarButton63: TdxBarButton;
  176.     dxBarSubItem13: TdxBarSubItem;
  177.     dxBarButton64: TdxBarButton;
  178.     dxBarButton65: TdxBarButton;
  179.     procedure FormCreate(Sender: TObject);
  180.     procedure FormDestroy(Sender: TObject);
  181.     procedure Timer1Timer(Sender: TObject);
  182.     procedure SpeedButton4Click(Sender: TObject);
  183.     procedure SpeedButton1Click(Sender: TObject);
  184.     procedure SpeedButton2Click(Sender: TObject);
  185.     procedure SpeedButton3Click(Sender: TObject);
  186.     procedure dxBarButton4Click(Sender: TObject);
  187.     procedure SpeedButton5Click(Sender: TObject);
  188.     procedure SpeedButton7Click(Sender: TObject);
  189.     procedure SpeedButton8Click(Sender: TObject);
  190.     procedure SpeedButton9Click(Sender: TObject);
  191.     procedure SpeedButton10Click(Sender: TObject);
  192.     procedure LMDTrackBar2MouseDown(Sender: TObject; Button: TMouseButton;
  193.       Shift: TShiftState; X, Y: Integer);
  194.     procedure LMDTrackBar2MouseUp(Sender: TObject; Button: TMouseButton;
  195.       Shift: TShiftState; X, Y: Integer);
  196.     procedure LMDTrackBar2Track(Sender: TObject; ScrollCode: TScrollCode;
  197.       var ScrollPos: Integer);
  198.     procedure LMDTrackBar1Track(Sender: TObject; ScrollCode: TScrollCode;
  199.       var ScrollPos: Integer);
  200.     procedure Panel1Resize(Sender: TObject);
  201.     procedure SpeedButton6Click(Sender: TObject);
  202.     procedure SpeedButton14Click(Sender: TObject);
  203.     procedure SpeedButton15Click(Sender: TObject);
  204.     procedure dxBarButton6Click(Sender: TObject);
  205.     procedure dxBarButton14Click(Sender: TObject);
  206.     procedure dxBarButton15Click(Sender: TObject);
  207.     procedure dxBarButton16Click(Sender: TObject);
  208.     procedure dxBarButton17Click(Sender: TObject);
  209.     procedure dxBarButton18Click(Sender: TObject);
  210.     procedure dxBarButton19Click(Sender: TObject);
  211.     procedure dxBarButton24Click(Sender: TObject);
  212.     procedure dxBarButton25Click(Sender: TObject);
  213.     procedure dxBarButton26Click(Sender: TObject);
  214.     procedure dxBarButton32Click(Sender: TObject);
  215.     procedure FormKeyUp(Sender: TObject; var Key: Word;
  216.       Shift: TShiftState);
  217.     procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
  218.       Y: Integer);
  219.     procedure dxBarButton44Click(Sender: TObject);
  220.     procedure dxBarButton7Click(Sender: TObject);
  221.     procedure dxBarButton5Click(Sender: TObject);
  222.     procedure ApplicationEvents1Exception(Sender: TObject; E: Exception);
  223.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  224.     procedure ListView1CustomDrawItem(Sender: TCustomListView;
  225.       Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
  226.     procedure N10Click(Sender: TObject);
  227.     procedure N11Click(Sender: TObject);
  228.     procedure N3Click(Sender: TObject);
  229.     procedure N4Click(Sender: TObject);
  230.     procedure N5Click(Sender: TObject);
  231.     procedure N6Click(Sender: TObject);
  232.     procedure LMDTrackBar1MouseUp(Sender: TObject; Button: TMouseButton;
  233.       Shift: TShiftState; X, Y: Integer);
  234.     procedure ListView1DblClick(Sender: TObject);
  235.     procedure dxBarButton53Click(Sender: TObject);
  236.     procedure SpeedButton13Click(Sender: TObject);
  237.     procedure ListView1DragOver(Sender, Source: TObject; X, Y: Integer;
  238.       State: TDragState; var Accept: Boolean);
  239.     procedure ListView1DragDrop(Sender, Source: TObject; X, Y: Integer);
  240.     procedure dxBarButton22Click(Sender: TObject);
  241.     procedure dxBarButton21Click(Sender: TObject);
  242.     procedure dxBarButton13Click(Sender: TObject);
  243.     procedure dxBarButton30Click(Sender: TObject);
  244.     procedure dxBarButton31Click(Sender: TObject);
  245.     procedure dxBarButton27Click(Sender: TObject);
  246.     procedure dxBarButton46Click(Sender: TObject);
  247.     procedure dxBarButton29Click(Sender: TObject);
  248.     procedure dxBarButton28Click(Sender: TObject);
  249.     procedure dxBarButton33Click(Sender: TObject);
  250.     procedure ApplicationEvents1Activate(Sender: TObject);
  251.     procedure ApplicationEvents1Deactivate(Sender: TObject);
  252.     procedure dxBarButton11Click(Sender: TObject);
  253.     procedure dxBarButton47Click(Sender: TObject);
  254.     procedure Panel1Paint(Sender: TObject);
  255.     procedure SpeedButton12Click(Sender: TObject);
  256.     procedure CoolTrayIcon1Click(Sender: TObject);
  257.     procedure N12Click(Sender: TObject);
  258.     procedure N8Click(Sender: TObject);
  259.     procedure dxBarButton55Click(Sender: TObject);
  260.     procedure dxBarButton56Click(Sender: TObject);
  261.     procedure dxBarButton57Click(Sender: TObject);
  262.     procedure DropURLTarget1Drop(Sender: TObject; ShiftState: TShiftState;
  263.       Point: TPoint; var Effect: Integer);
  264.     procedure DropFileTarget1Drop(Sender: TObject; ShiftState: TShiftState;
  265.       Point: TPoint; var Effect: Integer);
  266.     procedure FormResize(Sender: TObject);
  267.     procedure SpeedButton16Click(Sender: TObject);
  268.     procedure dxBarButton58Click(Sender: TObject);
  269.     procedure dxBarButton60Click(Sender: TObject);
  270.     procedure LMDTrackBar1MouseWheel(Sender: TObject; Shift: TShiftState;
  271.       WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
  272.     procedure FormDeactivate(Sender: TObject);
  273.     procedure dxBarButton62Click(Sender: TObject);
  274.     procedure PopupMenu3Popup(Sender: TObject);
  275.     procedure Panel1DblClick(Sender: TObject);
  276.     procedure Timer2Timer(Sender: TObject);
  277.     procedure dxBarButton63Click(Sender: TObject);
  278.     procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  279.       Shift: TShiftState; X, Y: Integer);
  280.     procedure Panel1MouseUp(Sender: TObject; Button: TMouseButton;
  281.       Shift: TShiftState; X, Y: Integer);
  282.     procedure dxBarButton64Click(Sender: TObject);
  283.     procedure dxBarButton65Click(Sender: TObject);
  284.   private
  285.     PlayState:TPlayState;
  286.     IsNoSet:Boolean;
  287.     Rate:DOUBLE;
  288.     OldRec:TRect;
  289.     PubLeft:Single;
  290.     CurrentItem:TListItem;
  291.     PlayEndFileName:String;
  292.     MaxSeconds,MaxMinutes,MaxHours:Integer;
  293.     AutoPause:Boolean;
  294.     PlayListManager:TPlayListManager;
  295.     bNextSuccess:Boolean;
  296.     bContinuePlay:Boolean;
  297.     OldPosRect:TRect;
  298.     OldX:Integer;
  299.     OldPt:TPoint;
  300.     RoundPlay:Boolean;
  301.     MouseTimeout:DWORD;
  302.     PreviewClick:Boolean;
  303.     PreviewFileName:Array[0..3] of String;
  304.     PausePreview:Boolean;
  305.     procedure InitPlayMenu(Items: TdxBarSubItem; MenuItem:TMenuItem);
  306.     procedure FilterOptionClick(Sender:TObject);
  307.     procedure StopPlay(IsSave:Boolean);
  308.     procedure MenuItemClick(Sender:TObject);
  309.     procedure OpenDialog(FileType:TFileType; PlayType:TPlayType);
  310.     procedure OnReadyEnd(Sender:TObject; PlayInfo:PPlayFileInfo; Item:TListItem);
  311.     function OpenFile(Item:TListItem):Boolean;
  312.     procedure WMFULLSCREEN(var Msg:TMessage);Message WM_FULLSCREEN;
  313.     procedure UpdateFullScreen(b:Boolean);
  314.     procedure CheckOne;
  315.     procedure UpdateButtonState;
  316.     procedure Init;
  317.     procedure DoRatio;
  318.     function GetLayerNo(X, Y: Integer): Integer;
  319.     { Private declarations }
  320.   protected
  321.     bLockUpateWindow:Boolean;
  322.     procedure WndProc(var Msg:TMessage);override;
  323.   public
  324.     class procedure WriteIni(Section, Key, Value: String);
  325.     class function ReadIni(Section,Key,Default:String):String;
  326.     class procedure WriteReg(Key:String; Value:Variant);
  327.     class function ReadReg(Key:String; DefaultValue:Variant):Variant;
  328.     { Public declarations }
  329.   end;
  330. var
  331.   MainForm: TMainForm;
  332. implementation
  333. uses WHPlaySDK, IniFiles, Controller, Hook, Config, MD5Unit, Password,
  334.   About, DoUnit, AudioConfig, ConfigExt;
  335. {$R *.dfm}
  336. procedure TMainForm.FormCreate(Sender: TObject);
  337. Var
  338.     i:Integer;
  339.     menu:TMenuItem;
  340. begin
  341.     WriteReg('ProcessHandle',GetCurrentProcess);
  342.     WriteReg('MsgHandle',Handle);
  343.     //DropURLTarget1.Register(Listview1);
  344.     //DropURLTarget2.Register(Panel1);
  345.     DropFileTarget1.Register(Listview1);
  346.     DropFileTarget2.Register(Panel1);
  347.     PlayListManager:=TPlayListManager.Create(ListView1,Handle);
  348.     SetWindowLong(Panel1.Handle,GWL_STYLE,GetWindowLong(Panel1.Handle, GWL_STYLE)
  349.         or WS_CHILD);
  350.     SetWindowLong(Panel2.Handle,GWL_STYLE,GetWindowLong(Panel2.Handle, GWL_STYLE)
  351.         or WS_CHILD);
  352.     //SetWindowLong(Panel2.Handle,GWL_EXSTYLE,GetWindowLong(Panel2.Handle, GWL_EXSTYLE) or WS_EX_APPWINDOW);
  353.     dllRegisterVideoHandle(Panel1.Handle);
  354.     dllRegisterMsgHandle(Handle);
  355.     Init;
  356.     For i:=0 to ImageList1.Count-1 do
  357.     begin
  358.         Menu:=TMenuItem.Create(N16);
  359.         Menu.Caption:='图标'+IntToStr(i);
  360.         Menu.ImageIndex:=i;
  361.         Menu.OnClick:=MenuItemClick;
  362.         N16.Add(Menu);
  363.     end;
  364.     PlayListManager.OnReadyEnd:=OnReadyEnd;
  365.     if (ParamStr(1)<>'') then
  366.     begin
  367.         PostMessage(Handle,WM_STARTSHOW,0,0);
  368.     end;
  369.     //SetHook;
  370. end;
  371. procedure OnNotifyEvent(eventcode:LongInt; Param:Pointer; var IsContinue:Boolean);stdcall;
  372. Var
  373.     Form:TMainForm;
  374. begin
  375.     Form:=TMainForm(Param);
  376.     With Form do
  377.     begin
  378.         Case eventCode of
  379.             EC_COMPLETE:
  380.             begin
  381.                 Panel8.Caption:='播放              00:00:00/00:00:00';
  382.                 PostMessage(Form.Handle,WM_PLAYNEXT,1,0);
  383.             end;
  384.             EC_USERABORT:
  385.             begin
  386.             end;
  387.             EC_ERRORABORT:
  388.             begin
  389.             end;
  390.         end;
  391.     end;
  392. end;
  393. procedure SwitchToThisWindow(hwnd:THandle; bRestore:Boolean);stdcall; External 'User32.dll';
  394. function ForceForegroundWindow(hwnd: THandle): boolean;
  395. const
  396.     SPI_GETFOREGROUNDLOCKTIMEOUT = $2000;
  397.     SPI_SETFOREGROUNDLOCKTIMEOUT = $2001;
  398. var
  399.     ForegroundThreadID: DWORD;
  400.     ThisThreadID      : DWORD;
  401.     timeout           : DWORD;
  402. begin
  403.     if IsIconic(hwnd) then ShowWindow(hwnd, SW_RESTORE);
  404.     if GetForegroundWindow = hwnd then
  405.         Result := true
  406.     else
  407.     begin
  408.         SwitchToThisWindow(Hwnd,true);
  409.         if ((Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion > 4)) or
  410.           ((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
  411.           ((Win32MajorVersion > 4) or ((Win32MajorVersion = 4) and
  412.           (Win32MinorVersion > 0)))) then
  413.         begin
  414.             Result := false;
  415.             ForegroundThreadID := GetWindowThreadProcessID(GetForegroundWindow,nil);
  416.             ThisThreadID := GetWindowThreadPRocessId(hwnd,nil);
  417.             if AttachThreadInput(ThisThreadID, ForegroundThreadID, true) then
  418.             begin
  419.                 BringWindowToTop(hwnd); // IE 5.5 related hack
  420.                 SetForegroundWindow(hwnd);
  421.                 AttachThreadInput(ThisThreadID, ForegroundThreadID, false);
  422.                 Result := (GetForegroundWindow = hwnd);
  423.             end;
  424.             if not Result then
  425.             begin
  426.                 SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, @timeout, 0);
  427.                 SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(0), SPIF_SENDCHANGE);
  428.                 BringWindowToTop(hwnd); // IE 5.5 related hack
  429.                 SetForegroundWindow(hWnd);
  430.                 SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(timeout), SPIF_SENDCHANGE);
  431.             end;
  432.         end
  433.         else begin
  434.             BringWindowToTop(hwnd); // IE 5.5 related hack
  435.             SetForegroundWindow(hwnd);
  436.         end;
  437.         Result := (GetForegroundWindow = hwnd);
  438.     end;
  439. end;
  440. procedure TMainForm.WndProc(var Msg: TMessage);
  441. Var
  442.     Item:TListItem;
  443.     Info:PPlayFileInfo;
  444.     vHours,vMinutes,vSeconds:String;
  445.     eventCode:LongInt;
  446.     v:Variant;
  447. begin
  448.     inherited;
  449.     if Application.Terminated then
  450.         Exit;
  451. if (Msg.Msg in [WM_PAINT,WM_SIZE,WM_DISPLAYCHANGE,WM_MOVE]) and (Not (PlayState in [psStop,psNone,psLoad])) then
  452.         dllDefaultProcessMsg(Handle,Msg.Msg,Msg.WParam,Msg.LParam);
  453.     Case Msg.Msg of
  454.         WM_KILLAPP:
  455.         begin
  456.             Close;
  457.         end;
  458.         WM_SHOWAPP:
  459.         begin
  460.             CoolTrayIcon1.ShowMainForm;
  461.             ForceForegroundWindow(Application.Handle);
  462.             ForceForegroundWindow(Handle);
  463.         end;
  464.         WM_HIDEAPP:
  465.         begin
  466.             ApplicationEvents1Deactivate(nil);
  467.         end;
  468.         WM_OPENREMOTEFILE:
  469.         begin
  470.           Msg.Result:=0;
  471.           v:=ReadReg('TmpFileName',null);
  472.           if Not VarIsNull(v) then
  473.           begin
  474.             CoolTrayIcon1.ShowMainForm;
  475.             ForceForegroundWindow(Application.Handle);
  476.             ForceForegroundWindow(Handle);
  477.             PlayListManager.Add(v,ftUnknown,ptPlay);
  478.             Msg.Result:=1;
  479.           end;
  480.         end;
  481.         WM_ADDITEM:
  482.         begin
  483.             Info:=Ptr(Msg.WParam);
  484.             Item:=ListView1.Items.Add;
  485.             With Item do
  486.             begin
  487.                 Caption:=Info.DisplayName;
  488.                 GetTimeString(Info.MediaInfo.PlayHours,Info.MediaInfo.PlayMinites,Info.MediaInfo.PlaySeconds,vHours,vMinutes,vSeconds);
  489.                 SubItems.Add(vHours+':'+vMinutes+':'+vSeconds);
  490.                 SubItems.Add(FloatToStr(Info.FileSize)+'M');
  491.                 Data:=Info;
  492.             end;
  493.             if Info.PlayType=ptPlay then
  494.                 OnReadyEnd(Owner,Info,Item);
  495.         end;
  496.         WM_STARTSHOW:
  497.         begin
  498.             if FileExists(ParamStr(1)) then
  499.             begin
  500.                 if UpperCase(ExtractFileExt(ParamStr(1)))='.WPL' then
  501.                     Self.PlayListManager.Open(ParamStr(1),false,true)
  502.                 else
  503.                     PlayListManager.Add(ParamStr(1),ftUnknown,ptPlay);
  504.             end;
  505.         end;
  506.         WM_PLAYNEXT:
  507.         begin
  508.             CurrentItem:=ListView1.GetNextItem(CurrentItem,sdAll, []);
  509.             if Not Assigned(CurrentItem) then
  510.             begin
  511.                 StopPlay(false);
  512.                 Exit;
  513.             end;
  514.                 
  515.             SpeedButton3.Click;
  516.             if CurrentItem<>nil then
  517.             begin
  518.                 if Not OpenFile(CurrentItem) then
  519.                 begin
  520.                     PostMessage(Handle,WM_PLAYNEXT,1,0);
  521.                 end
  522.                 else
  523.                     bNextSuccess:=true;
  524.             end
  525.             else if Msg.WParam=1 then
  526.             begin
  527.                 if dxBarButton53.Down then
  528.                 begin
  529.                     if ListView1.Items.Count=0 then
  530.                         Exit;
  531.                     CurrentItem:=ListView1.Items[0];
  532.                     OpenFile(CurrentItem);
  533.                 end
  534.                 else
  535.                 begin
  536.                     if dxBarButton9.Down then
  537.                     begin
  538.                         WinExit(EWX_FORCE or EWX_SHUTDOWN);
  539.                     end
  540.                     else if dxBarButton10.Down then
  541.                     begin
  542.                         Application.Terminate;
  543.                     end
  544.                     else if dxBarButton11.Down then
  545.                     begin
  546.                         ShellExecute(0,'open',PChar(PlayEndFileName),'','',SW_SHOW);
  547.                         Application.Terminate;
  548.                     end;
  549.                 end;
  550.             end;
  551.         end;
  552.         WM_PLAYPRIOR:
  553.         begin
  554.             if (CurrentItem<>nil) and (CurrentItem.Index>0) then
  555.                 CurrentItem:=ListView1.Items[CurrentItem.Index-1]
  556.             else
  557.             begin
  558.                 StopPlay(false);
  559.                 Exit;
  560.             end;
  561.             SpeedButton3.Click;
  562.             if CurrentItem<>nil then
  563.             begin
  564.                 if Not OpenFile(CurrentItem) then
  565.                 begin
  566.                     PostMessage(Handle,WM_PLAYPRIOR,0,0);
  567.                 end
  568.                 else
  569.                     bNextSuccess:=true;
  570.             end;
  571.         end;
  572.         
  573.     end;
  574.     if Msg.Msg<>WM_GRAPHNOTIFY then
  575.         Exit;
  576.     dllDefaultOnGraphNotify(Msg.WParam,Msg.LParam,Self,OnNotifyEvent);
  577. end;
  578. procedure TMainForm.Timer1Timer(Sender: TObject);
  579. Var
  580.     Hours,Minutes,Seconds:Integer;
  581.     vMaxHours,vMaxMinutes,vMaxSeconds,vHours,vMinutes,vSeconds:String;
  582. begin
  583.     if IsNoSet then
  584.         Exit;
  585.     if Application.Terminated then
  586.         Exit;
  587.         
  588.     if PlayState=psPreview then
  589.     begin
  590.         LMDTrackBar2.Position:=dllPreviewGetPosition;
  591.         dllPreviewGetSM(Seconds,Minutes);
  592.     end
  593.     else
  594.     begin
  595.         LMDTrackBar2.Position:=dllGetPostion;
  596.         dllReadMediaPosition(Seconds,Minutes);
  597.     end;
  598.     Hours:=Minutes div 60;
  599.     Minutes:=Minutes mod 60;
  600.     GetTimeString(MaxHours,MaxMinutes,MaxSeconds,vMaxHours,vMaxMinutes,vMaxSeconds);
  601.     GetTimeString(Hours,Minutes,Seconds,vHours,vMinutes,vSeconds);
  602.     Panel8.Caption:='播放    '+vHours+':'+vMinutes+':'+vSeconds+'/'+
  603.         vMaxHours+':'+vMaxMinutes+':'+vMaxSeconds;
  604. end;
  605. procedure TMainForm.FormDestroy(Sender: TObject);
  606. begin
  607.     //endhook;
  608.     PlayListManager.Free;
  609.     dllQuit;
  610. end;
  611. procedure TMainForm.SpeedButton4Click(Sender: TObject);
  612. begin
  613.     if Not (PlayState in [psPlay,psOne,psPause]) then
  614.     begin
  615.         SpeedButton4.Down:=false;
  616.         Exit;
  617.     end;
  618.     if SpeedButton4.Down then
  619.         dxBarButton55.Click
  620.     else
  621.         With OldPosRect do
  622.             SetBounds(Left,Top,Right,Bottom);
  623. end;
  624. procedure TMainForm.SpeedButton1Click(Sender: TObject);
  625. begin
  626.     if PlayState in [psNone,psStop] then
  627.     begin
  628.         if ListView1.Selected<>nil then
  629.             OpenFile(ListView1.Selected)
  630.         else if ListView1.Items.Count>0 then
  631.             OpenFile(ListView1.Items[0])
  632.         else
  633.             dxBarButton5.Click;
  634.     end
  635.     else
  636.     begin
  637.         dllPlay;
  638.             
  639.         dllVolume(0-(3000-LMDTrackBar1.Position));
  640.         Timer1.Enabled:=true;
  641.         dxBarButton56.OnClick(dxBarButton56);
  642.         PlayState:=psPlay;
  643.         UpdateButtonState;
  644.     end;
  645. end;
  646. procedure TMainForm.SpeedButton2Click(Sender: TObject);
  647. begin
  648.     DllPause;
  649.     PlayState:=psPause;
  650.     Timer1.Enabled:=false;
  651.     UpdateButtonState;
  652.     Panel1.Invalidate;
  653. end;
  654. procedure TMainForm.SpeedButton3Click(Sender: TObject);
  655. begin
  656.     StopPlay(false);
  657. end;
  658. procedure TMainForm.dxBarButton4Click(Sender: TObject);
  659. begin
  660.     dllShowVRPropertyPage
  661. end;
  662. procedure TMainForm.SpeedButton5Click(Sender: TObject);
  663. begin
  664.     if SpeedButton5.Visible then
  665.     begin
  666.         SpeedButton11.Visible:=true;
  667.         SpeedButton5.Visible:=false;
  668.         dllMuteAudio;
  669.     end
  670.     else
  671.     begin
  672.         SpeedButton5.Visible:=true;
  673.         SpeedButton11.Visible:=false;
  674.         dllResumeAudio;
  675.     end;
  676. end;
  677. procedure TMainForm.SpeedButton7Click(Sender: TObject);
  678. begin
  679.     CheckOne;
  680.     dllStepFrames(1);
  681.     UpdateButtonState;
  682. end;
  683. procedure TMainForm.SpeedButton8Click(Sender: TObject);
  684. begin
  685.     Rate:=Rate-(rate/2);
  686.     dllModifyRate(Rate);
  687.     if Rate>1.0 then
  688.         Panel6.Caption:='播放速度:'+FloatToStr(RoundTo(Rate,-2))+'(快速)'
  689.     else
  690.         Panel6.Caption:='播放速度:'+FloatToStr(RoundTo(Rate,-2))+'(慢速)';
  691. end;
  692. procedure TMainForm.SpeedButton9Click(Sender: TObject);
  693. begin
  694.     Rate:=Rate+0.5;
  695.     dllModifyRate(Rate);
  696.     if Rate>1.0 then
  697.         Panel6.Caption:='播放速度:'+FloatToStr(RoundTo(Rate,-2))+'(快速)'
  698.     else
  699.         Panel6.Caption:='播放速度:'+FloatToStr(RoundTo(Rate,-2))+'(慢速)';
  700. end;
  701. procedure TMainForm.SpeedButton10Click(Sender: TObject);
  702. begin
  703.     Rate:=1;
  704.     dllModifyRate(Rate);
  705.     Panel6.Caption:='播放速度:1.0(正常)';
  706. end;
  707. procedure TMainForm.LMDTrackBar2MouseDown(Sender: TObject;
  708.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  709. begin
  710.     IsNoSet:=true;
  711.     OldX:=X;
  712. end;
  713. procedure TMainForm.LMDTrackBar2MouseUp(Sender: TObject;
  714.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  715. begin
  716.     if IsNoSet then
  717.     begin
  718.         LMDTrackBar2.Position:=Round(LMDTrackBar2.MaxValue*(X/LMDTrackBar2.ClientWidth));
  719.     end;
  720.     IsNoSet:=false;
  721.     LMDTrackBar2.Invalidate;
  722. end;
  723. procedure TMainForm.LMDTrackBar2Track(Sender: TObject;
  724.   ScrollCode: TScrollCode; var ScrollPos: Integer);
  725. begin
  726.     if ScrollCode=scEndScroll then
  727.     begin
  728.         if LMDTrackBar2.Position=LMDTrackBar2.MaxValue then
  729.             LMDTrackBar2.Position:=LMDTrackBar2.Position-1;
  730.         if PlayState=psPreview then
  731.             dllPreviewSetPosition(LMDTrackBar2.Position)
  732.         else
  733.             dllSetPosition(LMDTrackBar2.Position);
  734.     end;
  735. end;
  736. procedure TMainForm.LMDTrackBar1Track(Sender: TObject;
  737.   ScrollCode: TScrollCode; var ScrollPos: Integer);
  738. begin
  739.     dllVolume(0-(3000-LMDTrackBar1.Position));
  740.     if ScrollCode=scEndScroll then
  741.     begin
  742.         WriteIni('Config' ,'Volume',IntToStr(LMDTrackBar1.Position));
  743.     end;
  744. end;
  745. procedure TMainForm.CheckOne;
  746. begin
  747.     if Not (PlayState in [psOne]) then
  748.     begin
  749.         dllSwitchStepFrame;
  750.         PlayState:=psOne;
  751.     end;
  752. end;
  753. procedure TMainForm.Panel1Resize(Sender: TObject);
  754. begin
  755.     if bLockUpateWindow then
  756.         Exit;
  757.     if (PlayState=psPreview) or (PausePreview) then
  758.         dllPreviewResize();
  759.     dllResetDisplay(Panel1.Handle);
  760. end;
  761. procedure TMainForm.Init;
  762. Var
  763.     g:TGUID;
  764. begin
  765.     InitPlayMenu(dxBarSubItem3,PopupMenu3.Items);
  766.     LMDTrackBar1.Position:=StrToInt(ReadIni('Config','Volume','0'));
  767.     g:=StringToGUID(ReadIni('Config','GUID','{c553f2c0-1529-11d0-b4d1-00805f6cbbea}'));
  768.     dllRegisterLockFilterGUID(g);
  769.     UpdateButtonState;
  770.     dxBarButton53.Down:=StrToBool(ReadIni('Config','RoundPlay','0'));
  771.     dxBarButton22.Down:=StrToBool(ReadIni('Config','Ratio','0'));
  772.     dxBarButton56.Down:=StrToBool(ReadIni('Config','AutoSize','0'));
  773.     ImageList1.GetIcon(StrToInt(ReadIni('Config','IconIndex','0')),CoolTrayIcon1.Icon);
  774.     OldPosRect.Left:=StrToInt(ReadIni('Config','PosX',IntToStr((Screen.Width-Width) div 2)));
  775.     OldPosRect.Top:=StrToInt(ReadIni('Config','PosY',IntToStr((Screen.Height-Height) div 2)));
  776.     OldPosRect.Right:=StrToInt(ReadIni('Config','PosWidth',IntToStr(Width)));
  777.     OldPosRect.Bottom:=StrToInt(ReadIni('Config','PosHeight',IntToStr(Height)));
  778.     With OldPosRect do
  779.         SetBounds(Left,Top,Right,Bottom);
  780.     CoolTrayIcon1.Refresh;
  781.     Rate:=1;
  782.     dxBarButton47.Down:=StrToBool(ReadIni('Playing','PlayListVisible','0'));
  783.     dxBarButton47Click(dxBarButton47);
  784. end;
  785. class function TMainForm.ReadIni(Section, Key, Default: String):String;
  786. Var
  787.     IniFile:TIniFile;
  788. begin
  789.     IniFile:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'Config.Dat');
  790.     Try
  791.         Result:=IniFile.ReadString(Section,Key,Default);
  792.     Finally
  793.         IniFile.Free;
  794.     end;
  795. end;
  796. class procedure TMainForm.WriteIni(Section, Key, Value: String);
  797. Var
  798.     IniFile:TIniFile;
  799. begin
  800.     IniFile:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'Config.Dat');
  801.     Try
  802.         IniFile.WriteString(Section,Key,Value);
  803.     Finally
  804.         IniFile.Free;
  805.     end;
  806. end;
  807. procedure TMainForm.UpdateButtonState;
  808. begin
  809.     SpeedButton4.Enabled:=Not dxBarButton56.Down;
  810.     Case PlayState of
  811.         psNone:
  812.         begin
  813.             SpeedButton1.Enabled:=true;
  814.             SpeedButton2.Enabled:=false;
  815.             SpeedButton3.Enabled:=false;
  816.             SpeedButton6.Enabled:=false;
  817.             SpeedButton14.Enabled:=false;
  818.             SpeedButton15.Enabled:=false;
  819.             SpeedButton7.Enabled:=false;
  820.             SpeedButton8.Enabled:=false;
  821.             SpeedButton9.Enabled:=false;
  822.             SpeedButton10.Enabled:=false;
  823.             Panel5.Caption:=' 状态:没有媒体';
  824.             Panel1.EraseBackground:=true;
  825.         end;
  826.         psStop:
  827.         begin
  828.             SpeedButton1.Enabled:=true;
  829.             SpeedButton2.Enabled:=false;
  830.             SpeedButton3.Enabled:=false;
  831.             SpeedButton6.Enabled:=false;
  832.             SpeedButton14.Enabled:=false;
  833.             SpeedButton15.Enabled:=false;
  834.             SpeedButton7.Enabled:=false;
  835.             SpeedButton8.Enabled:=false;
  836.             SpeedButton9.Enabled:=false;
  837.             SpeedButton10.Enabled:=false;
  838.             Panel5.Caption:=' 状态:停止';
  839.             Panel1.EraseBackground:=true;
  840.             Panel1.Invalidate;
  841.         end;
  842.         psPlay:
  843.         begin
  844.             SpeedButton1.Enabled:=false;
  845.             SpeedButton2.Enabled:=true;
  846.             SpeedButton3.Enabled:=true;
  847.             SpeedButton6.Enabled:=true;
  848.             SpeedButton14.Enabled:=true;
  849.             SpeedButton15.Enabled:=true;
  850.             SpeedButton7.Enabled:=true;
  851.             SpeedButton8.Enabled:=true;
  852.             SpeedButton9.Enabled:=true;
  853.             SpeedButton10.Enabled:=true;
  854.             Panel5.Caption:=' 状态:播放中';
  855.             Panel1.EraseBackground:=false;
  856.         end;
  857.         psPause:
  858.         begin
  859.             SpeedButton1.Enabled:=true;
  860.             SpeedButton2.Enabled:=false;
  861.             SpeedButton3.Enabled:=true;
  862.             SpeedButton6.Enabled:=true;
  863.             SpeedButton14.Enabled:=true;
  864.             SpeedButton15.Enabled:=true;
  865.             SpeedButton7.Enabled:=true;
  866.             SpeedButton8.Enabled:=false;
  867.             SpeedButton9.Enabled:=false;
  868.             SpeedButton10.Enabled:=false;
  869.             Panel5.Caption:=' 状态:暂停';
  870.             Panel1.EraseBackground:=true;
  871.         end;
  872.         psOne:
  873.         begin
  874.             SpeedButton1.Enabled:=true;
  875.             SpeedButton2.Enabled:=false;
  876.             SpeedButton3.Enabled:=true;
  877.             SpeedButton6.Enabled:=false;
  878.             SpeedButton14.Enabled:=false;
  879.             SpeedButton15.Enabled:=true;
  880.             SpeedButton7.Enabled:=true;
  881.             SpeedButton8.Enabled:=false;
  882.             SpeedButton9.Enabled:=false;
  883.             SpeedButton10.Enabled:=false;
  884.             Panel5.Caption:=' 状态:单步播放';
  885.             Panel1.EraseBackground:=true;
  886.         end;
  887.         psLoad:
  888.         begin
  889.             SpeedButton1.Enabled:=true;
  890.             SpeedButton2.Enabled:=false;
  891.             SpeedButton3.Enabled:=true;
  892.             SpeedButton6.Enabled:=false;
  893.             SpeedButton14.Enabled:=false;
  894.             SpeedButton15.Enabled:=false;
  895.             SpeedButton7.Enabled:=false;
  896.             SpeedButton8.Enabled:=false;
  897.             SpeedButton9.Enabled:=false;
  898.             SpeedButton10.Enabled:=false;
  899.             Panel5.Caption:=' 状态:文件已打开';
  900.             Panel1.EraseBackground:=true;
  901.         end;
  902.     end;
  903. end;
  904. procedure TMainForm.SpeedButton6Click(Sender: TObject);
  905. begin
  906.     if Not (PlayState in [psPlay,psPause,psOne]) then
  907.         Exit;
  908.     UpdateFullScreen(false);
  909. //    dllRestoreFromFullScreen;
  910.     SpeedButton6.Visible:=false;
  911.     SpeedButton14.Visible:=true;
  912. end;
  913. procedure TMainForm.SpeedButton14Click(Sender: TObject);
  914. begin
  915. //    dllFullscreen;
  916.     if Not (PlayState in [psPlay,psPause,psOne]) then
  917.         Exit;
  918.     UpdateFullScreen(true);
  919.     SpeedButton6.Visible:=true;
  920.     SpeedButton14.Visible:=false;
  921. end;
  922. procedure TMainForm.SpeedButton15Click(Sender: TObject);
  923. begin
  924.     if SavePictureDialog1.Execute then
  925.     begin
  926.         dllCaptureToBmp(PChar(SavePictureDialog1.FileName));
  927.     end;
  928. end;
  929. procedure TMainForm.dxBarButton6Click(Sender: TObject);
  930. begin
  931.     OpenDialog(ftLock,ptPlay);
  932. end;
  933. procedure TMainForm.dxBarButton14Click(Sender: TObject);
  934. begin
  935.     OpenDialog(ftUnLock,ptPlay);
  936. end;
  937. procedure TMainForm.dxBarButton15Click(Sender: TObject);
  938. begin
  939.     SpeedButton1.Click;
  940. end;
  941. procedure TMainForm.dxBarButton16Click(Sender: TObject);
  942. begin
  943.     SpeedButton2.Click;
  944. end;
  945. procedure TMainForm.dxBarButton17Click(Sender: TObject);
  946. begin
  947.     SpeedButton3.Click;
  948. end;
  949. procedure TMainForm.dxBarButton18Click(Sender: TObject);
  950. begin
  951.     SpeedButton12.Click;
  952. end;
  953. procedure TMainForm.dxBarButton19Click(Sender: TObject);
  954. begin
  955.     SpeedButton13.Click;
  956. end;
  957. procedure TMainForm.dxBarButton24Click(Sender: TObject);
  958. begin
  959.     SpeedButton8.Click;
  960. end;
  961. procedure TMainForm.dxBarButton25Click(Sender: TObject);
  962. begin
  963.     SpeedButton9.Click;
  964. end;
  965. procedure TMainForm.dxBarButton26Click(Sender: TObject);
  966. begin
  967.     SpeedButton10.Click;
  968. end;
  969. procedure TMainForm.dxBarButton32Click(Sender: TObject);
  970. begin
  971.     SpeedButton7.Click;
  972. end;
  973. procedure TMainForm.FormKeyUp(Sender: TObject; var Key: Word;
  974.   Shift: TShiftState);
  975. begin
  976.     if (Key=VK_ESCAPE) then
  977.     begin
  978.         if SpeedButton6.Visible then
  979.             SpeedButton6.Click
  980.         else
  981.             PostMessage(Handle,WM_HIDEAPP,0,0);
  982.     end
  983.     else if (ssAlt in Shift) and (Key=VK_RETURN) then
  984.     begin
  985.         if Not (PlayState in [psPlay,psPause,psOne,psPreview]) then
  986.             Exit;
  987.         if SpeedButton6.Visible then
  988.             SpeedButton6.Click
  989.         else
  990.             SpeedButton14.Click;
  991.     end
  992. end;
  993. procedure TMainForm.UpdateFullScreen(b: Boolean);
  994. Var
  995.     a:Integer;
  996. begin
  997.     bLockUpateWindow:=true;
  998.     SpeedButton2.Click;
  999.     if b then
  1000.     begin
  1001.         //LockWindowUpdate(Handle);
  1002.         SpeedButton4.Visible:=false;
  1003.         dxBarManager1.Bars[0].Visible:=false;
  1004.         Panel1.Align:=alNone;
  1005.         Panel2.Align:=alNone;
  1006.         Panel2.Visible:=false;
  1007.         ListView1.Visible:=false;
  1008.         OldRec:=Rect(Self.Left,Self.Top,Self.Width,Self.Height);
  1009.         a:=GetWindowLong(Handle, GWL_STYLE);
  1010.         a:=a and not WS_CAPTION;
  1011.         SetWindowLong(Handle,GWL_STYLE,a);
  1012.         SetWindowLong(Handle,GWL_EXSTYLE,GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_TOPMOST);
  1013.         SetBounds(-4,-4,Screen.Width+8,Screen.Height+8);
  1014.         Self.Panel1.SetBounds(0,0,Screen.Width,Screen.Height);
  1015.         Self.Panel2.SetBounds(0,ClientHeight-Panel2.Height,ClientWidth,Panel2.Height);
  1016.         ShowCursor(false);
  1017. //        dllFullscreen;
  1018.         //LockWindowUpdate(0);
  1019.     end
  1020.     else
  1021.     begin
  1022.         SpeedButton4.Visible:=true;
  1023.         SetWindowLong(Handle,GWL_EXSTYLE,GetWindowLong(Handle, GWL_EXSTYLE) and not WS_EX_TOPMOST);
  1024.         SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle, GWL_STYLE) or WS_CAPTION or WS_BORDER);
  1025.         Self.SetBounds(OldRec.Left,OldRec.Top,OldRec.Right,OldRec.Bottom);
  1026.         Panel1.SetBounds(Self.ClientRect.Left,Self.ClientRect.Top,
  1027.             Self.ClientRect.Right-Self.ClientRect.Left,Self.ClientRect.Bottom-Self.ClientRect.Top);
  1028.         Panel1.Align:=alClient;
  1029.         Panel2.Align:=alBottom;
  1030.         dxBarManager1.Bars[0].Visible:=true;
  1031.         Self.Panel2.Visible:=true;
  1032.         ListView1.Visible:=dxBarButton47.Down;
  1033.         ShowCursor(true);
  1034. //        dllRestoreFromFullScreen;
  1035.     end;
  1036.     bLockUpateWindow:=false;
  1037.     PostMessage(Handle,WM_FULLSCREEN,0,0);
  1038. end;
  1039. procedure TMainForm.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
  1040.   Y: Integer);
  1041. begin
  1042.     if SpeedButton6.Visible then
  1043.     begin
  1044.         if (X<>OldPt.X) or (Y<>OldPt.Y) then
  1045.         begin
  1046.             OldPt:=Point(X,Y);
  1047.             MouseTimeout:=GetTickCount;
  1048.             if Not Timer2.Enabled then
  1049.             begin
  1050.                 ShowCursor(true);
  1051.                 Timer2.Enabled:=true;
  1052.             end;
  1053.         end;
  1054.         if Y>=Self.Height-Panel2.Height then
  1055.         begin
  1056.             if Panel2.Visible then
  1057.                 Exit;
  1058.             Panel2.Visible:=true;
  1059.         end
  1060.         else
  1061.         begin
  1062.             if Not Panel2.Visible then
  1063.                 Exit;
  1064.             Panel2.Visible:=false;
  1065.         end;
  1066.     end;
  1067. end;
  1068. procedure TMainForm.WMFULLSCREEN(var Msg: TMessage);
  1069. begin
  1070.     Panel1.OnResize(Panel1);
  1071.     SpeedButton1.Click;
  1072. end;
  1073. procedure TMainForm.dxBarButton44Click(Sender: TObject);
  1074. begin
  1075.     if OpenDialog1.Execute then
  1076.     begin
  1077.         dllAddUnLockGraph(PChar(OpenDialog1.FileName));
  1078.     end;
  1079. end;
  1080. procedure TMainForm.dxBarButton7Click(Sender: TObject);
  1081. begin
  1082.     Form1.ShowModal;
  1083. end;
  1084. function TMainForm.OpenFile(Item:TListItem): Boolean;
  1085. Var
  1086.     Info:PPlayFileInfo;
  1087.     FileStream:TFileStream;
  1088.     Str,Key:String;
  1089.     i:Integer;
  1090.     pStr:Array[0..1024] of Char;
  1091.     Var1,Var2:Integer;
  1092.     StrList:TStringList;
  1093.     Bu:TdxBarButton;
  1094.     b:Boolean;
  1095.     ItemLink:TdxBarItemLink;
  1096. begin
  1097.     Result:=false;
  1098.     Info:=Item.Data;
  1099.     if Not Info.bExists then
  1100.         Exit;
  1101.     if Info.bLock then
  1102.     begin
  1103.         if DllOpenLockFile(PChar(Info.FileName),PChar(PForm.Password))=0 then
  1104.             Exit;
  1105.         PlayState:=psLoad;
  1106.         SpeedButton1.Click;
  1107.         UpdateButtonState;
  1108.     end
  1109.     else
  1110.     begin
  1111.         if DllOpenUnLockFile(PChar(Info.FileName))=0 then
  1112.             Exit;
  1113.         PlayState:=psLoad;
  1114.         SpeedButton1.Click;
  1115.         UpdateButtonState;
  1116.     end;
  1117.     CurrentItem:=Item;
  1118.     ListView1.Invalidate;
  1119.     DoRatio;
  1120.     DllConfig('GETFILTERNAMES',Var1,Var2);
  1121.     dxBarButton7.DestroyComponents;
  1122.     StrList:=TStringList.Create;
  1123.     Try
  1124.         b:=true;
  1125.         StrList.Text:=StrPas(Ptr(Var1));
  1126.         For i:=0 to StrList.Count-1 do
  1127.         begin
  1128.             if StrList.Strings[i]='' then
  1129.                 Continue;
  1130.             Bu:=TdxBarButton.Create(dxBarButton7);
  1131.             Bu.Caption:=StrList.Strings[i];
  1132.             Bu.OnClick:=FilterOptionClick;
  1133.             ItemLink:=dxBarSubItem12.ItemLinks.Add;
  1134.             ItemLink.Item:=Bu;
  1135.             if b then
  1136.             begin
  1137.                 b:=false;
  1138.                 ItemLink.BeginGroup:=true;
  1139.             end;
  1140.         end;
  1141.     Finally
  1142.         StrList.Free;
  1143.     end;
  1144.     Result:=true;
  1145. end;
  1146. procedure TMainForm.dxBarButton5Click(Sender: TObject);
  1147. begin
  1148.     OpenDialog(ftUnKnown,ptPlay);
  1149. end;
  1150. procedure TMainForm.ApplicationEvents1Exception(Sender: TObject;
  1151.   E: Exception);
  1152. Var
  1153.     Str:String;
  1154. begin
  1155.     Str:=E.Message;
  1156. end;
  1157. procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
  1158. begin
  1159.     StopPlay(true);
  1160. end;
  1161. procedure TMainForm.OnReadyEnd(Sender: TObject; PlayInfo: PPlayFileInfo; Item:TListItem);
  1162. Var
  1163.     vItem:TListItem;
  1164.     Info:PPlayFileInfo;
  1165. begin
  1166.     if PlayInfo.bExists then
  1167.     begin
  1168.         vItem:=Item;
  1169.         While (Not OpenFile(vItem)) and (vItem.Index<ListView1.Items.Count-1) do
  1170.         begin
  1171.             vItem:=ListView1.Items[vItem.Index+1];
  1172.         end;
  1173.         Info:=vItem.Data;
  1174.         Self.MaxHours:=Info.MediaInfo.PlayHours;
  1175.         Self.MaxMinutes:=Info.MediaInfo.PlayMinites;
  1176.         Self.MaxSeconds:=Info.MediaInfo.PlaySeconds;
  1177.         if Info.Pos>0 then
  1178.         begin
  1179.             LMDTrackBar2.Position:=Info.Pos;
  1180.             dllSetPosition(LMDTrackBar2.Position);
  1181.         end;
  1182.     end;
  1183. end;
  1184. procedure TMainForm.ListView1CustomDrawItem(Sender: TCustomListView;
  1185.   Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
  1186. Var
  1187.     Info:PPlayFileInfo;
  1188.     OldColor:TColor;
  1189. begin
  1190.     Info:=Item.Data;
  1191.     Sender.Canvas.Font.Color:=clLime;
  1192.     if Not Info.bExists then
  1193.     begin
  1194.         Sender.Canvas.Brush.Color:=clRed
  1195.     end
  1196.     else
  1197.         Sender.Canvas.Brush.Color:=clBlack;
  1198.     if Item=CurrentItem then
  1199.     begin
  1200.         Sender.Canvas.Brush.Color:=clYellow;
  1201.         Sender.Canvas.Font.Color:=clBlack;
  1202.     end;
  1203. end;
  1204. procedure TMainForm.OpenDialog(FileType:TFileType; PlayType:TPlayType);
  1205. Var
  1206.     i:Integer;
  1207. begin
  1208.     if Opendialog1.Execute then
  1209.     begin
  1210. {
  1211.         DllOpenUnLockFile(PChar(OpenDialog1.FileName));
  1212.         SpeedButton1.Click;
  1213.         Exit;
  1214. }
  1215.         For i:=0 to OpenDialog1.Files.Count-1 do
  1216.         begin
  1217.             if (i=0) and (PlayType=ptPlay) then
  1218.             begin
  1219.                 Self.PlayListManager.Add(OpenDialog1.Files.Strings[i],FileType,ptPlay);
  1220.             end
  1221.             else
  1222.                 Self.PlayListManager.Add(OpenDialog1.Files.Strings[i],FileType,ptAdd);
  1223.         end;
  1224.     end;
  1225. end;
  1226. procedure TMainForm.N10Click(Sender: TObject);
  1227. begin
  1228.     OpenDialog(ftUnLock,ptAdd);
  1229. end;
  1230. procedure TMainForm.N11Click(Sender: TObject);
  1231. Var
  1232.     CurDelete:Boolean;
  1233.     i:Integer;
  1234.     Item:TListItem;
  1235.     List:TList;
  1236. begin
  1237.     Item:=ListView1.Selected;
  1238.     if Item=nil then
  1239.         Exit;
  1240.     List:=TList.Create;
  1241.     Try
  1242.         Repeat
  1243.             List.Add(Item);
  1244.             Item:=ListView1.GetNextItem(Item, sdAll, [isSelected]);
  1245.         Until Item=nil;
  1246.         CurDelete:=false;
  1247.         For i:=0 to List.Count-1 do
  1248.         begin
  1249.             if List.Items[i]=CurrentItem then
  1250.             begin
  1251.                 CurDelete:=true;
  1252.                 if SpeedButton3.Enabled then
  1253.                     SpeedButton3.Click;
  1254.                 CurrentItem:=ListView1.GetNextItem(CurrentItem, sdAll, []);
  1255.             end;
  1256.             Self.PlayListManager.Delete(TListItem(List.Items[i]));
  1257.         end;
  1258.         if CurDelete then
  1259.         begin
  1260.             if CurrentItem<>nil then
  1261.                 OpenFile(CurrentItem);
  1262.         end;
  1263.     Finally
  1264.         List.Free;
  1265.     end;
  1266. end;
  1267. procedure TMainForm.N3Click(Sender: TObject);
  1268. begin
  1269.     if OpenDialog2.Execute then
  1270.     begin
  1271.         Self.PlayListManager.Open(OpenDialog2.FileName,false);
  1272.     end;
  1273. end;
  1274. procedure TMainForm.N4Click(Sender: TObject);
  1275. begin
  1276.     if OpenDialog2.Execute then
  1277.     begin
  1278.         Self.PlayListManager.Open(OpenDialog2.FileName,true);
  1279.     end;
  1280. end;
  1281. procedure TMainForm.N5Click(Sender: TObject);
  1282. begin
  1283.     if Self.PlayListManager.FileName<>'' then
  1284.     begin
  1285.         Self.PlayListManager.Save(Self.PlayListManager.FileName,CurrentItem);
  1286.     end
  1287.     else
  1288.         if SaveDialog1.Execute then
  1289.             Self.PlayListManager.Save(SaveDialog1.FileName,CurrentItem);
  1290. end;
  1291. procedure TMainForm.N6Click(Sender: TObject);
  1292. begin
  1293.     if SaveDialog2.Execute then
  1294.     begin
  1295.         if UpperCase(ExtractFileExt(SaveDialog2.FileName))='.WPL' then
  1296.             Self.PlayListManager.Save(SaveDialog2.FileName,CurrentItem)
  1297.         else
  1298.             Self.PlayListManager.SaveAs(SaveDialog2.FileName);
  1299.     end;
  1300. end;
  1301. procedure TMainForm.LMDTrackBar1MouseUp(Sender: TObject;
  1302.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1303. begin
  1304.     Self.LMDTrackBar1.Invalidate;
  1305. end;
  1306. procedure TMainForm.ListView1DblClick(Sender: TObject);
  1307. begin
  1308.     if ListView1.Selected<>nil then
  1309.     begin
  1310.         Self.OpenFile(ListView1.Selected);
  1311.     end;
  1312. end;
  1313. procedure TMainForm.dxBarButton53Click(Sender: TObject);
  1314. Var
  1315.     b:Boolean;
  1316.     Item:TMenuItem;
  1317. begin
  1318.     if Sender is TMenuItem then
  1319.     begin
  1320.         Item:=TMenuItem(PopupMenu3.Items.Find('循环播放'));
  1321.         if Item<>nil then
  1322.         begin
  1323.             Item.Checked:=Not Item.Checked;
  1324.             b:=Item.Checked;
  1325.         end
  1326.         else
  1327.             b:=dxBarButton53.Down;
  1328.     end
  1329.     else
  1330.         b:=dxBarButton53.Down;
  1331.     WriteIni('Config','RoundPlay',BoolToStr(b));
  1332.     if Sender is TdxBarButton then
  1333.     begin
  1334.         Item:=TMenuItem(PopupMenu3.Items.Find('循环播放'));
  1335.         if Item<>nil then
  1336.         begin
  1337.             Item.Checked:=b;
  1338.         end;
  1339.     end
  1340.     else
  1341.         dxBarButton53.Down:=b;
  1342. end;
  1343. procedure TMainForm.SpeedButton13Click(Sender: TObject);
  1344. begin
  1345.     PostMessage(Handle,WM_PLAYNEXT,0,0);
  1346. end;
  1347. procedure TMainForm.ListView1DragOver(Sender, Source: TObject; X,
  1348.   Y: Integer; State: TDragState; var Accept: Boolean);
  1349. begin
  1350.     if Source=ListView1 then accept :=true;
  1351. end;
  1352. procedure TMainForm.ListView1DragDrop(Sender, Source: TObject; X,
  1353.   Y: Integer);
  1354. var
  1355.     DragItem, TargetItem:TListItem;
  1356.     TargetIndex: integer;
  1357. begin
  1358.     DragItem := ListView1.Selected;
  1359.     TargetIndex := ListView1.DropTarget.Index;
  1360.     if TargetIndex>DragItem.Index then
  1361.         TargetItem:=ListView1.Items.Insert(TargetIndex+1)
  1362.     else
  1363.         TargetItem:=ListView1.Items.Insert(TargetIndex);
  1364.     TargetItem.Assign(DragItem);
  1365.     DragItem.Delete;
  1366. end;
  1367. procedure TMainForm.dxBarButton22Click(Sender: TObject);
  1368. begin
  1369.     SpeedButton4.Enabled:=Not dxBarButton56.Down;
  1370.     DoRatio;
  1371. end;
  1372. procedure TMainForm.dxBarButton21Click(Sender: TObject);
  1373. begin
  1374.     SpeedButton14.Click;
  1375. end;
  1376. procedure TMainForm.dxBarButton13Click(Sender: TObject);
  1377. begin
  1378.     PForm.ShowModal;
  1379. end;
  1380. procedure TMainForm.dxBarButton30Click(Sender: TObject);
  1381. begin
  1382.     N10.Click;
  1383. end;
  1384. procedure TMainForm.dxBarButton31Click(Sender: TObject);
  1385. begin
  1386.     N11.Click;
  1387. end;
  1388. procedure TMainForm.dxBarButton27Click(Sender: TObject);
  1389. begin
  1390.     N3.Click;
  1391. end;
  1392. procedure TMainForm.dxBarButton46Click(Sender: TObject);
  1393. begin
  1394.     N4.Click;
  1395. end;
  1396. procedure TMainForm.dxBarButton29Click(Sender: TObject);
  1397. begin
  1398.     N5.Click;
  1399. end;
  1400. procedure TMainForm.dxBarButton28Click(Sender: TObject);
  1401. begin
  1402.     N6.Click;
  1403. end;
  1404. procedure TMainForm.dxBarButton33Click(Sender: TObject);
  1405. begin
  1406.     AForm.ShowModal;
  1407. end;
  1408. procedure TMainForm.ApplicationEvents1Activate(Sender: TObject);
  1409. begin
  1410.     if (PlayState=psPause) and AutoPause then
  1411.     begin
  1412.         SpeedButton1.Click;
  1413.         AutoPause:=false;
  1414.     end;
  1415. end;
  1416. procedure TMainForm.ApplicationEvents1Deactivate(Sender: TObject);
  1417. begin
  1418.     if (PlayState=psPlay) and (Not AutoPause) then
  1419.     begin
  1420.         AutoPause:=true;
  1421.         SpeedButton2.Click;
  1422.         if N15.Checked then
  1423.             CoolTrayIcon1.HideMainForm
  1424.         else if N14.Checked then
  1425.         begin
  1426.         end
  1427.         else
  1428.             Application.Terminate;
  1429.     end;
  1430. end;
  1431. procedure TMainForm.dxBarButton11Click(Sender: TObject);
  1432. begin
  1433.     if OpenDialog3.Execute then
  1434.     begin
  1435.         PlayEndFileName:=OpenDialog3.FileName;
  1436.     end;
  1437. end;
  1438. procedure TMainForm.DoRatio;
  1439. begin
  1440.     if dxBarButton22.Down then
  1441.         dllDisplayRatio(1)
  1442.     else
  1443.         dllDisplayRatio(0);
  1444.     WriteIni('Config','Ratio',BoolToStr(dxBarButton22.Down));
  1445. end;
  1446. procedure TMainForm.dxBarButton47Click(Sender: TObject);
  1447. begin
  1448.     ListView1.Visible:=dxBarButton47.Down;
  1449.     dxBarButton56.OnClick(dxBarButton56);
  1450.     if (Not dxBarButton56.Down) and (SpeedButton4.Down) then
  1451.     begin
  1452.         SpeedButton4.OnClick(SpeedButton4);
  1453.     end;
  1454.     WriteIni('Playing','PlayListVisible',BoolToStr(dxBarButton47.Down));
  1455. end;
  1456. procedure TMainForm.Panel1Paint(Sender: TObject);
  1457. Var
  1458.     dc:HDC;
  1459. begin
  1460.     if Not (PlayState in [psPause,psOne]) then
  1461.         Exit;
  1462.     DC:=GetDC(Panel1.Handle);
  1463.     Try
  1464.         dllRepaint(Panel1.Handle,DC);
  1465.     Finally
  1466.         ReleaseDC(Panel1.Handle,DC);
  1467.     end;
  1468. end;
  1469. procedure TMainForm.SpeedButton12Click(Sender: TObject);
  1470. begin
  1471.     PostMessage(Handle,WM_PLAYPRIOR,0,0);
  1472. end;
  1473. procedure TMainForm.CoolTrayIcon1Click(Sender: TObject);
  1474. begin
  1475.     if Not MainForm.Showing then
  1476.         CoolTrayIcon1.ShowMainForm;
  1477. end;
  1478. procedure TMainForm.N12Click(Sender: TObject);
  1479. begin
  1480.     Application.Terminate;
  1481. end;
  1482. procedure TMainForm.N8Click(Sender: TObject);
  1483. begin
  1484.     if Not MainForm.Showing then
  1485.         CoolTrayIcon1.ShowMainForm;
  1486. end;
  1487. procedure TMainForm.dxBarButton55Click(Sender: TObject);
  1488. Var
  1489.     W,h:Integer;
  1490.     Rec:TRect;
  1491. begin
  1492.     if SpeedButton6.Visible then
  1493.         Exit;
  1494.     OldPosRect:=Rect(Left,Top,Width,Height);
  1495.     if dllGetVideoRect(@Rec) then
  1496.     begin
  1497.         W:=Rec.Right-Panel1.ClientWidth;
  1498.         H:=Rec.Bottom-Panel1.ClientHeight;
  1499.         Width:=Width+W;
  1500.         Height:=Height+H;
  1501.     end;
  1502.     Left:=(Screen.Width-Width) div 2;
  1503.     Top:=(Screen.Height-Height) div 2;
  1504. end;
  1505. procedure TMainForm.dxBarButton56Click(Sender: TObject);
  1506. begin
  1507.     SpeedButton4.Enabled:=Not dxBarButton56.Down;
  1508.     if dxBarButton56.Down then
  1509.     begin
  1510.         DoRatio;
  1511.         dxBarButton55.Click;
  1512.     end;
  1513.     WriteIni('Config','AutoSize',BoolToStr(dxBarButton56.Down));
  1514. end;
  1515. procedure TMainForm.MenuItemClick(Sender: TObject);
  1516. begin
  1517.     ImageList1.GetIcon(TMenuItem(Sender).ImageIndex,CoolTrayIcon1.Icon);
  1518.     CoolTrayIcon1.Refresh;
  1519.     WriteIni('Config','IconIndex',IntToStr(TMenuItem(Sender).ImageIndex));
  1520. end;
  1521. procedure TMainForm.dxBarButton57Click(Sender: TObject);
  1522. Var
  1523.     Pos:LongInt;
  1524.     FileName:String;
  1525.     FileType:TFileType;
  1526. begin
  1527.     Pos:=StrToInt(ReadIni('Config','PlayPos','-1'));
  1528.     FileName:=ReadIni('Config','PlayPosFileName','');
  1529.     FileType:=TFileType(StrToInt(ReadIni('Config','FileType','0')));
  1530.     if (FileName='') or (Not FileExists(FileName)) or (Pos=-1) then
  1531.     begin
  1532.         MessageBox(Handle,'未发现可以恢复的媒体信息','提示',MB_ICONINFORMATION);
  1533.         Exit;
  1534.     end;
  1535.     bContinuePlay:=true;
  1536.     PlayListManager.Add(FileName,FileType,ptPlay,Pos);
  1537. end;
  1538. procedure TMainForm.StopPlay(IsSave: Boolean);
  1539. Var
  1540.     Pos:LongInt;
  1541.     Info:PPlayFileInfo;
  1542. begin
  1543.     if IsSave and (PlayState in [psPlay,psPause,psOne]) then
  1544.     begin
  1545.         Pos:=dllGetPostion;
  1546.         Info:=CurrentItem.Data;
  1547.         WriteIni('Config','PlayPos',IntToStr(Pos));
  1548.         WriteIni('Config','PlayPosFileName',Info.FileName);
  1549.         WriteIni('Config','FileType',IntToStr(Integer(Info.FileType)));
  1550.     end;
  1551.     DllStop;
  1552.     PlayState:=psStop;
  1553.     Timer1.Enabled:=false;
  1554.     UpdateButtonState;
  1555.     LMDTrackBar2.Position:=0;
  1556.     Panel1.Invalidate;
  1557. end;
  1558. procedure TMainForm.DropURLTarget1Drop(Sender: TObject;
  1559.   ShiftState: TShiftState; Point: TPoint; var Effect: Integer);
  1560. begin
  1561.     PlayListManager.Add(TDropURLTarget(Sender).URL,ftUnknown,ptAdd);
  1562. end;
  1563. procedure TMainForm.DropFileTarget1Drop(Sender: TObject;
  1564.   ShiftState: TShiftState; Point: TPoint; var Effect: Integer);
  1565. var
  1566.     i: integer;
  1567. begin
  1568.     with TDropFileTarget(Sender) do
  1569.     begin
  1570.         for i := 0 to files.count-1 do
  1571.         begin
  1572.             if (i=0) and (ListView1.Items.Count=0) then
  1573.                 PlayListManager.Add(files[i],ftUnknown,ptPlay)
  1574.             else
  1575.                 PlayListManager.Add(files[i],ftUnknown,ptAdd);
  1576.         end;
  1577.     end;
  1578. end;
  1579. procedure TMainForm.FormResize(Sender: TObject);
  1580. Var
  1581.     Rec:TRect;
  1582. begin
  1583.     Rec:=Rect(Left,Top,Width,Height);
  1584.     WriteIni('Config','PosX',IntToStr(Rec.Left));
  1585.     WriteIni('Config','PosY',IntToStr(Rec.Top));
  1586.     WriteIni('Config','PosWidth',IntToStr(Rec.Right));
  1587.     WriteIni('Config','PosHeight',IntToStr(Rec.Bottom));
  1588. end;
  1589. procedure TMainForm.SpeedButton16Click(Sender: TObject);
  1590. begin
  1591.     AuForm.ShowModal;
  1592. end;
  1593. procedure TMainForm.dxBarButton58Click(Sender: TObject);
  1594. Var
  1595.     Val1,Val2:LongInt;
  1596. begin
  1597.     DllConfig('SHOWDECODEPROPERTY',Val1,Val2);
  1598. end;
  1599. procedure TMainForm.FilterOptionClick(Sender: TObject);
  1600. Var
  1601.     Val1,Val2:LongInt;
  1602. begin
  1603.     Val1:=Integer(PChar(TdxBarButton(Sender).Caption));
  1604.     DllConfig('SHOWFILTERPROPERTY',Val1,Val2);
  1605. end;
  1606. procedure TMainForm.dxBarButton60Click(Sender: TObject);
  1607. begin
  1608.     CEForm.ShowModal;
  1609. end;
  1610. procedure TMainForm.LMDTrackBar1MouseWheel(Sender: TObject;
  1611.   Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;
  1612.   var Handled: Boolean);
  1613. begin
  1614.     LMDTrackBar1.Position:=LMDTrackBar1.Position+WheelDelta;
  1615. end;
  1616. procedure TMainForm.FormDeactivate(Sender: TObject);
  1617. begin
  1618.     ApplicationEvents1Deactivate(nil);
  1619. end;
  1620. class function TMainForm.ReadReg(Key: String; DefaultValue: Variant): Variant;
  1621. Var
  1622.     Reg:TRegistry;
  1623. begin
  1624.     Result:=NULL;
  1625.     Reg:=TRegistry.Create;
  1626.     Try
  1627.         Reg.RootKey:=HKEY_CURRENT_USER;
  1628.         if Reg.OpenKey('/WHSUPPERPLAYER/RUN',false) then
  1629.         begin
  1630.             Result:=Reg.ReadString(Key);
  1631.             if VarIsNull(Result) or VarIsEmpty(Result) then
  1632.                 Result:=DefaultValue;
  1633.         end
  1634.         else
  1635.             Result:=DefaultValue;
  1636.     Finally
  1637.         Reg.Free;
  1638.     end;
  1639. end;
  1640. class procedure TMainForm.WriteReg(Key: String; Value: Variant);
  1641. Var
  1642.     Reg:TRegistry;
  1643. begin
  1644.     Reg:=TRegistry.Create;
  1645.     Try
  1646.         Reg.RootKey:=HKEY_CURRENT_USER;
  1647.         if Reg.OpenKey('/WHSUPPERPLAYER/RUN',true) then
  1648.         begin
  1649.             Reg.WriteString(Key,Value);
  1650.         end
  1651.     Finally
  1652.         Reg.Free;
  1653.     end;
  1654. end;
  1655. procedure TMainForm.dxBarButton62Click(Sender: TObject);
  1656. begin
  1657.     Close;
  1658. end;
  1659. procedure TMainForm.InitPlayMenu(Items: TdxBarSubItem; MenuItem:TMenuItem);
  1660. Var
  1661.     i:Integer;
  1662.     Item:TMenuItem;
  1663.     Link:TdxBarItemLink;
  1664. begin
  1665.     for i:=0 to Items.ItemLinks.Count-1 do
  1666.     begin
  1667.         Link:=Items.ItemLinks.Items[i];
  1668.         if Link.BeginGroup then
  1669.         begin
  1670.             Item:=TMenuItem.Create(MenuItem);
  1671.             MenuItem.Add(Item);
  1672.             Item.Caption:='-';
  1673.         end;
  1674.         if Link.Item.ClassType=TdxBarSubItem then
  1675.         begin
  1676.             Item:=TMenuItem.Create(MenuItem);
  1677.             MenuItem.Add(Item);
  1678.             Item.Caption:=Link.Caption;
  1679.             Item.OnClick:=TdxBarSubItem(Link.Item).OnClick;
  1680.             InitPlayMenu(TdxBarSubItem(Link.Item),Item);
  1681.         end
  1682.         else
  1683.         begin
  1684.             Item:=TMenuItem.Create(MenuItem);
  1685.             MenuItem.Add(Item);
  1686.             Item.Caption:=Link.Caption;
  1687.             Item.OnClick:=TdxBarButton(Link.Item).OnClick;
  1688.         end;
  1689.     end;
  1690. end;
  1691. procedure TMainForm.PopupMenu3Popup(Sender: TObject);
  1692. Var
  1693.     Item:TMenuItem;
  1694. begin
  1695.     Item:=TMenuItem(PopupMenu3.Items.Find('循环播放'));
  1696.     if Item<>nil then
  1697.     begin
  1698.         Item.Checked:=dxBarButton53.Down;
  1699.     end;
  1700. end;
  1701. procedure TMainForm.Panel1DblClick(Sender: TObject);
  1702. Var
  1703.     nLayer:Integer;
  1704.     Pt:TPoint;
  1705. begin
  1706.     if PlayState in [psPreview] then
  1707.     begin
  1708.         GetCursorPos(Pt);
  1709.         Pt:=Panel1.ScreenToClient(Pt);
  1710.         nLayer:=GetLayerNo(Pt.X,Pt.Y);
  1711.         PlayListManager.Add(PreviewFileName[nLayer],ftUnknown,ptPlay,LMDTrackBar2.Position);
  1712.         PausePreview:=true;
  1713.         DllPreviewPause();
  1714.         Exit;
  1715.     end;
  1716.     if Not (PlayState in [psPlay,psPause,psOne,psPreview]) then
  1717.         Exit;
  1718.     if SpeedButton14.Visible then
  1719.         SpeedButton14.Click
  1720.     else
  1721.         SpeedButton6.Click;
  1722. end;
  1723. procedure TMainForm.Timer2Timer(Sender: TObject);
  1724. begin
  1725.     if Not (SpeedButton6.Visible) then
  1726.         Exit;
  1727.     if Panel2.Visible then
  1728.         Exit;
  1729.     if GetTickCount-MouseTimeout>2000 then
  1730.     begin
  1731.         Timer2.Enabled:=false;
  1732.         ShowCursor(false);
  1733.     end;
  1734. end;
  1735. procedure TMainForm.dxBarButton63Click(Sender: TObject);
  1736. Var
  1737.     i,L,T:Integer;
  1738.     Rec:TRect;
  1739.     procedure GetRect;
  1740.     Var
  1741.         W,H:Integer;
  1742.     begin
  1743.         W:=Panel1.ClientWidth div 2;
  1744.         H:=Panel1.ClientHeight div 2;
  1745.         T:=(i div 2)*H;
  1746.         L:=(i mod 2)*W;
  1747.         Rec:=Rect(L,T,L+W,T+H);
  1748.     end;
  1749. begin
  1750.     if Not (PlayState in [psPreview,psNone]) then
  1751.         SpeedButton3.Click;
  1752.         
  1753.     PausePreview:=false;
  1754.     dllBeginPreview(Panel1.Handle,4);
  1755.     if OpenDialog1.Execute then
  1756.     begin
  1757.         for i:=0 to OpenDialog1.Files.Count-1 do
  1758.         begin
  1759.             dllSetPreviewMedia(PChar(OpenDialog1.Files.Strings[i]),i);
  1760.             GetRect;
  1761.             dllSetPreviewMediaRect(i,Rec);
  1762.             PreviewFileName[i]:=OpenDialog1.Files.Strings[i];
  1763.         end;
  1764.     end;
  1765.     dllPreviewPlay;
  1766.     PlayState:=psPreview;
  1767.     Timer1.Enabled:=true;
  1768. end;
  1769. function TMainForm.GetLayerNo(X,Y:Integer):Integer;
  1770. Var
  1771.     nLayer:Integer;
  1772. begin
  1773.     nLayer:=0;
  1774.     if PtInRect(Rect(0,0,ClientWidth div 2,ClientHeight div 2),Point(X,Y)) then
  1775.     begin
  1776.         nLayer:=0;
  1777.     end
  1778.     else if PtInRect(Rect(ClientWidth div 2,0,ClientWidth,ClientHeight div 2),Point(X,Y)) then
  1779.     begin
  1780.         nLayer:=1;
  1781.     end
  1782.     else if PtInRect(Rect(0,ClientHeight div 2,ClientWidth div 2,ClientHeight),Point(X,Y)) then
  1783.     begin
  1784.         nLayer:=2;
  1785.     end
  1786.     else if PtInRect(Rect(0,ClientHeight div 2,ClientWidth,ClientHeight),Point(X,Y)) then
  1787.     begin
  1788.         nLayer:=3;
  1789.     end;
  1790.     Result:=nLayer;
  1791. end;
  1792. procedure TMainForm.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  1793.   Shift: TShiftState; X, Y: Integer);
  1794. begin
  1795.     PreviewClick:=true;
  1796. end;
  1797. procedure TMainForm.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
  1798.   Shift: TShiftState; X, Y: Integer);
  1799. Var
  1800.     nLayer:Integer;
  1801. begin
  1802.     if (PreviewClick) and (PlayState=psPreview) then
  1803.     begin
  1804.         nLayer:=GetLayerNo(X,Y);
  1805.         PreviewClick:=false;
  1806.         dllPreviewSetAudio(nLayer,0-(3000-LMDTrackBar1.Position));
  1807.     end;
  1808. end;
  1809. procedure TMainForm.dxBarButton64Click(Sender: TObject);
  1810. begin
  1811.     if PlayState<>psPreview then
  1812.     begin
  1813.         Exit;
  1814.     end;
  1815.     Timer1.Enabled:=false;
  1816.     Playstate:=psNone;
  1817.     DllEndPreview();
  1818.     PausePreview:=false;
  1819.     Panel1.Invalidate;
  1820. end;
  1821. procedure TMainForm.dxBarButton65Click(Sender: TObject);
  1822. begin
  1823.     if PausePreview then
  1824.     begin
  1825.         SpeedButton3.Click;
  1826.         PlayState:=psPreview;
  1827.         DllPreviewPlay();
  1828.         Timer1.Enabled:=true;
  1829.     end
  1830. end;
  1831. end.