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 SpeedButton6.Visible then
  986.             SpeedButton6.Click
  987.         else
  988.             SpeedButton14.Click;
  989.     end
  990. end;
  991. procedure TMainForm.UpdateFullScreen(b: Boolean);
  992. Var
  993.     a:Integer;
  994. begin
  995.     bLockUpateWindow:=true;
  996.     SpeedButton2.Click;
  997.     if b then
  998.     begin
  999.         //LockWindowUpdate(Handle);
  1000.         SpeedButton4.Visible:=false;
  1001.         dxBarManager1.Bars[0].Visible:=false;
  1002.         Panel1.Align:=alNone;
  1003.         Panel2.Align:=alNone;
  1004.         Panel2.Visible:=false;
  1005.         ListView1.Visible:=false;
  1006.         OldRec:=Rect(Self.Left,Self.Top,Self.Width,Self.Height);
  1007.         a:=GetWindowLong(Handle, GWL_STYLE);
  1008.         a:=a and not WS_CAPTION;
  1009.         SetWindowLong(Handle,GWL_STYLE,a);
  1010.         SetWindowLong(Handle,GWL_EXSTYLE,GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_TOPMOST);
  1011.         SetBounds(-4,-4,Screen.Width+8,Screen.Height+8);
  1012.         Self.Panel1.SetBounds(0,0,Screen.Width,Screen.Height);
  1013.         Self.Panel2.SetBounds(0,ClientHeight-Panel2.Height,ClientWidth,Panel2.Height);
  1014.         ShowCursor(false);
  1015. //        dllFullscreen;
  1016.         //LockWindowUpdate(0);
  1017.     end
  1018.     else
  1019.     begin
  1020.         SpeedButton4.Visible:=true;
  1021.         SetWindowLong(Handle,GWL_EXSTYLE,GetWindowLong(Handle, GWL_EXSTYLE) and not WS_EX_TOPMOST);
  1022.         SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle, GWL_STYLE) or WS_CAPTION or WS_BORDER);
  1023.         Self.SetBounds(OldRec.Left,OldRec.Top,OldRec.Right,OldRec.Bottom);
  1024.         Panel1.SetBounds(Self.ClientRect.Left,Self.ClientRect.Top,
  1025.             Self.ClientRect.Right-Self.ClientRect.Left,Self.ClientRect.Bottom-Self.ClientRect.Top);
  1026.         Panel1.Align:=alClient;
  1027.         Panel2.Align:=alBottom;
  1028.         dxBarManager1.Bars[0].Visible:=true;
  1029.         Self.Panel2.Visible:=true;
  1030.         ListView1.Visible:=dxBarButton47.Down;
  1031.         ShowCursor(true);
  1032. //        dllRestoreFromFullScreen;
  1033.     end;
  1034.     bLockUpateWindow:=false;
  1035.     PostMessage(Handle,WM_FULLSCREEN,0,0);
  1036. end;
  1037. procedure TMainForm.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
  1038.   Y: Integer);
  1039. begin
  1040.     if SpeedButton6.Visible then
  1041.     begin
  1042.         if (X<>OldPt.X) or (Y<>OldPt.Y) then
  1043.         begin
  1044.             OldPt:=Point(X,Y);
  1045.             MouseTimeout:=GetTickCount;
  1046.             if Not Timer2.Enabled then
  1047.             begin
  1048.                 ShowCursor(true);
  1049.                 Timer2.Enabled:=true;
  1050.             end;
  1051.         end;
  1052.         if Y>=Self.Height-Panel2.Height then
  1053.         begin
  1054.             if Panel2.Visible then
  1055.                 Exit;
  1056.             Panel2.Visible:=true;
  1057.         end
  1058.         else
  1059.         begin
  1060.             if Not Panel2.Visible then
  1061.                 Exit;
  1062.             Panel2.Visible:=false;
  1063.         end;
  1064.     end;
  1065. end;
  1066. procedure TMainForm.WMFULLSCREEN(var Msg: TMessage);
  1067. begin
  1068.     Panel1.OnResize(Panel1);
  1069.     SpeedButton1.Click;
  1070. end;
  1071. procedure TMainForm.dxBarButton44Click(Sender: TObject);
  1072. begin
  1073.     if OpenDialog1.Execute then
  1074.     begin
  1075.         dllAddUnLockGraph(PChar(OpenDialog1.FileName));
  1076.     end;
  1077. end;
  1078. procedure TMainForm.dxBarButton7Click(Sender: TObject);
  1079. begin
  1080.     Form1.ShowModal;
  1081. end;
  1082. function TMainForm.OpenFile(Item:TListItem): Boolean;
  1083. Var
  1084.     Info:PPlayFileInfo;
  1085.     FileStream:TFileStream;
  1086.     Str,Key:String;
  1087.     i:Integer;
  1088.     pStr:Array[0..1024] of Char;
  1089.     Var1,Var2:Integer;
  1090.     StrList:TStringList;
  1091.     Bu:TdxBarButton;
  1092.     b:Boolean;
  1093.     ItemLink:TdxBarItemLink;
  1094. begin
  1095.     Result:=false;
  1096.     Info:=Item.Data;
  1097.     if Not Info.bExists then
  1098.         Exit;
  1099.     if Info.bLock then
  1100.     begin
  1101.         if DllOpenLockFile(PChar(Info.FileName),PChar(PForm.Password))=0 then
  1102.             Exit;
  1103.         PlayState:=psLoad;
  1104.         SpeedButton1.Click;
  1105.         UpdateButtonState;
  1106.     end
  1107.     else
  1108.     begin
  1109.         if DllOpenUnLockFile(PChar(Info.FileName))=0 then
  1110.             Exit;
  1111.         PlayState:=psLoad;
  1112.         SpeedButton1.Click;
  1113.         UpdateButtonState;
  1114.     end;
  1115.     CurrentItem:=Item;
  1116.     ListView1.Invalidate;
  1117.     DoRatio;
  1118.     DllConfig('GETFILTERNAMES',Var1,Var2);
  1119.     dxBarButton7.DestroyComponents;
  1120.     StrList:=TStringList.Create;
  1121.     Try
  1122.         b:=true;
  1123.         StrList.Text:=StrPas(Ptr(Var1));
  1124.         For i:=0 to StrList.Count-1 do
  1125.         begin
  1126.             if StrList.Strings[i]='' then
  1127.                 Continue;
  1128.             Bu:=TdxBarButton.Create(dxBarButton7);
  1129.             Bu.Caption:=StrList.Strings[i];
  1130.             Bu.OnClick:=FilterOptionClick;
  1131.             ItemLink:=dxBarSubItem12.ItemLinks.Add;
  1132.             ItemLink.Item:=Bu;
  1133.             if b then
  1134.             begin
  1135.                 b:=false;
  1136.                 ItemLink.BeginGroup:=true;
  1137.             end;
  1138.         end;
  1139.     Finally
  1140.         StrList.Free;
  1141.     end;
  1142.     Result:=true;
  1143. end;
  1144. procedure TMainForm.dxBarButton5Click(Sender: TObject);
  1145. begin
  1146.     OpenDialog(ftUnKnown,ptPlay);
  1147. end;
  1148. procedure TMainForm.ApplicationEvents1Exception(Sender: TObject;
  1149.   E: Exception);
  1150. Var
  1151.     Str:String;
  1152. begin
  1153.     Str:=E.Message;
  1154. end;
  1155. procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
  1156. begin
  1157.     StopPlay(true);
  1158. end;
  1159. procedure TMainForm.OnReadyEnd(Sender: TObject; PlayInfo: PPlayFileInfo; Item:TListItem);
  1160. Var
  1161.     vItem:TListItem;
  1162.     Info:PPlayFileInfo;
  1163. begin
  1164.     if PlayInfo.bExists then
  1165.     begin
  1166.         vItem:=Item;
  1167.         While (Not OpenFile(vItem)) and (vItem.Index<ListView1.Items.Count-1) do
  1168.         begin
  1169.             vItem:=ListView1.Items[vItem.Index+1];
  1170.         end;
  1171.         Info:=vItem.Data;
  1172.         Self.MaxHours:=Info.MediaInfo.PlayHours;
  1173.         Self.MaxMinutes:=Info.MediaInfo.PlayMinites;
  1174.         Self.MaxSeconds:=Info.MediaInfo.PlaySeconds;
  1175.         if Info.Pos>0 then
  1176.         begin
  1177.             LMDTrackBar2.Position:=Info.Pos;
  1178.             dllSetPosition(LMDTrackBar2.Position);
  1179.         end;
  1180.     end;
  1181. end;
  1182. procedure TMainForm.ListView1CustomDrawItem(Sender: TCustomListView;
  1183.   Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
  1184. Var
  1185.     Info:PPlayFileInfo;
  1186.     OldColor:TColor;
  1187. begin
  1188.     Info:=Item.Data;
  1189.     Sender.Canvas.Font.Color:=clLime;
  1190.     if Not Info.bExists then
  1191.     begin
  1192.         Sender.Canvas.Brush.Color:=clRed
  1193.     end
  1194.     else
  1195.         Sender.Canvas.Brush.Color:=clBlack;
  1196.     if Item=CurrentItem then
  1197.     begin
  1198.         Sender.Canvas.Brush.Color:=clYellow;
  1199.         Sender.Canvas.Font.Color:=clBlack;
  1200.     end;
  1201. end;
  1202. procedure TMainForm.OpenDialog(FileType:TFileType; PlayType:TPlayType);
  1203. Var
  1204.     i:Integer;
  1205. begin
  1206.     if Opendialog1.Execute then
  1207.     begin
  1208. {
  1209.         DllOpenUnLockFile(PChar(OpenDialog1.FileName));
  1210.         SpeedButton1.Click;
  1211.         Exit;
  1212. }
  1213.         For i:=0 to OpenDialog1.Files.Count-1 do
  1214.         begin
  1215.             if (i=0) and (PlayType=ptPlay) then
  1216.             begin
  1217.                 Self.PlayListManager.Add(OpenDialog1.Files.Strings[i],FileType,ptPlay);
  1218.             end
  1219.             else
  1220.                 Self.PlayListManager.Add(OpenDialog1.Files.Strings[i],FileType,ptAdd);
  1221.         end;
  1222.     end;
  1223. end;
  1224. procedure TMainForm.N10Click(Sender: TObject);
  1225. begin
  1226.     OpenDialog(ftUnLock,ptAdd);
  1227. end;
  1228. procedure TMainForm.N11Click(Sender: TObject);
  1229. Var
  1230.     CurDelete:Boolean;
  1231.     i:Integer;
  1232.     Item:TListItem;
  1233.     List:TList;
  1234. begin
  1235.     Item:=ListView1.Selected;
  1236.     if Item=nil then
  1237.         Exit;
  1238.     List:=TList.Create;
  1239.     Try
  1240.         Repeat
  1241.             List.Add(Item);
  1242.             Item:=ListView1.GetNextItem(Item, sdAll, [isSelected]);
  1243.         Until Item=nil;
  1244.         CurDelete:=false;
  1245.         For i:=0 to List.Count-1 do
  1246.         begin
  1247.             if List.Items[i]=CurrentItem then
  1248.             begin
  1249.                 CurDelete:=true;
  1250.                 if SpeedButton3.Enabled then
  1251.                     SpeedButton3.Click;
  1252.                 CurrentItem:=ListView1.GetNextItem(CurrentItem, sdAll, []);
  1253.             end;
  1254.             Self.PlayListManager.Delete(TListItem(List.Items[i]));
  1255.         end;
  1256.         if CurDelete then
  1257.         begin
  1258.             if CurrentItem<>nil then
  1259.                 OpenFile(CurrentItem);
  1260.         end;
  1261.     Finally
  1262.         List.Free;
  1263.     end;
  1264. end;
  1265. procedure TMainForm.N3Click(Sender: TObject);
  1266. begin
  1267.     if OpenDialog2.Execute then
  1268.     begin
  1269.         Self.PlayListManager.Open(OpenDialog2.FileName,false);
  1270.     end;
  1271. end;
  1272. procedure TMainForm.N4Click(Sender: TObject);
  1273. begin
  1274.     if OpenDialog2.Execute then
  1275.     begin
  1276.         Self.PlayListManager.Open(OpenDialog2.FileName,true);
  1277.     end;
  1278. end;
  1279. procedure TMainForm.N5Click(Sender: TObject);
  1280. begin
  1281.     if Self.PlayListManager.FileName<>'' then
  1282.     begin
  1283.         Self.PlayListManager.Save(Self.PlayListManager.FileName,CurrentItem);
  1284.     end
  1285.     else
  1286.         if SaveDialog1.Execute then
  1287.             Self.PlayListManager.Save(SaveDialog1.FileName,CurrentItem);
  1288. end;
  1289. procedure TMainForm.N6Click(Sender: TObject);
  1290. begin
  1291.     if SaveDialog2.Execute then
  1292.     begin
  1293.         if UpperCase(ExtractFileExt(SaveDialog2.FileName))='.WPL' then
  1294.             Self.PlayListManager.Save(SaveDialog2.FileName,CurrentItem)
  1295.         else
  1296.             Self.PlayListManager.SaveAs(SaveDialog2.FileName);
  1297.     end;
  1298. end;
  1299. procedure TMainForm.LMDTrackBar1MouseUp(Sender: TObject;
  1300.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1301. begin
  1302.     Self.LMDTrackBar1.Invalidate;
  1303. end;
  1304. procedure TMainForm.ListView1DblClick(Sender: TObject);
  1305. begin
  1306.     if ListView1.Selected<>nil then
  1307.     begin
  1308.         Self.OpenFile(ListView1.Selected);
  1309.     end;
  1310. end;
  1311. procedure TMainForm.dxBarButton53Click(Sender: TObject);
  1312. Var
  1313.     b:Boolean;
  1314.     Item:TMenuItem;
  1315. begin
  1316.     if Sender is TMenuItem then
  1317.     begin
  1318.         Item:=TMenuItem(PopupMenu3.Items.Find('循环播放'));
  1319.         if Item<>nil then
  1320.         begin
  1321.             Item.Checked:=Not Item.Checked;
  1322.             b:=Item.Checked;
  1323.         end
  1324.         else
  1325.             b:=dxBarButton53.Down;
  1326.     end
  1327.     else
  1328.         b:=dxBarButton53.Down;
  1329.     WriteIni('Config','RoundPlay',BoolToStr(b));
  1330.     if Sender is TdxBarButton then
  1331.     begin
  1332.         Item:=TMenuItem(PopupMenu3.Items.Find('循环播放'));
  1333.         if Item<>nil then
  1334.         begin
  1335.             Item.Checked:=b;
  1336.         end;
  1337.     end
  1338.     else
  1339.         dxBarButton53.Down:=b;
  1340. end;
  1341. procedure TMainForm.SpeedButton13Click(Sender: TObject);
  1342. begin
  1343.     PostMessage(Handle,WM_PLAYNEXT,0,0);
  1344. end;
  1345. procedure TMainForm.ListView1DragOver(Sender, Source: TObject; X,
  1346.   Y: Integer; State: TDragState; var Accept: Boolean);
  1347. begin
  1348.     if Source=ListView1 then accept :=true;
  1349. end;
  1350. procedure TMainForm.ListView1DragDrop(Sender, Source: TObject; X,
  1351.   Y: Integer);
  1352. var
  1353.     DragItem, TargetItem:TListItem;
  1354.     TargetIndex: integer;
  1355. begin
  1356.     DragItem := ListView1.Selected;
  1357.     TargetIndex := ListView1.DropTarget.Index;
  1358.     if TargetIndex>DragItem.Index then
  1359.         TargetItem:=ListView1.Items.Insert(TargetIndex+1)
  1360.     else
  1361.         TargetItem:=ListView1.Items.Insert(TargetIndex);
  1362.     TargetItem.Assign(DragItem);
  1363.     DragItem.Delete;
  1364. end;
  1365. procedure TMainForm.dxBarButton22Click(Sender: TObject);
  1366. begin
  1367.     SpeedButton4.Enabled:=Not dxBarButton56.Down;
  1368.     DoRatio;
  1369. end;
  1370. procedure TMainForm.dxBarButton21Click(Sender: TObject);
  1371. begin
  1372.     SpeedButton14.Click;
  1373. end;
  1374. procedure TMainForm.dxBarButton13Click(Sender: TObject);
  1375. begin
  1376.     PForm.ShowModal;
  1377. end;
  1378. procedure TMainForm.dxBarButton30Click(Sender: TObject);
  1379. begin
  1380.     N10.Click;
  1381. end;
  1382. procedure TMainForm.dxBarButton31Click(Sender: TObject);
  1383. begin
  1384.     N11.Click;
  1385. end;
  1386. procedure TMainForm.dxBarButton27Click(Sender: TObject);
  1387. begin
  1388.     N3.Click;
  1389. end;
  1390. procedure TMainForm.dxBarButton46Click(Sender: TObject);
  1391. begin
  1392.     N4.Click;
  1393. end;
  1394. procedure TMainForm.dxBarButton29Click(Sender: TObject);
  1395. begin
  1396.     N5.Click;
  1397. end;
  1398. procedure TMainForm.dxBarButton28Click(Sender: TObject);
  1399. begin
  1400.     N6.Click;
  1401. end;
  1402. procedure TMainForm.dxBarButton33Click(Sender: TObject);
  1403. begin
  1404.     AForm.ShowModal;
  1405. end;
  1406. procedure TMainForm.ApplicationEvents1Activate(Sender: TObject);
  1407. begin
  1408.     if (PlayState=psPause) and AutoPause then
  1409.     begin
  1410.         SpeedButton1.Click;
  1411.         AutoPause:=false;
  1412.     end;
  1413. end;
  1414. procedure TMainForm.ApplicationEvents1Deactivate(Sender: TObject);
  1415. begin
  1416.     if (PlayState=psPlay) and (Not AutoPause) then
  1417.     begin
  1418.         AutoPause:=true;
  1419.         SpeedButton2.Click;
  1420.         if N15.Checked then
  1421.             CoolTrayIcon1.HideMainForm
  1422.         else if N14.Checked then
  1423.         begin
  1424.         end
  1425.         else
  1426.             Application.Terminate;
  1427.     end;
  1428. end;
  1429. procedure TMainForm.dxBarButton11Click(Sender: TObject);
  1430. begin
  1431.     if OpenDialog3.Execute then
  1432.     begin
  1433.         PlayEndFileName:=OpenDialog3.FileName;
  1434.     end;
  1435. end;
  1436. procedure TMainForm.DoRatio;
  1437. begin
  1438.     if dxBarButton22.Down then
  1439.         dllDisplayRatio(1)
  1440.     else
  1441.         dllDisplayRatio(0);
  1442.     WriteIni('Config','Ratio',BoolToStr(dxBarButton22.Down));
  1443. end;
  1444. procedure TMainForm.dxBarButton47Click(Sender: TObject);
  1445. begin
  1446.     ListView1.Visible:=dxBarButton47.Down;
  1447.     dxBarButton56.OnClick(dxBarButton56);
  1448.     if (Not dxBarButton56.Down) and (SpeedButton4.Down) then
  1449.     begin
  1450.         SpeedButton4.OnClick(SpeedButton4);
  1451.     end;
  1452.     WriteIni('Playing','PlayListVisible',BoolToStr(dxBarButton47.Down));
  1453. end;
  1454. procedure TMainForm.Panel1Paint(Sender: TObject);
  1455. Var
  1456.     dc:HDC;
  1457. begin
  1458.     if Not (PlayState in [psPause,psOne]) then
  1459.         Exit;
  1460.     DC:=GetDC(Panel1.Handle);
  1461.     Try
  1462.         dllRepaint(Panel1.Handle,DC);
  1463.     Finally
  1464.         ReleaseDC(Panel1.Handle,DC);
  1465.     end;
  1466. end;
  1467. procedure TMainForm.SpeedButton12Click(Sender: TObject);
  1468. begin
  1469.     PostMessage(Handle,WM_PLAYPRIOR,0,0);
  1470. end;
  1471. procedure TMainForm.CoolTrayIcon1Click(Sender: TObject);
  1472. begin
  1473.     if Not MainForm.Showing then
  1474.         CoolTrayIcon1.ShowMainForm;
  1475. end;
  1476. procedure TMainForm.N12Click(Sender: TObject);
  1477. begin
  1478.     Application.Terminate;
  1479. end;
  1480. procedure TMainForm.N8Click(Sender: TObject);
  1481. begin
  1482.     if Not MainForm.Showing then
  1483.         CoolTrayIcon1.ShowMainForm;
  1484. end;
  1485. procedure TMainForm.dxBarButton55Click(Sender: TObject);
  1486. Var
  1487.     W,h:Integer;
  1488.     Rec:TRect;
  1489. begin
  1490.     if SpeedButton6.Visible then
  1491.         Exit;
  1492.     OldPosRect:=Rect(Left,Top,Width,Height);
  1493.     if dllGetVideoRect(@Rec) then
  1494.     begin
  1495.         W:=Rec.Right-Panel1.ClientWidth;
  1496.         H:=Rec.Bottom-Panel1.ClientHeight;
  1497.         Width:=Width+W;
  1498.         Height:=Height+H;
  1499.     end;
  1500.     Left:=(Screen.Width-Width) div 2;
  1501.     Top:=(Screen.Height-Height) div 2;
  1502. end;
  1503. procedure TMainForm.dxBarButton56Click(Sender: TObject);
  1504. begin
  1505.     SpeedButton4.Enabled:=Not dxBarButton56.Down;
  1506.     if dxBarButton56.Down then
  1507.     begin
  1508.         DoRatio;
  1509.         dxBarButton55.Click;
  1510.     end;
  1511.     WriteIni('Config','AutoSize',BoolToStr(dxBarButton56.Down));
  1512. end;
  1513. procedure TMainForm.MenuItemClick(Sender: TObject);
  1514. begin
  1515.     ImageList1.GetIcon(TMenuItem(Sender).ImageIndex,CoolTrayIcon1.Icon);
  1516.     CoolTrayIcon1.Refresh;
  1517.     WriteIni('Config','IconIndex',IntToStr(TMenuItem(Sender).ImageIndex));
  1518. end;
  1519. procedure TMainForm.dxBarButton57Click(Sender: TObject);
  1520. Var
  1521.     Pos:LongInt;
  1522.     FileName:String;
  1523.     FileType:TFileType;
  1524. begin
  1525.     Pos:=StrToInt(ReadIni('Config','PlayPos','-1'));
  1526.     FileName:=ReadIni('Config','PlayPosFileName','');
  1527.     FileType:=TFileType(StrToInt(ReadIni('Config','FileType','0')));
  1528.     if (FileName='') or (Not FileExists(FileName)) or (Pos=-1) then
  1529.     begin
  1530.         MessageBox(Handle,'未发现可以恢复的媒体信息','提示',MB_ICONINFORMATION);
  1531.         Exit;
  1532.     end;
  1533.     bContinuePlay:=true;
  1534.     PlayListManager.Add(FileName,FileType,ptPlay,Pos);
  1535. end;
  1536. procedure TMainForm.StopPlay(IsSave: Boolean);
  1537. Var
  1538.     Pos:LongInt;
  1539.     Info:PPlayFileInfo;
  1540. begin
  1541.     if IsSave and (PlayState in [psPlay,psPause,psOne]) then
  1542.     begin
  1543.         Pos:=dllGetPostion;
  1544.         Info:=CurrentItem.Data;
  1545.         WriteIni('Config','PlayPos',IntToStr(Pos));
  1546.         WriteIni('Config','PlayPosFileName',Info.FileName);
  1547.         WriteIni('Config','FileType',IntToStr(Integer(Info.FileType)));
  1548.     end;
  1549.     DllStop;
  1550.     PlayState:=psStop;
  1551.     Timer1.Enabled:=false;
  1552.     UpdateButtonState;
  1553.     LMDTrackBar2.Position:=0;
  1554.     Panel1.Invalidate;
  1555. end;
  1556. procedure TMainForm.DropURLTarget1Drop(Sender: TObject;
  1557.   ShiftState: TShiftState; Point: TPoint; var Effect: Integer);
  1558. begin
  1559.     PlayListManager.Add(TDropURLTarget(Sender).URL,ftUnknown,ptAdd);
  1560. end;
  1561. procedure TMainForm.DropFileTarget1Drop(Sender: TObject;
  1562.   ShiftState: TShiftState; Point: TPoint; var Effect: Integer);
  1563. var
  1564.     i: integer;
  1565. begin
  1566.     with TDropFileTarget(Sender) do
  1567.     begin
  1568.         for i := 0 to files.count-1 do
  1569.         begin
  1570.             if (i=0) and (ListView1.Items.Count=0) then
  1571.                 PlayListManager.Add(files[i],ftUnknown,ptPlay)
  1572.             else
  1573.                 PlayListManager.Add(files[i],ftUnknown,ptAdd);
  1574.         end;
  1575.     end;
  1576. end;
  1577. procedure TMainForm.FormResize(Sender: TObject);
  1578. Var
  1579.     Rec:TRect;
  1580. begin
  1581.     Rec:=Rect(Left,Top,Width,Height);
  1582.     WriteIni('Config','PosX',IntToStr(Rec.Left));
  1583.     WriteIni('Config','PosY',IntToStr(Rec.Top));
  1584.     WriteIni('Config','PosWidth',IntToStr(Rec.Right));
  1585.     WriteIni('Config','PosHeight',IntToStr(Rec.Bottom));
  1586. end;
  1587. procedure TMainForm.SpeedButton16Click(Sender: TObject);
  1588. begin
  1589.     AuForm.ShowModal;
  1590. end;
  1591. procedure TMainForm.dxBarButton58Click(Sender: TObject);
  1592. Var
  1593.     Val1,Val2:LongInt;
  1594. begin
  1595.     DllConfig('SHOWDECODEPROPERTY',Val1,Val2);
  1596. end;
  1597. procedure TMainForm.FilterOptionClick(Sender: TObject);
  1598. Var
  1599.     Val1,Val2:LongInt;
  1600. begin
  1601.     Val1:=Integer(PChar(TdxBarButton(Sender).Caption));
  1602.     DllConfig('SHOWFILTERPROPERTY',Val1,Val2);
  1603. end;
  1604. procedure TMainForm.dxBarButton60Click(Sender: TObject);
  1605. begin
  1606.     CEForm.ShowModal;
  1607. end;
  1608. procedure TMainForm.LMDTrackBar1MouseWheel(Sender: TObject;
  1609.   Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;
  1610.   var Handled: Boolean);
  1611. begin
  1612.     LMDTrackBar1.Position:=LMDTrackBar1.Position+WheelDelta;
  1613. end;
  1614. procedure TMainForm.FormDeactivate(Sender: TObject);
  1615. begin
  1616.     ApplicationEvents1Deactivate(nil);
  1617. end;
  1618. class function TMainForm.ReadReg(Key: String; DefaultValue: Variant): Variant;
  1619. Var
  1620.     Reg:TRegistry;
  1621. begin
  1622.     Result:=NULL;
  1623.     Reg:=TRegistry.Create;
  1624.     Try
  1625.         Reg.RootKey:=HKEY_CURRENT_USER;
  1626.         if Reg.OpenKey('/WHSUPPERPLAYER/RUN',false) then
  1627.         begin
  1628.             Result:=Reg.ReadString(Key);
  1629.             if VarIsNull(Result) or VarIsEmpty(Result) then
  1630.                 Result:=DefaultValue;
  1631.         end
  1632.         else
  1633.             Result:=DefaultValue;
  1634.     Finally
  1635.         Reg.Free;
  1636.     end;
  1637. end;
  1638. class procedure TMainForm.WriteReg(Key: String; Value: Variant);
  1639. Var
  1640.     Reg:TRegistry;
  1641. begin
  1642.     Reg:=TRegistry.Create;
  1643.     Try
  1644.         Reg.RootKey:=HKEY_CURRENT_USER;
  1645.         if Reg.OpenKey('/WHSUPPERPLAYER/RUN',true) then
  1646.         begin
  1647.             Reg.WriteString(Key,Value);
  1648.         end
  1649.     Finally
  1650.         Reg.Free;
  1651.     end;
  1652. end;
  1653. procedure TMainForm.dxBarButton62Click(Sender: TObject);
  1654. begin
  1655.     Close;
  1656. end;
  1657. procedure TMainForm.InitPlayMenu(Items: TdxBarSubItem; MenuItem:TMenuItem);
  1658. Var
  1659.     i:Integer;
  1660.     Item:TMenuItem;
  1661.     Link:TdxBarItemLink;
  1662. begin
  1663.     for i:=0 to Items.ItemLinks.Count-1 do
  1664.     begin
  1665.         Link:=Items.ItemLinks.Items[i];
  1666.         if Link.BeginGroup then
  1667.         begin
  1668.             Item:=TMenuItem.Create(MenuItem);
  1669.             MenuItem.Add(Item);
  1670.             Item.Caption:='-';
  1671.         end;
  1672.         if Link.Item.ClassType=TdxBarSubItem then
  1673.         begin
  1674.             Item:=TMenuItem.Create(MenuItem);
  1675.             MenuItem.Add(Item);
  1676.             Item.Caption:=Link.Caption;
  1677.             Item.OnClick:=TdxBarSubItem(Link.Item).OnClick;
  1678.             InitPlayMenu(TdxBarSubItem(Link.Item),Item);
  1679.         end
  1680.         else
  1681.         begin
  1682.             Item:=TMenuItem.Create(MenuItem);
  1683.             MenuItem.Add(Item);
  1684.             Item.Caption:=Link.Caption;
  1685.             Item.OnClick:=TdxBarButton(Link.Item).OnClick;
  1686.         end;
  1687.     end;
  1688. end;
  1689. procedure TMainForm.PopupMenu3Popup(Sender: TObject);
  1690. Var
  1691.     Item:TMenuItem;
  1692. begin
  1693.     Item:=TMenuItem(PopupMenu3.Items.Find('循环播放'));
  1694.     if Item<>nil then
  1695.     begin
  1696.         Item.Checked:=dxBarButton53.Down;
  1697.     end;
  1698. end;
  1699. procedure TMainForm.Panel1DblClick(Sender: TObject);
  1700. Var
  1701.     nLayer:Integer;
  1702.     Pt:TPoint;
  1703. begin
  1704.     if PlayState in [psPreview] then
  1705.     begin
  1706.         GetCursorPos(Pt);
  1707.         Pt:=Panel1.ScreenToClient(Pt);
  1708.         nLayer:=GetLayerNo(Pt.X,Pt.Y);
  1709.         PlayListManager.Add(PreviewFileName[nLayer],ftUnknown,ptPlay,LMDTrackBar2.Position);
  1710.         PausePreview:=true;
  1711.         DllPreviewPause();
  1712.         Exit;
  1713.     end;
  1714.     if Not (PlayState in [psPlay,psPause,psOne,psPreview]) then
  1715.         Exit;
  1716.     if SpeedButton14.Visible then
  1717.         SpeedButton14.Click
  1718.     else
  1719.         SpeedButton6.Click;
  1720. end;
  1721. procedure TMainForm.Timer2Timer(Sender: TObject);
  1722. begin
  1723.     if Not (SpeedButton6.Visible) then
  1724.         Exit;
  1725.     if Panel2.Visible then
  1726.         Exit;
  1727.     if GetTickCount-MouseTimeout>2000 then
  1728.     begin
  1729.         Timer2.Enabled:=false;
  1730.         ShowCursor(false);
  1731.     end;
  1732. end;
  1733. procedure TMainForm.dxBarButton63Click(Sender: TObject);
  1734. Var
  1735.     i,L,T:Integer;
  1736.     Rec:TRect;
  1737.     procedure GetRect;
  1738.     Var
  1739.         W,H:Integer;
  1740.     begin
  1741.         W:=Panel1.ClientWidth div 2;
  1742.         H:=Panel1.ClientHeight div 2;
  1743.         T:=(i div 2)*H;
  1744.         L:=(i mod 2)*W;
  1745.         Rec:=Rect(L,T,L+W,T+H);
  1746.     end;
  1747. begin
  1748.     if Not (PlayState in [psPreview,psNone]) then
  1749.         SpeedButton3.Click;
  1750.         
  1751.     PausePreview:=false;
  1752.     dllBeginPreview(Panel1.Handle,4);
  1753.     if OpenDialog1.Execute then
  1754.     begin
  1755.         for i:=0 to OpenDialog1.Files.Count-1 do
  1756.         begin
  1757.             dllSetPreviewMedia(PChar(OpenDialog1.Files.Strings[i]),i);
  1758.             GetRect;
  1759.             dllSetPreviewMediaRect(i,Rec);
  1760.             PreviewFileName[i]:=OpenDialog1.Files.Strings[i];
  1761.         end;
  1762.     end;
  1763.     dllPreviewPlay;
  1764.     PlayState:=psPreview;
  1765.     Timer1.Enabled:=true;
  1766. end;
  1767. function TMainForm.GetLayerNo(X,Y:Integer):Integer;
  1768. Var
  1769.     nLayer:Integer;
  1770. begin
  1771.     nLayer:=0;
  1772.     if PtInRect(Rect(0,0,ClientWidth div 2,ClientHeight div 2),Point(X,Y)) then
  1773.     begin
  1774.         nLayer:=0;
  1775.     end
  1776.     else if PtInRect(Rect(ClientWidth div 2,0,ClientWidth,ClientHeight div 2),Point(X,Y)) then
  1777.     begin
  1778.         nLayer:=1;
  1779.     end
  1780.     else if PtInRect(Rect(0,ClientHeight div 2,ClientWidth div 2,ClientHeight),Point(X,Y)) then
  1781.     begin
  1782.         nLayer:=2;
  1783.     end
  1784.     else if PtInRect(Rect(0,ClientHeight div 2,ClientWidth,ClientHeight),Point(X,Y)) then
  1785.     begin
  1786.         nLayer:=3;
  1787.     end;
  1788.     Result:=nLayer;
  1789. end;
  1790. procedure TMainForm.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  1791.   Shift: TShiftState; X, Y: Integer);
  1792. begin
  1793.     PreviewClick:=true;
  1794. end;
  1795. procedure TMainForm.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
  1796.   Shift: TShiftState; X, Y: Integer);
  1797. Var
  1798.     nLayer:Integer;
  1799. begin
  1800.     if (PreviewClick) and (PlayState=psPreview) then
  1801.     begin
  1802.         nLayer:=GetLayerNo(X,Y);
  1803.         PreviewClick:=false;
  1804.         dllPreviewSetAudio(nLayer,0-(3000-LMDTrackBar1.Position));
  1805.     end;
  1806. end;
  1807. procedure TMainForm.dxBarButton64Click(Sender: TObject);
  1808. begin
  1809.     if PlayState<>psPreview then
  1810.     begin
  1811.         Exit;
  1812.     end;
  1813.     Timer1.Enabled:=false;
  1814.     Playstate:=psNone;
  1815.     DllEndPreview();
  1816.     PausePreview:=false;
  1817.     Panel1.Invalidate;
  1818. end;
  1819. procedure TMainForm.dxBarButton65Click(Sender: TObject);
  1820. begin
  1821.     if PausePreview then
  1822.     begin
  1823.         SpeedButton3.Click;
  1824.         PlayState:=psPreview;
  1825.         DllPreviewPlay();
  1826.         Timer1.Enabled:=true;
  1827.     end
  1828. end;
  1829. end.