unit list; {$DEFINE DEBUG} interface uses Windows, ActnList, Buttons, Classes, ComCtrls, Controls, Dialogs, ExtCtrls, Forms, Graphics, Grids, Menus, Messages, StdCtrls, SysUtils, ToolWin, Variants, myDShow, myEdit, myFolderDialog, myGrid, myLabel, myList, mySendTo, myShape, myTag, myWStrings, info_get, info_update; const G_ciFIND_MEDIANAME = 0; G_ciFIND_MEDIAPATH = 1; G_ciFIND_FILENAME = 2; type T_MyItem = record iCol: Integer; iWidth: Integer; end; TApp_MEDIAPlaylist = class(TForm) ActionList1: TActionList; actWindow_Player: TAction; actFileCmd: TAction; actFileCmd_Rename: TAction; actFileCmd_MoveAs: TAction; actFileCmd_CopyAs: TAction; actFileCmd_Move: TAction; actFileCmd_Copy: TAction; actFileCmd_Trash: TAction; actFile_Property: TAction; actFile_Close: TAction; Action_Search: TAction; Action_SearchTitle: TAction; Action_SearchArtist: TAction; Action_SearchAlbum: TAction; Action_SearchWriter: TAction; Action_SearchComposer: TAction; Action_SearchConductor: TAction; Action_SearchSelectSite: TAction; actSort: TAction; actSort_Album: TAction; actSort_AlbumArtist: TAction; actSort_Artist: TAction; actSort_Composer: TAction; actSort_Conductor: TAction; actSort_Genre: TAction; actSort_Title: TAction; actSort_Track: TAction; actSort_Writer: TAction; actSort_Length: TAction; actSort_VideoSize: TAction; actSort_VideoFrameRate: TAction; actSort_FileName: TAction; actSort_MediaPath: TAction; actSort_MediaName: TAction; actSort_MediaExt: TAction; actSort_FileSize: TAction; actSort_FileWriteTime: TAction; actSort_FileCreateTime: TAction; actSort_Shuffle: TAction; actSort_PartOf: TAction; actListMove: TAction; actListMove_Up: TAction; actListMove_Down: TAction; actListMove_10Up: TAction; actListMove_10Down: TAction; actListMove_100Up: TAction; actListMove_100Down: TAction; actListMove_Top: TAction; actListMove_Bottom: TAction; actListEdit_Cut: TAction; actListEdit_Copy: TAction; actListEdit_CopyMediaName: TAction; actListEdit_CopyMediaPath: TAction; actListEdit_CopyFileName: TAction; actListEdit_CopyMainFileName: TAction; actListEdit_AppendCursor: TAction; actListEdit_Delete: TAction; actListEdit_SelectAll: TAction; actInfo_CopyTitle: TAction; actInfo_CopyArtist: TAction; actInfo_CopyAlbum: TAction; actFind_FindDown: TAction; actFind_FindUp: TAction; actFind_FindFileName: TAction; actFind_FindMediaPath: TAction; actFind_FindMediaName: TAction; actFind_FindArtist: TAction; actFind_FindAlbum: TAction; actFind_FindTitle: TAction; actFind_FindComposer: TAction; actFind_FindWriter: TAction; actFind_FindConductor: TAction; actPlay_SelPlay: TAction; actPlay_GoToItemIndex: TAction; actDisp_MediaInfo: TAction; actDisp_Font: TAction; actMenu_PopupPlayer: TAction; actMenu_PopupPlaylist: TAction; ActionList_Edit: TActionList; actEdit_Tab: TAction; actEdit_Undo: TAction; actEdit_Redo: TAction; actEdit_Cut: TAction; actEdit_Copy: TAction; actEdit_Paste: TAction; actEdit_Delete: TAction; actEdit_SelectAll: TAction; mnuPlayList: TPopupMenu; mniPPlay_SelPlay: TMenuItem; mniPPlay_ItemIndex: TMenuItem; mniPLine_1: TMenuItem; mniPListEdit: TMenuItem; mniPListEdit_CopyFileName: TMenuItem; mniPListEdit_CopyMediaPath: TMenuItem; mniPListEdit_CopyMediaName: TMenuItem; mniPListEdit_CopyMainFileName: TMenuItem; mniPListEdit_SelectAll: TMenuItem; mniPListEdit_Line1: TMenuItem; mniPListEdit_Delete: TMenuItem; mniPSort: TMenuItem; mniPSort_Track: TMenuItem; mniPSort_Artist: TMenuItem; mniPSort_Album: TMenuItem; mniPSort_AlbumArtist: TMenuItem; mniPSort_Title: TMenuItem; mniPSort_Composer: TMenuItem; mniPSort_Writer: TMenuItem; mniPSort_Conductor: TMenuItem; mniPSort_Genre: TMenuItem; mniPSort_Line1: TMenuItem; mniPSort_Length: TMenuItem; mniPSort_VideoWidth: TMenuItem; mniPSort_VideoFrameRate: TMenuItem; mniPSort_Line2: TMenuItem; mniPSort_FileName: TMenuItem; mniPSort_MediaPath: TMenuItem; mniPSort_MediaName: TMenuItem; mniPSort_MediaExt: TMenuItem; mniPSort_FileSize: TMenuItem; mniPSort_FileWriteTime: TMenuItem; mniPSort_FileCreatTime: TMenuItem; mniPSort_Line3: TMenuItem; mniPSort_Shuffle: TMenuItem; mniPSort_Line4: TMenuItem; mniPSort_PartOf: TMenuItem; mniPLine_2: TMenuItem; mniPFileCmd: TMenuItem; mniPFileCmd_Copy: TMenuItem; mniPFileCmd_Move: TMenuItem; mniPFileCmd_CopyAs: TMenuItem; mniPFileCmd_MoveAs: TMenuItem; mniPFileCmd_Rename: TMenuItem; mniPFileCmd_Line1: TMenuItem; mniPFileCmd_DeleteFromHDD: TMenuItem; MenuItem_PSendTo: TMenuItem; mniPLine_3: TMenuItem; mniPSearch: TMenuItem; mniPSearch_Title: TMenuItem; mniPSearch_Album: TMenuItem; mniPSearch_Artist: TMenuItem; mniPSearch_Writer: TMenuItem; mniPSearch_Composer: TMenuItem; mniPSearch_Conductor: TMenuItem; mniPSearch_Line1: TMenuItem; mniPSearch_SelectSite: TMenuItem; mniPDisp_MediaInfo: TMenuItem; mniPFile_Property: TMenuItem; mnuEdit: TPopupMenu; mniPEdit_Undo: TMenuItem; mniPEdit_Redo: TMenuItem; mniPEdit_Line1: TMenuItem; mniPEdit_Cut: TMenuItem; mniPEdit_Copy: TMenuItem; mniPEdit_Paste: TMenuItem; mniPEdit_Delete: TMenuItem; mniPEdit_Line2: TMenuItem; mniPEdit_SelectAll: TMenuItem; mniPEdit_Line3: TMenuItem; mniPFind_FindDown: TMenuItem; mniPFind_FindUp: TMenuItem; mniPEdit_Line4: TMenuItem; mniPFind_FindMediaName: TMenuItem; mniPFind_FindMediaPath: TMenuItem; mniPFind_FindFileName: TMenuItem; mnuFind_FindHistory: TPopupMenu; mnuSort: TPopupMenu; mniPPSort_Album: TMenuItem; mniPPSort_AlbumArtist: TMenuItem; mniPPSort_Artist: TMenuItem; mniPPSort_Composer: TMenuItem; mniPPSort_Conductor: TMenuItem; mniPPSort_Genre: TMenuItem; mniPPSort_Title: TMenuItem; mniPPSort_Track: TMenuItem; mniPPSort_Writer: TMenuItem; mniPPSort_Line1: TMenuItem; mniPPSort_Length: TMenuItem; mniPPSort_VideoWidth: TMenuItem; mniPPSort_VideoFrameRate: TMenuItem; mniPPSort_Line2: TMenuItem; mniPPSort_FileName: TMenuItem; mniPPSort_MediaName: TMenuItem; mniPPSort_MediaPath: TMenuItem; mniPPSort_MediaExt: TMenuItem; mniPPSort_FileSize: TMenuItem; mniPPSort_FileWriteTime: TMenuItem; mniPPSort_FileCreateTime: TMenuItem; mniPPSort_Line3: TMenuItem; mniPPSort_Shuffle: TMenuItem; mniPPSort_Line4: TMenuItem; mniPPSort_PartOf: TMenuItem; mnuListCopy: TPopupMenu; mniPPListEdit_CopyFileName: TMenuItem; mniPPListEdit_CopyMediaName: TMenuItem; mniPPListEdit_CopyMediaPath: TMenuItem; mniPPListEdit_CopyMainFileName: TMenuItem; mnuInfo: TPopupMenu; mniPPInfo_Copy: TMenuItem; mniPPInfo_CopyTitle: TMenuItem; mniPPInfo_CopyArtist: TMenuItem; mniPPInfo_CopyAlbum: TMenuItem; mniPPSearch: TMenuItem; mniPPSearch_Title: TMenuItem; mniPPSearch_Artist: TMenuItem; mniPPSearch_Album: TMenuItem; mniPPSearch_Writer: TMenuItem; mniPPSearch_Composer: TMenuItem; mniPPSearch_Conductor: TMenuItem; mniPPSearch_Line1: TMenuItem; mniPPSearch_SelectSite: TMenuItem; mnuSearch: TPopupMenu; mniPPPSearch_Title: TMenuItem; mniPPPSearch_Artist: TMenuItem; mniPPPSearch_Album: TMenuItem; mniPPPSearch_Writer: TMenuItem; mniPPPSearch_Composer: TMenuItem; mniPPPSearch_Conductor: TMenuItem; mniPPPSearch_Line1: TMenuItem; mniPPPSearch_SelectSite: TMenuItem; mnuSearch_SelectSite: TPopupMenu; Timer_Status: TTimer; Timer_StatusReset: TTimer; FontDialog1: TFontDialog; celPlaylist: TMyStringGrid; pnlInfo: TPanel; shpBottom: TShape; celInfo: TStringGrid; pnlToolBar: TPanel; shpLine1: TShape; ToolBar_PlayList: TToolBar; btnSpc0: TToolButton; btnToolFile_OpenFile: TToolButton; btnToolFile_OpenFolder: TToolButton; btnToolFile_OpenThisFolder: TToolButton; btnToolFile_SaveList: TToolButton; btnToolFile_Property: TToolButton; btnToolSearch: TToolButton; btnToolSearch_Title: TToolButton; btnToolSearch_Artist: TToolButton; btnToolSearch_Album: TToolButton; btnToolSearch_Writer: TToolButton; btnToolSearch_Composer: TToolButton; btnToolSearch_Conductor: TToolButton; btnToolSearch_SelectSite: TToolButton; btnToolFileCmd_Rename: TToolButton; btnToolFileCmd_MoveAs: TToolButton; btnToolFileCmd_CopyAs: TToolButton; btnToolFileCmd_Move: TToolButton; btnTool_Spc2: TToolButton; btnToolFileCmd_Copy: TToolButton; btnToolFileCmd_Trash: TToolButton; btnToolSendTo_OpenFolder: TToolButton; btnToolSendTo_SelProgram: TToolButton; btnToolSendTo_Regist: TToolButton; btnToolSendTo_Property: TToolButton; btnToolList_OpenAdd: TToolButton; btnToolList_SaveRelativePath: TToolButton; btnToolListEdit_Cut: TToolButton; btnToolListEdit_Copy: TToolButton; btnToolListEdit_CopyFileName: TToolButton; btnToolListEdit_CopyMediaPath: TToolButton; btnToolListEdit_CopyMediaName: TToolButton; btnToolListEdit_CopyMainFileName: TToolButton; btnToolListEdit_AppendCursor: TToolButton; btnToolListEdit_Delete: TToolButton; btnToolListEdit_SelectAll: TToolButton; btnTool_Spc3: TToolButton; pnlToolFind_Find: TPanel; btnToolFind_FindHistory: TSpeedButton; lblToolFind: TLabel; shpToolFind_Find: TMyShape; edtToolFind_Find: TMyEdit; btnToolFind_FindDown: TToolButton; btnToolFind_FindUp: TToolButton; btnToolFind_FileName: TToolButton; btnToolFind_MediaPath: TToolButton; btnToolFind_MediaName: TToolButton; btnToolSort: TToolButton; btnToolSort_FileName: TToolButton; btnToolSort_MediaPath: TToolButton; btnToolSort_MediaName: TToolButton; btnToolSort_MediaExt: TToolButton; btnToolSort_Shuffle: TToolButton; btnToolSort_PartOf: TToolButton; btnTool_Spc4: TToolButton; btnToolList_Move: TToolButton; btnToolList_MoveUp: TToolButton; btnToolList_MoveDown: TToolButton; btnToolList_MoveUp10: TToolButton; btnToolList_MoveDown10: TToolButton; btnToolList_MoveUp100: TToolButton; btnToolList_MoveDown100: TToolButton; btnToolList_MoveTop: TToolButton; btnToolList_MoveBottom: TToolButton; btnToolPlay_Play: TToolButton; btnToolPlay_GoToItemIndex: TToolButton; btnToolDisp_Info: TToolButton; btnToolDisp_Font: TToolButton; btnToolMenu_WindowList: TToolButton; btnToolOpt_AllowExt: TToolButton; ToolBar_Move: TToolBar; btnToolListMove_Up: TToolButton; btnToolListMove_Down: TToolButton; btnToolListMove_10Up: TToolButton; btnToolListMove_10Down: TToolButton; btnToolListMove_100Up: TToolButton; btnToolListMove_100Down: TToolButton; btnToolListMove_Top: TToolButton; btnToolListMove_Bottom: TToolButton; A1: TMenuItem; B1: TMenuItem; T1: TMenuItem; C1: TMenuItem; W1: TMenuItem; D1: TMenuItem; btnToolFind_FindArtist: TToolButton; btnToolFind_FindAlbum: TToolButton; btnToolFind_FindTitle: TToolButton; btnToolFind_FindComposer: TToolButton; btnToolFind_FindWriter: TToolButton; btnToolFind_FindConductor: TToolButton; btnToolSort_Track: TToolButton; btnToolSort_Artist: TToolButton; btnToolSort_Album: TToolButton; btnToolSort_AlbumArtist: TToolButton; btnToolSort_Title: TToolButton; btnToolSort_Composer: TToolButton; btnToolSort_Writer: TToolButton; btnToolSort_Conductor: TToolButton; btnToolSort_Genre: TToolButton; btnToolSort_Length: TToolButton; btnToolSort_VideoSize: TToolButton; btnToolSort_VideoFrameRate: TToolButton; btnToolSort_FileSize: TToolButton; btnToolSort_FileWriteTime: TToolButton; btnToolSort_FileCreateTime: TToolButton; btnToolList_ReadTag: TToolButton; mniPFileCmd_Trash: TMenuItem; Action_List_Edit: TAction; procedure actNop (Sender: TObject); procedure actFile_CloseExecute (Sender: TObject); procedure actFile_PropertyExecute (Sender: TObject); procedure actFileCmd_RenameExecute (Sender: TObject); procedure actFileCmd_MoveAsExecute (Sender: TObject); procedure actFileCmd_MoveExecute (Sender: TObject); procedure actFileCmd_CopyAsExecute (Sender: TObject); procedure actFileCmd_CopyExecute (Sender: TObject); procedure actFileCmd_TrashExecute (Sender: TObject); procedure actListEdit_CutExecute (Sender: TObject); procedure actListEdit_CopyExecute (Sender: TObject); procedure actListEdit_AppendCursorExecute(Sender: TObject); procedure actListEdit_DeleteExecute (Sender: TObject); procedure actListEdit_SelectAllExecute (Sender: TObject); procedure Action_SearchTitleExecute (Sender: TObject); procedure actInfo_CopyTitleExecute (Sender: TObject); procedure actListMoveExecute (Sender: TObject); procedure actListMove_UpExecute (Sender: TObject); procedure actSort_FileNameExecute (Sender: TObject); procedure actPlay_GoToItemIndexExecute (Sender: TObject); procedure actPlay_SelPlayExecute (Sender: TObject); procedure actFind_FindDownExecute (Sender: TObject); procedure actFind_FindMediaNameExecute (Sender: TObject); procedure actDisp_MediaInfoExecute (Sender: TObject); procedure actDisp_FontExecute (Sender: TObject); procedure actMenu_PopupPlaylistExecute (Sender: TObject); procedure actMenu_PopupPlayerExecute (Sender: TObject); procedure actWindow_PlayerExecute (Sender: TObject); procedure actEdit_UndoExecute (Sender: TObject); procedure actEdit_RedoExecute (Sender: TObject); procedure actEdit_CutExecute (Sender: TObject); procedure actEdit_CopyExecute (Sender: TObject); procedure actEdit_PasteExecute (Sender: TObject); procedure actEdit_DeleteExecute (Sender: TObject); procedure actEdit_SelectAllExecute(Sender: TObject); procedure actEdit_TabExecute (Sender: TObject); procedure FormCreate (Sender: TObject); procedure FormDestroy (Sender: TObject); procedure FormResize (Sender: TObject); procedure FormKeyUp (Sender: TObject; var Key: Word; Shift: TShiftState); procedure mnuEditPopup (Sender: TObject); procedure mnuPlayListPopup (Sender: TObject); procedure mnuSortPopup (Sender: TObject); procedure mnuInfoPopup (Sender: TObject); procedure mnuSearchPopup (Sender: TObject); procedure mnuSearch_SelectSitePopup (Sender: TObject); procedure mniAdvancedDrawItem (Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState); procedure mniFind_HistoryDrawItem (Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean); procedure mniSearch_SelectSiteClick (Sender: TObject); procedure imgIconMouseUp (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure imgExitButtonClick (Sender: TObject); procedure celPlaylistClick (Sender: TObject); procedure celPlaylistDblClick (Sender: TObject); procedure celPlaylistMouseWheel (Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); procedure celPlaylistDrawCell (Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); procedure celPlaylistKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState); procedure celPlaylistKeyUp (Sender: TObject; var Key: Word; Shift: TShiftState); procedure celPlaylistMouseDown (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure celPlaylistMouseMove (Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure celPlaylistMouseUp (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure celPlaylistSelectCell (Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); procedure celInfoDrawCell (Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); procedure edtToolFind_FindChange (Sender: TObject); procedure edtToolFind_FindKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState); procedure edtToolFind_FindKeyUp (Sender: TObject; var Key: Word; Shift: TShiftState); procedure edtToolFind_FindMouseUp (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure btnToolFind_FindHistoryClick (Sender: TObject); procedure btnToolFind_FindHistoryMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure btnToolSearchMouseDown (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Timer_StatusTimer (Sender: TObject); procedure Timer_StatusResetTimer (Sender: TObject); private { Private 宣言 } F_Player: TMyDSPlayer; F_bThrough : Boolean; F_bDrag : Boolean; //セルのリサイズ用 F_iClickItem : Integer; F_iColLeft : Integer; F_iSort : Integer; //現在のソートのキーになっている列 //0より大:昇順 //0: ソートなし //0未満: 降順 F_sSortMarker : String; //ソートマーカー F_iSelRow : Integer; //アイテム選択用 //タグ取得 FInfoUpdate : T_MyInfoUpdate; FbTagDone : Boolean; //送る FSendTo : TMySendTo; procedure F_BeginUpdate; procedure F_EndUpdate; procedure F_Sort(iColIndex: Integer); // function F_GetSelFiles: WideString; function F_SetEnabled(bEnabled: Boolean): Integer; function F_GetFocusEdit: TMyCustomEditControl; function F_GetFindCompareString(sStr: WideString): WideString; procedure F_AddFindHistory(MenuItem: TMenuItem; sText: WideString); procedure F_FindHistoryClick(Sender: TObject); procedure F_SelClear; function F_GetCheck(iRow : Integer) : Boolean; procedure F_SelCheck(iRow : Integer; bSelect : Boolean); procedure WMMouseWheel(var Msg: TWMMouseWheel); message WM_MOUSEWHEEL; procedure WMDropFiles (var Msg: TWMDropFiles); message WM_DROPFILES; // procedure WMDispInfo (var Msg: TMessage); message G_ciDISPINFO; public { Public 宣言 } // procedure DispInfo(iIndex: Integer); procedure ResetCount(bSortReset: Boolean); procedure AddFindHistory(MenuItem: TMenuItem; slList: TMyWStrings); procedure ResetSortMark; procedure SetSearchIndex(iIndex: Integer); //情報表示 procedure SetInfo (Sender : T_MyInfoGet; iIndex : Integer; ATag : TMyTag); procedure SetInfo2(Sender : T_MyInfoGet; iIndex : Integer; ATag : TMyTag); //タグ取得 procedure GetInfo(iIndex : Integer); procedure ReadTagFromLib(bStart : Boolean); procedure RestartReadTagFromLib; // function GetLibTag(var ATag : TMyTag; sFileName : WideString) : Boolean; procedure SetTag(iIndex : Integer; ATag : TMyTag; bUpdateList, bUpdateLibrary : Boolean); procedure EndSetTag; //タグ取得終了(中断もあり) procedure DoneSetTag; //タグ取得終了 property TagDone : Boolean read FbTagDone write FbTagDone; // function F_FindConvert (sText : WideString) : WideString; // function F_DBTextConvert(sText : WideString) : WideString; // procedure F_UpdateLibrary(ATag : TMyTag); end; var App_MEDIAPlaylist : TApp_MEDIAPlaylist; G_PlaylistForm : TApp_MEDIAPlaylist; const lcsDB_FILENAME = '.library.sqlite3'; const lcsDBCOL_FILE_NAME = 'FILE_NAME'; lcsDBCOL_FILE_SIZE = 'FILE_SIZE'; lcsDBCOL_FILE_WRITETIME = 'FILE_WRITETIME'; lcsDBCOL_FILE_CREATETIME = 'FILE_CREATETIME'; lcsDBCOL_MEDIA_LENGTH = 'MEDIA_LENGTH'; lcsDBCOL_MEDIA_DURATION = 'MEDIA_DURATION'; lcsDBCOL_VIDEO_WIDTH = 'VIDEO_WIDTH'; lcsDBCOL_VIDEO_HEIGHT = 'VIDEO_HEIGHT'; lcsDBCOL_VIDEO_FRAMERATE = 'VIDEO_FRAMERATE'; lcsDBCOL_TAG_ARTIST = 'TAG_ARTIST'; lcsDBCOL_TAG_ALBUM = 'TAG_ALBUM'; lcsDBCOL_TAG_ALBUMARTIST = 'TAG_ALBUMARTIST'; lcsDBCOL_TAG_COMPOSER = 'TAG_COMPOSER'; lcsDBCOL_TAG_CONDUCTOR = 'TAG_CONDUCTOR'; lcsDBCOL_TAG_GENRE = 'TAG_GENRE'; lcsDBCOL_TAG_TITLE = 'TAG_TITLE'; lcsDBCOL_TAG_TRACK = 'TAG_TRACK'; lcsDBCOL_TAG_WRITER = 'TAG_WRITER'; { lcsDBCOL_FIND_ARTIST = 'FIND_ARTIST'; lcsDBCOL_FIND_ALBUM = 'FIND_ALBUM'; lcsDBCOL_FIND_ALBUMARTIST = 'FIND_ALBUMARTIST'; lcsDBCOL_FIND_COMPOSER = 'FIND_COMPOSER'; lcsDBCOL_FIND_CONDUCTOR = 'FIND_CONDUCTOR'; lcsDBCOL_FIND_GENRE = 'FIND_GENRE'; lcsDBCOL_FIND_TITLE = 'FIND_TITLE'; lcsDBCOL_FIND_TRACK = 'FIND_TRACK'; lcsDBCOL_FIND_WRITER = 'FIND_WRITER'; } implementation uses {$IFDEF DEBUG} myDebug, {$ENDIF} ShellAPI, CommCtrl, ComObj, Clipbrd, WMPLib_TLB, myApp, myClipbrd, myControl, myFile, myFileProgress, myMenu, myMediaProperty, myMessageBox, myMessagePanel, myMonitor, myNum, mySearch, myString, myWindow, main; {$R *.dfm} const lciMARGIN = 2; const //ソート&表示用 lciCOL_NO = 0; lciCOL_MEDIANAME = 1; lciCOL_MEDIAPATH = 2; //ソート用。表示はしない lciCOL_FILENAME = 100; lciCOL_MEDIAEXT = 101; lciCOL_FILESIZE = 102; lciCOL_FILEWRITETIME = 103; lciCOL_FILECREATETIME = 104; lciCOL_LENGTH = 110; lciCOL_VIDEOSIZE = 112; lciCOL_VIDEOFRAMERATE = 113; lciCOL_TRACK = 210; lciCOL_ARTIST = 211; lciCOL_ALBUM = 212; lciCOL_ALBUMARTIST = 213; lciCOL_TITLE = 214; lciCOL_COMPOSER = 215; lciCOL_WRITER = 216; lciCOL_CONDUCTOR = 217; lciCOL_GENRE = 218; lciCOL_SHUFFLE = 300; lciCOL_SORTNONE = 1024; //ソートマークの削除用 const lciCOL_ITEM = 0; lciCOL_VALUE = 1; lciROW_TITLE = 0; lciROW_ARTIST = 1; lciROW_ALBUM = 2; lciROW_FILEINFO = 3; //------------------------------------------------------------------------------ procedure TApp_MEDIAPlaylist.WMDropFiles(var Msg: TWMDropFiles); begin G_MainForm.WMDropFiles(Msg); end; { procedure TApp_MEDIAPlaylist.WMDispInfo(var Msg: TMessage); begin //メディア情報表示 if (actDisp_MediaInfo.Checked) then begin DispInfo(celPlayList.DataRow); end; end; } function TApp_MEDIAPlaylist.F_SetEnabled(bEnabled: Boolean): Integer; begin if (bEnabled) then begin Screen.Cursor := crDefault; end else begin Screen.Cursor := crHourGlass; end; Result := G_MainForm.SetFormEnabled(bEnabled); end; procedure TApp_MEDIAPlaylist.F_BeginUpdate; begin //タグ取得中止。 ReadTagFromLib(False); celPlaylist.BeginUpdate; F_Player.Items.BeginUpdate; end; procedure TApp_MEDIAPlaylist.F_EndUpdate; begin celPlaylist.EndUpdate; F_Player.Items.EndUpdate; //中断したタグ取得を再開する。 RestartReadTagFromLib; end; procedure TApp_MEDIAPlaylist.FormCreate(Sender: TObject); var lh_Menu : hMenu; begin F_bThrough := False; F_bDrag := False; F_iClickItem := -1; F_iColLeft := 1; Randomize; G_PlaylistForm := Self; F_Player := G_MainForm.plyMedia; info_get.G_Strings := F_Player.Items; //デフォルトは真ん中に gpcMonitorCenterPosSet(Self, gfnptMousePosGet); F_bThrough := False; //メニュー 最大化、最小化は必要ないので消去 lh_Menu := GetSystemMenu(Handle, False); DeleteMenu(lh_Menu, SC_RESTORE, MF_BYCOMMAND); //元のサイズに戻す DeleteMenu(lh_Menu, SC_MINIMIZE, MF_BYCOMMAND); //最小化 DeleteMenu(lh_Menu, SC_MAXIMIZE, MF_BYCOMMAND); //最大化 DeleteMenu(lh_Menu, 2, MF_BYPOSITION); //区切り線 DrawMenuBar(lh_Menu); gpcMenuShortCutDel(mnuPlaylist); pnlToolBar.Height := ToolBar_Playlist.ButtonHeight +1; celPlaylist.Align := alClient; celPlaylist.DefaultRowHeight := gfniRoundUp(gfniGridCanvasTextHeight(celPlaylist) * 1.4); celPlaylist.ColWidths[lciCOL_NO] := gfniGridCanvasTextWidth(celPlaylist, '1000'); celPlaylist.ColWidths[lciCOL_MEDIANAME] := (gfniGridCellWidthsGet(celPlaylist) - celPlaylist.ColWidths[lciCOL_NO]) div 2; F_iSort := 0; with celInfo do begin Cells[lciCOL_ITEM, lciROW_TITLE] := 'タイトル'; Cells[lciCOL_ITEM, lciROW_ARTIST] := 'アーティスト'; Cells[lciCOL_ITEM, lciROW_ALBUM] := 'アルバム'; Cells[lciCOL_ITEM, lciROW_FILEINFO] := 'ファイル情報'; ColWidths[lciCOL_ITEM] := gfniGridCanvasTextWidth(celInfo, Cells[lciCOL_ITEM, lciROW_FILEINFO]) + lciMARGIN * 2; end; //送る FSendTo := TMySendTo.Create(Self); // FSendTo.OnOpenFileFolder := FSendToOpenFileFolder; // FSendTo.OnSelectProgram := FSendToSelectProgram; FSendTo.AddMenuItem(MenuItem_PSendTo); FSendTo.CreateSendToMenu; DragAcceptFiles(Handle, True); end; procedure TApp_MEDIAPlaylist.FormDestroy(Sender: TObject); //破棄 begin ReadTagFromLib(False); Timer_Status.Enabled := False; Timer_StatusReset.Enabled := False; DragAcceptFiles(Handle, False); end; procedure TApp_MEDIAPlaylist.FormResize(Sender: TObject); //リサイズ begin //lciCOL_PATHとlciCOL_NAMEは使わず直接1や2を指定すること celPlaylist.ColWidths[2] := gfniGridCellWidthsGet(celPlaylist) - celPlaylist.ColWidths[lciCOL_NO] - celPlaylist.ColWidths[1]; celInfo.ColWidths[1] := gfniGridCellWidthsGet(celInfo) - celInfo.ColWidths[0]; end; //------------------------------------------------------------------------------ procedure TApp_MEDIAPlaylist.actFile_PropertyExecute(Sender: TObject); //プロパティ var i: Integer; begin //プロパティ try if (F_Player.Count > 0) then begin for i := celPlaylist.DataSelection.Top to celPlaylist.DataSelection.Bottom do begin G_MainForm.FileProperty(F_Player.Items[i]); end; end; except on E: Exception do begin gpcShowMessage(E.Message); end; end; end; procedure TApp_MEDIAPlaylist.actFile_CloseExecute(Sender: TObject); begin Close; end; procedure TApp_MEDIAPlaylist.actFileCmd_RenameExecute(Sender: TObject); //ファイル名の変更 var i, li_Index: Integer; begin G_MainForm.SetFormEnabled(False); try //タグ取得中止 ReadTagFromLib(False); for i := 0 to gfniGridSelectRowCount(celPlaylist) -1 do begin li_Index := celPlaylist.DataSelection.Top +i; G_MainForm.FileRename(li_Index); if (F_Player.playState = gciPLAYSTATE_STOPPED) then begin F_Player.Play(li_Index); end; end; finally //中断したタグ取得を再開する。 RestartReadTagFromLib; G_MainForm.SetFormEnabled(True); end; end; procedure TApp_MEDIAPlaylist.actFileCmd_MoveAsExecute(Sender: TObject); //名前を付けて移動 var i, li_Index: Integer; lb_Playing : Boolean; begin G_MainForm.SetFormEnabled(False); try //タグ取得中止 ReadTagFromLib(False); for i := 0 to gfniGridSelectRowCount(celPlaylist) -1 do begin li_Index := celPlaylist.DataSelection.Top +i; lb_Playing := (F_Player.ItemIndex = li_Index) and (F_Player.playState = gciPLAYSTATE_PLAYING); G_MainForm.dlgFileCmd_FileMove.Owner := Self; G_MainForm.FileMoveAs(li_Index, True); if (lb_Playing) and (F_Player.PlayState = gciPLAYSTATE_STOPPED) then begin F_Player.Play(li_Index); end; end; finally //中断したタグ取得を再開する。 RestartReadTagFromLib; G_MainForm.SetFormEnabled(True); end; end; procedure TApp_MEDIAPlaylist.actFileCmd_MoveExecute(Sender: TObject); //移動 var i, li_Index: Integer; ls_Path : WideString; lb_Playing : Boolean; begin with G_MainForm do begin SetFormEnabled(False); try //タグ取得中止 ReadTagFromLib(False); dlgFileCmd_FileMove.Owner := Self; if (dlgFileCmd_FileMove.Execute) then begin dlgFileCmd_FileMove.InitialDir := dlgFileCmd_FileMove.FolderName; ls_Path := WideUpperCase(dlgFileCmd_FileMove.FolderName); for i := 0 to gfniGridSelectRowCount(celPlaylist)-1 do begin li_Index := celPlaylist.DataSelection.Top +i; lb_Playing := (F_Player.ItemIndex = li_Index) and (F_Player.playState = gciPLAYSTATE_PLAYING); if (ls_Path = WideUpperCase(gfnsFilePathGet(F_Player.Items[li_Index]))) then begin //同じフォルダならエラー gpcShowMessage(WideFormat('%s'#13'同じフォルダには移動できません', [dlgFileCmd_FileMove.FolderName]), dlgFileCmd_FileMove.Title + ' - ' + gfnsProductNameGet); end else begin dlgFileCmd_FileMoveAs.FileName := dlgFileCmd_FileMove.FolderName + gfnsFileNameGet(F_Player.Items[li_Index]); FileMoveAs(li_Index, False); // if not(F_Player.playState = gciPLAYSTATE_PLAYING) then begin // F_Player.Play;//(li_Play); if (lb_Playing) and (F_Player.PlayState = gciPLAYSTATE_STOPPED) then begin F_Player.Play(li_Index); end; end; end; end; finally //中断したタグ取得を再開する。 RestartReadTagFromLib; SetFormEnabled(True); end; end; end; procedure TApp_MEDIAPlaylist.actFileCmd_CopyAsExecute(Sender: TObject); //名前をつけてファイルコピー var i, li_Index: Integer; begin //コピーの場合はタグ情報取得の一時中止は必要ない G_MainForm.SetFormEnabled(False); try for i := 0 to gfniGridSelectRowCount(celPlaylist) -1 do begin li_Index := celPlaylist.Selection.Top +i -1; //ヘッダー分で-1 if (G_MainForm.FileSaveAs(li_Index, True)) and (li_Index = F_Player.ItemIndex) then begin F_Player.Play(li_Index); end; end; finally G_MainForm.SetFormEnabled(True); end; end; procedure TApp_MEDIAPlaylist.actFileCmd_CopyExecute(Sender: TObject); //ファイルコピー var i, li_Index: Integer; ls_Path: WideString; begin //コピーの場合はタグ情報取得の一時中止は必要ない with G_MainForm do begin SetFormEnabled(False); try if (dlgFileCmd_FileCopy.Execute) then begin dlgFileCmd_FileCopy.InitialDir := dlgFileCmd_FileCopy.FolderName; ls_Path := WideUpperCase(dlgFileCmd_FileCopy.FolderName); for i := 0 to gfniGridSelectRowCount(celPlaylist) -1 do begin li_Index := celPlaylist.Selection.Top +i -1; //ヘッダー分で-1 if (ls_Path = WideUpperCase(gfnsFilePathGet(F_Player.Items[li_Index]))) then begin //同じフォルダならエラー gpcShowMessage(WideFormat('%s'#13'同じフォルダにはコピーできません', [dlgFileCmd_FileCopy.FolderName]), dlgFileCmd_FileCopy.Title + ' - ' + gfnsProductNameGet); end else begin dlgFileCmd_FileCopyAs.FileName := dlgFileCmd_FileCopy.FolderName + gfnsFileNameGet(F_Player.Items[li_Index]); if (FileSaveAs(li_Index, False)) and (li_Index = F_Player.ItemIndex) then begin // F_Player.Play(li_Index); end; end; end; end; finally SetFormEnabled(True); end; end; end; procedure TApp_MEDIAPlaylist.actFileCmd_TrashExecute(Sender: TObject); //ごみ箱へ var i, li_Top, li_Index: Integer; begin G_MainForm.SetFormEnabled(False); try //タグ取得中止 ReadTagFromLib(False); if (celPlayList.Selection.Top > 0) and (gfniMessageBoxYesNo('選択ファイルをメディアから削除します'#13'よろしいですか', MB_DEFBUTTON2) = IDYES) // and (gfniMessageBoxYesNo(F_GetSelFiles + 'ファイルをディスクから削除します'#13#13'よろしいですか', MB_DEFBUTTON2) = IDYES) then begin //タグ取得を中止。 ReadTagFromLib(False); SetActiveWindow(Self.Handle); li_Top := celPlaylist.DataSelection.Top; F_BeginUpdate; try for i := gfniGridSelectRowCount(celPlaylist)-1 downto 0 do begin li_Index := li_Top +i; G_MainForm.FileDelete(li_Index, False); end; finally F_EndUpdate; end; ResetCount(False); celPlaylistClick(nil); mnuPlaylistPopup(nil); //中断したタグ取得を再開する。 RestartReadTagFromLib; end; finally //中断したタグ取得を再開する。 RestartReadTagFromLib; G_MainForm.SetFormEnabled(True); end; if (Screen.ActiveControl = celPlaylist) and (celPlaylist.CanFocus) then begin celPlaylist.SetFocus; end; end; procedure TApp_MEDIAPlaylist.actListEdit_CutExecute(Sender: TObject); //切り取り var l_List: TMyWStrings; i: Integer; begin l_List := TMyWStrings.Create; try F_BeginUpdate; try for i := celPlaylist.DataSelection.Bottom downto celPlaylist.DataSelection.Top do begin l_List.Insert(0, F_Player.Items[i]); F_Player.Items.Delete(i); end; gpcStrToClipboard(l_List.Text); ResetCount(False); finally F_EndUpdate; end; finally l_List.Free; end; end; procedure TApp_MEDIAPlaylist.actListEdit_CopyExecute(Sender: TObject); //ファイル名をコピー var i: Integer; l_List : TMyWStrings; ls_File : WideString; begin if (Screen.ActiveForm = G_MainForm) then begin //メインフォームから呼ばれた ls_File := F_Player.FileName; if (Sender = actListEdit_CopyMediaName) then begin ls_File := gfnsFileNameGet(ls_File); end else if (Sender = actListEdit_CopyMediaPath) then begin ls_File := gfnsFilePathGet(ls_File); end else if (Sender = actListEdit_CopyMainFileName) then begin ls_File := gfnsFileMainGet(ls_File); end; gpcStrToClipboard(ls_File); Exit; end; l_List := nil; try l_List := TMyWStrings.Create; for i := celPlaylist.DataSelection.Top to celPlaylist.DataSelection.Bottom do begin ls_File := F_Player.Items[i]; if (Sender = actListEdit_CopyMediaName) then begin ls_File := gfnsFileNameGet(ls_File); end else if (Sender = actListEdit_CopyMediaPath) then begin ls_File := gfnsFilePathGet(ls_File); end else if (Sender = actListEdit_CopyMainFileName) then begin ls_File := gfnsFileMainGet(ls_File); end; l_List.Add(ls_File); end; gpcStrToClipboard(l_List.Text); finally l_List.Free; end; end; procedure TApp_MEDIAPlaylist.actListEdit_AppendCursorExecute(Sender: TObject); //カーソル行の後に追加 var lsl_List: TMyWStrings; li_Top: Integer; begin lsl_List := TMyWStrings.Create; try li_Top := celPlaylist.TopRow; lsl_List.Text := gfnsStrFromClipboard; F_SetEnabled(False); F_BeginUpdate; try if (F_Player.Count = 0) then begin F_Player.Items.AddStrings(lsl_List); end else begin F_Player.Items.InsertStrings(celPlaylist.DataRow+1, lsl_List); end; ResetCount(True); celPlaylist.TopRow := li_Top; finally F_EndUpdate; F_SetEnabled(True); end; finally lsl_List.Free; end; end; { function TApp_WallvideoSpPlaylist.F_GetSelFiles: WideString; //選択ファイルを列挙 const lci_DISPCOUNT = 9; var i, li_Loop, li_Count: Integer; begin li_Count := celPlaylist.Selection.Bottom - celPlaylist.Selection.Top; li_Loop := gfniNumLimit(li_Count, 0, lci_DISPCOUNT); for i := 0 to li_Loop do begin Result := WideFormat('%s'#13'%s', [Result, F_Player.Items[celPlaylist.Selection.Top +i -1]]); //ヘッダー分で-1 end; Result := TrimLeft(Result); if (li_Count > lci_DISPCOUNT) then begin Result := Result + #13#13 + WideFormat('他 全%dファイル', [li_Count +1]); end; Result := Result + #13; end; } procedure TApp_MEDIAPlaylist.ResetCount(bSortReset: Boolean); //リストの行数調整 begin celPlaylist.ColWidths[0] := celPlaylist.Canvas.TextWidth(IntToStr(gfniMax([F_Player.Count, 1000]))) + (lciMARGIN * 2); //マージン*2 celPlaylist.DataRowCount := gfniMax([F_Player.Count, 1]); //少なくともデータ部は1行必要 G_MainForm.ResetCount; mnuPlaylistPopup(nil); if (bSortReset) then begin F_iSort := 0; //ソートしていない状態とする //昇順・降順のマーカーのリセット F_Sort(lciCOL_SORTNONE); end; celPlaylist.Repaint; end; procedure TApp_MEDIAPlaylist.actListEdit_DeleteExecute(Sender: TObject); //リストから削除 var i: Integer; li_Index: Integer; begin if (celPlayList.Selection.Top > 0) // and (gfniMessageBoxYesNo('選択ファイルをリストから削除しますか') = IDYES) // and (gfniMessageBoxYesNo(F_GetSelFiles + 'リストから削除しますか') = IDYES) then begin F_SetEnabled(False); F_BeginUpdate; try li_Index := -1; for i := celPlaylist.DataSelection.Bottom downto celPlaylist.DataSelection.Top do begin if (i = F_Player.ItemIndex) then begin li_Index := F_Player.ItemIndex; F_Player.Stop; end; F_Player.Items.Delete(i); end; if (li_Index >= 0) then begin F_Player.Play(F_Player.NextItemIndex(0)); end; finally F_EndUpdate; if (F_SetEnabled(True) = 0) then begin ResetCount(False); celPlaylistClick(nil); mnuPlaylistPopup(nil); if (Screen.ActiveControl = celPlaylist) then begin celPlaylist.SetFocus; end; end; end; end; end; procedure TApp_MEDIAPlaylist.actListEdit_SelectAllExecute(Sender: TObject); //すべて選択 var lr_Grid: TGridRect; begin lr_Grid.Left := 1; lr_Grid.Top := 1; //ヘッダー分で1 lr_Grid.Right := celPlaylist.ColCount -1; lr_Grid.Bottom := celPlaylist.RowCount -1; celPlayList.Selection := lr_Grid; mnuPlaylistPopup(nil); end; procedure TApp_MEDIAPlaylist.actListMoveExecute(Sender: TObject); begin ToolBar_Move.Visible := actListMove.Checked; end; procedure TApp_MEDIAPlaylist.actListMove_UpExecute(Sender: TObject); var i, li_Shift: Integer; lr_Grid: TGridRect; begin if (F_Player.Count = 0) or (((Sender = actListMove_Up) or (Sender = actListMove_10Up) or (Sender = actListMove_100Up) or (Sender = actListMove_Top)) and (celPlaylist.DataSelection.Top = 0)) or (((Sender = actListMove_Down) or (Sender = actListMove_10Down) or (Sender = actListMove_100Down) or (Sender = actListMove_Bottom)) and (celPlaylist.DataSelection.Bottom = celPlaylist.RowCount -1)) then begin Beep; Exit; end; //移動する行数を得る if (Sender = actListMove_Up) or (Sender = actListMove_10Up) or (Sender = actListMove_100Up) or (Sender = actListMove_Top) then begin if (Sender = actListMove_Up) then begin //Shiftなし li_Shift := 1; end else if (Sender = actListMove_Top) then begin //トップへ li_Shift := celPlaylist.Selection.Top -1; end else begin li_Shift := celPlaylist.Selection.Top -1; if (Sender = actListMove_10Up) then begin //10上 li_Shift := gfniNumLimit(li_Shift, 0, 10); end else if (Sender = actListMove_100Up) then begin //100上 li_Shift := gfniNumLimit(li_Shift, 0, 100); end else begin // li_Shift := 0; Exit; end; end; end else begin if (Sender = actListMove_Down) then begin li_Shift := -1; end else if (Sender = actListMove_Bottom) then begin //ボトムへ li_Shift := -((celPlaylist.RowCount -1) - celPlaylist.Selection.Bottom); end else begin li_Shift := -(celPlaylist.RowCount - celPlaylist.Selection.Bottom); if (Sender = actListMove_10Down) then begin //10下 li_Shift := gfniNumLimit(li_Shift, -10, 0); end else if (Sender = actListMove_100Down) then begin //100下 li_Shift := gfniNumLimit(li_Shift, -100, 0); end else begin // li_Shift := 0; Exit; end; end; end; if (li_Shift <> 0) then begin //タグ取得中止。 ReadTagFromLib(False); F_BeginUpdate; try if (li_Shift > 0) then begin for i := celPlaylist.Selection.Top -1 to celPlaylist.Selection.Bottom -1 do begin F_Player.Items.Move(i, i - li_Shift); end; end else begin for i := celPlaylist.Selection.Bottom -1 downto celPlaylist.Selection.Top -1 do begin F_Player.Items.Move(i, i - li_Shift); end; end; lr_Grid := celPlaylist.Selection; Dec(lr_Grid.Top, li_Shift); Dec(lr_Grid.Bottom, li_Shift); celPlaylist.Selection := lr_Grid; finally F_EndUpdate; end; ResetSortMark; celPlayList.Repaint; //中断したタグ取得を再開する。 RestartReadTagFromLib; end; end; procedure TApp_MEDIAPlaylist.actPlay_GoToItemIndexExecute(Sender: TObject); //再生中のファイルへ移動 var l_Rect: TGridRect; begin if (F_Player.ItemIndex >= 0) then begin if not(gfnbKeyState(VK_SHIFT)) then begin celPlaylist.DataRow := F_Player.ItemIndex; l_Rect.Left := 0; //lciCOL_NO +1; l_Rect.Top := celPlaylist.DataRow; l_Rect.Right := celPlaylist.DataColCount-1; l_Rect.Bottom := celPlaylist.DataRow; celPlaylist.DataSelection := l_Rect; celPlaylistClick(nil); end; celPlaylist.DataTopRow := gfniNumLimit(F_Player.ItemIndex, 0, celPlaylist.RowCount - celPlaylist.VisibleRowCount -1); end; end; procedure TApp_MEDIAPlaylist.actPlay_SelPlayExecute(Sender: TObject); //選択項目を再生 begin if (edtToolFind_Find.Focused) then begin actFind_FindDownExecute(actFind_FindDown); end else begin F_Player.Play(F_Player.Items[celPlayList.DataRow]); end; end; procedure TApp_MEDIAPlaylist.celPlaylistDblClick(Sender: TObject); var lpt_Pos: TPoint; li_Col, li_Row: Longint; begin lpt_Pos := celPlaylist.ScreenToClient(gfnptMousePosGet); celPlaylist.MouseToCell(lpt_Pos.X, lpt_Pos.Y, li_Col, li_Row); if (li_Row > 0) then begin Sleep(100); Application.ProcessMessages; actPlay_SelPlayExecute(Sender); end; end; procedure TApp_MEDIAPlaylist.mniAdvancedDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState); //オーナー描画 begin myMenu.MenuItem_AdvancedDrawItem(Sender, ACanvas, ARect, State); end; procedure TApp_MEDIAPlaylist.mnuPlayListPopup(Sender: TObject); //ポップアップ begin actListEdit_SelectAll.Enabled := F_Player.Items.Count > 0; actListEdit_Delete.Enabled := (F_Player.Count > 0) and (celPlaylist.SelectRowCount > 0); actListEdit_Cut.Enabled := actListEdit_Delete.Enabled; actListEdit_Copy.Enabled := actListEdit_Delete.Enabled; actListEdit_CopyFileName.Enabled := actListEdit_Copy.Enabled; actListEdit_CopyMediaPath.Enabled := actListEdit_Copy.Enabled; actListEdit_CopyMediaName.Enabled := actListEdit_Copy.Enabled; actListEdit_CopyMainFileName.Enabled := actListEdit_Copy.Enabled; actListEdit_AppendCursor.Enabled := Clipboard.HasFormat(CF_TEXT); actFile_Property.Enabled := actListEdit_Delete.Enabled; actPlay_SelPlay.Enabled := actListEdit_Delete.Enabled; actPlay_GoToItemIndex.Enabled := F_Player.ItemIndex >= 0; //プレイヤー側で対処 // actListMove.Enabled := actListEdit_Delete.Enabled; actListMove_Up.Enabled := actListEdit_Delete.Enabled; actListMove_Down.Enabled := actListMove_Up.Enabled; actListMove_10Up.Enabled := actListMove_Up.Enabled; actListMove_10Down.Enabled := actListMove_Up.Enabled; actListMove_100Up.Enabled := actListMove_Up.Enabled; actListMove_100Down.Enabled := actListMove_Up.Enabled; actListMove_Top.Enabled := actListMove_Up.Enabled; actListMove_Bottom.Enabled := actListMove_Up.Enabled; //ソート mnuSortPopup(nil); //ネット検索 mnuInfoPopup(nil); gpcSetMenuDefault(mniPSearch_SelectSite); //ファイル操作 actFileCmd.Enabled := actListEdit_Delete.Enabled; actFileCmd_Rename.Enabled := actFileCmd.Enabled; actFileCmd_MoveAs.Enabled := actFileCmd.Enabled; actFileCmd_CopyAs.Enabled := actFileCmd.Enabled; actFileCmd_Move.Enabled := actFileCmd.Enabled; actFileCmd_Copy.Enabled := actFileCmd.Enabled; actFileCmd_Trash.Enabled := actFileCmd.Enabled; //送る // App_Wallvideo.CreateSendToMenu; // mniPSendTo.Enabled := actListEdit_Delete.Enabled; end; procedure TApp_MEDIAPlaylist.mnuSortPopup(Sender: TObject); begin //ソート actSort.Enabled := (F_Player.Items.Count > 1); actSort_Album.Enabled := actSort.Enabled; actSort_AlbumArtist.Enabled := actSort.Enabled; actSort_Artist.Enabled := actSort.Enabled; actSort_Composer.Enabled := actSort.Enabled; actSort_Conductor.Enabled := actSort.Enabled; actSort_Genre.Enabled := actSort.Enabled; actSort_Title.Enabled := actSort.Enabled; actSort_Track.Enabled := actSort.Enabled; actSort_Writer.Enabled := actSort.Enabled; actSort_Length.Enabled := actSort.Enabled; actSort_VideoSize.Enabled := actSort.Enabled; actSort_VideoFrameRate.Enabled := actSort.Enabled; actSort_FileName.Enabled := actSort.Enabled; actSort_MediaPath.Enabled := actSort.Enabled; actSort_MediaName.Enabled := actSort.Enabled; actSort_MediaExt.Enabled := actSort.Enabled; actSort_FileSize.Enabled := actSort.Enabled; actSort_FileWriteTime.Enabled := actSort.Enabled; actSort_FileCreateTime.Enabled := actSort.Enabled; actSort_Shuffle.Enabled := actSort.Enabled; end; //ソート procedure TApp_MEDIAPlaylist.ResetSortMark; begin F_iSort := lciCOL_SORTNONE; F_Sort(F_iSort); end; procedure TApp_MEDIAPlaylist.F_Sort(iColIndex: Integer); procedure lpc_SetCaption(l_Action: TAction; bAscending: Boolean); begin if (actSort_PartOf.Checked) then begin if (bAscending) then begin F_sSortMarker := ' △'; end else begin F_sSortMarker := ' ▽'; end; end else begin if (bAscending) then begin F_sSortMarker := ' ▲'; end else begin F_sSortMarker := ' ▼'; end; end; l_Action.Caption := l_Action.Caption + F_sSortMarker; end; var lb_Ascending : Boolean; li_Start : Integer; li_End : Integer; i : Integer; li_Pos : Integer; l_Action : TAction; begin if not(TagDone) then begin case iColIndex of lciCOL_NO, lciCOL_MEDIANAME, lciCOL_MEDIAPATH, lciCOL_MEDIAEXT, lciCOL_FILENAME, lciCOL_FILESIZE, lciCOL_FILEWRITETIME, lciCOL_FILECREATETIME, lciCOL_SHUFFLE, lciCOL_SORTNONE :begin //これらはタグ情報を取得済みでなくともソートできるのでメッセージは出さない。 //ただしファイルサイズと更新日時、作成日時は比較の度にファイルから情報を //取得するので大量のディスクアクセスが発生する。 //とはいえ今どきのOSならキャッシュに収まるのではないかなと。 end; else begin //タグ情報が完全ではないので確認メッセージを出す if (gfniMessageBoxYesNo('タグ情報の取得が完了していません'#13'不足分の情報は空のままソートされます'#13'ソートを続行しますか') <> ID_YES) then begin Exit; end; end; end; end; F_SetEnabled(False); try //昇順・降順のマーカーの削除 for i := 0 to ActionList1.ActionCount-1 do begin l_Action := TAction(ActionList1.Actions[i]); if (l_Action.Category = 'ソート') then begin li_Pos := Pos(' ', WideString(l_Action.Caption)); if (li_Pos > 0) then begin l_Action.Caption := Copy(WideString(l_Action.Caption), 1, li_Pos-1); end; end; end; if (iColIndex = lciCOL_SORTNONE) then begin Exit; end; if (actSort_PartOf.Checked) then begin if (celPlaylist.SelectRowCount <= 1) then begin //部分ソートで選択された項目が1未満。 Exit; end; li_Start := celPlaylist.DataSelection.Top; li_End := celPlaylist.DataSelection.Bottom; end else begin li_Start := 0; li_End := -1; end; //タグ取得中止 ReadTagFromLib(False); if (F_Player.Items.Count > 1) and (iColIndex >= 0) then begin Timer_StatusReset.Enabled := False; Self.Caption := 'リストを並べ替えています'; Timer_Status.Enabled := True; if (F_iSort > 0) and (iColIndex = Abs(F_iSort)) then begin //昇順だったので降順に切り替える F_iSort := -(iColIndex); end else begin F_iSort := iColIndex; end; lb_Ascending := (F_iSort >= 0); with F_Player do begin case iColIndex of lciCOL_FILENAME :begin Items.SortFileName(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_FileName, lb_Ascending); end; lciCOL_MEDIANAME :begin Items.SortMediaName(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_MediaName, lb_Ascending); end; lciCOL_MEDIAPATH :begin Items.SortMediaPath(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_MediaPath, lb_Ascending); end; lciCOL_MEDIAEXT :begin Items.SortMediaExt(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_MediaExt, lb_Ascending); end; lciCOL_FILESIZE :begin Items.SortFileSize(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_FileSize, lb_Ascending); end; lciCOL_FILEWRITETIME :begin Items.SortFileWriteTime(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_FileWriteTime, lb_Ascending); end; lciCOL_FILECREATETIME :begin Items.SortFileCreateTime(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_FileCreateTime, lb_Ascending); end; lciCOL_LENGTH :begin Items.SortMediaDuration(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_Length, lb_Ascending); end; lciCOL_VIDEOSIZE :begin Items.SortVideoSize(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_VideoSize, lb_Ascending); end; lciCOL_VIDEOFRAMERATE :begin Items.SortVideoFrameRate(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_VideoFrameRate, lb_Ascending); end; lciCOL_ALBUM :begin Items.SortAlbum(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_Album, lb_Ascending); end; lciCOL_ALBUMARTIST :begin Items.SortAlbumArtist(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_AlbumArtist, lb_Ascending); end; lciCOL_ARTIST :begin Items.SortArtist(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_Artist, lb_Ascending); end; lciCOL_COMPOSER :begin Items.SortComposer(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_Composer, lb_Ascending); end; lciCOL_CONDUCTOR :begin Items.SortConductor(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_Conductor, lb_Ascending); end; lciCOL_GENRE :begin Items.SortGenre(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_Genre, lb_Ascending); end; lciCOL_TITLE :begin Items.SortTitle(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_Title, lb_Ascending); end; lciCOL_TRACK :begin Items.SortTrack(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_Track, lb_Ascending); end; lciCOL_WRITER :begin Items.SortWriter(lb_Ascending, li_Start, li_End); lpc_SetCaption(actSort_Writer, lb_Ascending); end; lciCOL_SHUFFLE :begin Items.Shuffle(li_Start, li_End); F_iSort := 0; end; end; end; Timer_StatusTimer(nil); Timer_Status.Enabled := False; Self.Caption := 'リストを並べ替えました'; Timer_StatusReset.Enabled := True; actPlay_GoToItemIndexExecute(nil); //中断したタグ取得を再開する。 RestartReadTagFromLib; end; // actPlay_GoToItemIndexExecute(nil); celPlaylist.Repaint; finally if (F_SetEnabled(True) = 0) then begin if (Screen.ActiveControl = celPlaylist) then begin celPlaylist.SetFocus; end; end; end; end; procedure TApp_MEDIAPlaylist.actSort_FileNameExecute(Sender: TObject); begin if (F_Player.Count = 0) then begin Exit; //AIU end; if (Sender = actSort_Shuffle) then F_Sort(lciCOL_SHUFFLE) //シャッフル else if (Sender = actSort_FileName) then F_Sort(lciCOL_FILENAME) //ファイル名でソート else if (Sender = actSort_MediaName) then F_Sort(lciCOL_MEDIANAME) //名前でソート else if (Sender = actSort_MediaPath) then F_Sort(lciCOL_MEDIAPATH) //場所でソート else if (Sender = actSort_MediaExt) then F_Sort(lciCOL_MEDIAEXT) //種類でソート else if (Sender = actSort_FileSize) then F_Sort(lciCOL_FILESIZE) //ファイルサイズでソート else if (Sender = actSort_FileWriteTime) then F_Sort(lciCOL_FILEWRITETIME) //ファイルの更新日でソート else if (Sender = actSort_FileCreateTime) then F_Sort(lciCOL_FILECREATETIME) //ファイルの作成日でソート else if (Sender = actSort_Length) then F_Sort(lciCOL_LENGTH) //長さでソート else if (Sender = actSort_VideoSize) then F_Sort(lciCOL_VIDEOSIZE) //ビデオの大きさでソート else if (Sender = actSort_VideoFrameRate) then F_Sort(lciCOL_VIDEOFRAMERATE) //ビデオのフレームレートでソート else if (Sender = actSort_Album) then F_Sort(lciCOL_ALBUM) //アルバム名でソート else if (Sender = actSort_AlbumArtist) then F_Sort(lciCOL_ALBUMARTIST) //アルバムのアーティストでソート else if (Sender = actSort_Artist) then F_Sort(lciCOL_ARTIST) //アーティストでソート else if (Sender = actSort_Composer) then F_Sort(lciCOL_COMPOSER) //作曲家でソート else if (Sender = actSort_Conductor) then F_Sort(lciCOL_CONDUCTOR) //指揮者でソート else if (Sender = actSort_Genre) then F_Sort(lciCOL_GENRE) //ジャンルでソート else if (Sender = actSort_Title) then F_Sort(lciCOL_TITLE) //タイトルでソート else if (Sender = actSort_Track) then F_Sort(lciCOL_TRACK) //トラック番号でソート else if (Sender = actSort_Writer) then F_Sort(lciCOL_WRITER) //作詞家でソート end; //------------------------------------------------------------------------------ procedure TApp_MEDIAPlaylist.GetInfo(iIndex : Integer); var l_InfoGet: T_MyInfoGet; begin l_InfoGet := T_MyInfoGet.Create(iIndex, F_Player.Items[iIndex]); if (l_InfoGet = nil) then begin Beep; //ダミー end; end; procedure TApp_MEDIAPlaylist.celPlaylistClick(Sender: TObject); begin if (celPlayList.Row > 0) and (F_Player.Count > 0) then begin //送る FSendTo.Arg := F_Player.Items[celPlayList.DataRow]; GetInfo(celPlayList.DataRow); end else begin Exit; end; end; procedure TApp_MEDIAPlaylist.SetInfo(Sender: T_MyInfoGet; iIndex: Integer; ATag: TMyTag); var l_Tag : TMyTag; begin with celInfo do begin Cells[1, lciROW_TITLE] := ''; Cells[1, lciROW_ARTIST] := ''; Cells[1, lciROW_ALBUM] := ''; Cells[1, lciROW_FILEINFO] := ''; end; if (iIndex = celPlaylist.DataRow) then begin if (ATag = nil) then begin l_Tag := TMyTag(F_Player.Items.Objects[iIndex]); end else begin l_Tag := ATag; end; if (WideUpperCase(F_Player.Items[iIndex]) = WideUpperCase(l_Tag.FileName)) then begin //タイトル celInfo.Cells[1, lciROW_TITLE] := gfnsWideToAnsiEx(l_Tag.Title); //アーティスト celInfo.Cells[1, lciROW_ARTIST] := gfnsWideToAnsiEx(l_Tag.Artist); if (l_Tag.OriginalArtist <> '') then begin celInfo.Cells[1, lciROW_ARTIST] := celInfo.Cells[1, lciROW_ARTIST] + '//' + gfnsWideToAnsiEx(l_Tag.OriginalArtist); end; //アルバム celInfo.Cells[1, lciROW_ALBUM] := gfnsWideToAnsiEx(l_Tag.Album); if (l_Tag.OriginalAlbum <> '') then begin celInfo.Cells[1, lciROW_ALBUM] := celInfo.Cells[1, lciROW_ALBUM] + '//' + gfnsWideToAnsiEx(l_Tag.OriginalAlbum); end; end; end else begin Sender.Terminate; end; end; procedure TApp_MEDIAPlaylist.SetInfo2(Sender: T_MyInfoGet; iIndex: Integer; ATag : TMyTag); var l_Tag : TMyTag; ls_Info: WideString; begin if (iIndex = celPlaylist.DataRow) then begin if (F_Player.Items.Objects[iIndex] = nil) then begin if (ATag = nil) then begin Exit; end; l_Tag := TMyTag.Create; F_Player.Items.Objects[iIndex] := l_Tag; end else begin l_Tag := TMyTag(F_Player.Items.Objects[iIndex]); end; if (ATag <> nil) then begin l_Tag.Assign(ATag); end; if (WideUpperCase(F_Player.Items[iIndex]) = WideUpperCase(l_Tag.FileName)) then begin if (gfnbFileExists(l_Tag.FileName)) then begin //ファイル情報 ls_Info := WideFormat('%s %s秒 (%s)', [l_Tag.FileSizeString, gfnsSecToTimeStr(l_Tag.MediaDuration, 3), l_Tag.FileWriteTimeString]); if (l_Tag.VideoWidth > 0) and (l_Tag.VideoHeight > 0) then begin ls_Info := WideFormat('%s %dx%d', [ls_Info, l_Tag.VideoWidth, l_Tag.VideoHeight]); end; if (l_Tag.VideoFrameRate > 0) then begin ls_Info := ls_Info + Format(' %.2ffps', [l_Tag.VideoFrameRate]); end; end else begin ls_Info := 'ファイルが存在しません'; end; celInfo.Cells[1, lciROW_FILEINFO] := ls_Info; end; end else begin Sender.Terminate; end; end; procedure TApp_MEDIAPlaylist.RestartReadTagFromLib; begin if not(FbTagDone) and (G_MainForm.actList_ReadTag.Checked) then begin //タグ取得を途中でやめたので再開する ReadTagFromLib(True); end; end; procedure TApp_MEDIAPlaylist.ReadTagFromLib(bStart : Boolean); var l_FreeUpdate : T_MyInfoUpdate; ls_DBFile : WideString; begin if (bStart) then begin ReadTagFromLib(False); ls_DBFile := gfnsFileExtChange(gfnsExeNameGet, '') + lcsDB_FILENAME; FInfoUpdate := T_MyInfoUpdate.Create(ls_DBFile); end else begin if (FInfoUpdate <> nil) then begin l_FreeUpdate := FInfoUpdate; FInfoUpdate := nil; l_FreeUpdate.Priority := tpNormal; //必須。ないとしばらく応答不能になる。 l_FreeUpdate.Terminate; l_FreeUpdate.Free; end; end; end; procedure TApp_MEDIAPlaylist.SetTag(iIndex : Integer; ATag : TMyTag; bUpdateList, bUpdateLibrary : Boolean); //ATagがnilでなければリストの更新は必要なのでbUpdateListは本来不要。 //ただbUpdateLibraryとの関係で、あった方が分かりやすかろうということで。 var l_CreateTag : TMyTag; begin //AIU if (ATag = nil) then begin Exit; end; if (WideUpperCase(F_Player.Items[iIndex]) = WideUpperCase(ATag.FileName)) then begin //myDebug.gpcDebug(Timer_Library.Enabled); // Self.Caption := Format('タグ取得中[%d/%d] %s', [iIndex +1, F_Player.Count, gfnsFileNameGet(F_Player.Items[iIndex])]); Self.Caption := Format('タグ取得中[%d/%d] %s', [iIndex +1, F_Player.Count, F_Player.Items[iIndex]]); if (F_Player.Items.Objects[iIndex] = nil) then begin l_CreateTag := TMyTag.Create; l_CreateTag.Assign(ATag); F_Player.Items.Objects[iIndex] := l_CreateTag; //myDebug.gpcDebug([iIndex, TMyTag(F_Player.Items.Objects[iIndex]).FileName]); end else begin; TMyTag(F_Player.Items.Objects[iIndex]).Assign(ATag); end; //今はまだ必要ない // if (gfnbIsGridRowVisible(celPlaylist, iIndex)) then begin // gpcGridDrawRow(celPlaylist, iIndex); // end; end; end; procedure TApp_MEDIAPlaylist.EndSetTag; begin //NG! ReadTagFromLib(False); Timer_StatusResetTimer(nil); end; procedure TApp_MEDIAPlaylist.DoneSetTag; begin FbTagDone := True; //NG! F_InfoUpdate.WaitForで止まってしまうようだ ReadTagFromLib(False); Timer_StatusResetTimer(nil); end; procedure TApp_MEDIAPlaylist.WMMouseWheel(var Msg: TWMMouseWheel); var l_Msg: TMessage; begin if not(GetFocus <> celPlaylist.Handle) then begin Exit; end; FillChar(l_Msg, SizeOf(l_Msg), 0); if (Msg.WheelDelta > 0) then begin l_Msg.WParamLo := SB_LINEUP; end else begin l_Msg.WParamLo := SB_LINEDOWN; end; l_Msg.Result := 0; SendMessage(celPlaylist.Handle, WM_VSCROLL, l_Msg.WParam, l_Msg.LParam); end; procedure TApp_MEDIAPlaylist.celPlaylistMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); //スクロールをリストボックスと同じように var l_Msg: TMessage; begin FillChar(l_Msg, SizeOf(l_Msg), 0); if (WheelDelta > 0) then begin l_Msg.WParamLo := SB_LINEUP; end else begin l_Msg.WParamLo := SB_LINEDOWN; end; l_Msg.Result := 0; SendMessage(celPlaylist.Handle, WM_VSCROLL, l_Msg.WParam, l_Msg.LParam); Handled := True; end; procedure TApp_MEDIAPlaylist.celPlaylistDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); //描画 var ls_Value : WideString; lrc_Rect : TRect; lpt_Pos : TPoint; lr_Grid : TGridCoord; l_Color : TColor; begin // if (F_bThrough) then Exit; // F_bThrough := True; with celPlaylist.Canvas do begin Pen.Color := clBtnShadow; // Font.Assign(celPlaylist.Font); if (ACol = 0) then begin if (ARow > 0) and (F_Player.ItemIndex = (ARow-1)) then begin Brush.Color := celPlaylist.Font.Color; Font.Color := celPlaylist.FixedColor; end else begin Brush.Color := celPlaylist.FixedColor; Font.Color := celPlaylist.Font.Color; end; end else if (ARow = 0) then begin Brush.Color := celPlaylist.FixedColor; Font.Color := celPlaylist.Font.Color; end else if (gdSelected in State) then begin // end else if (celPlaylist.Cells[0, ARow] <> '') then begin Brush.Color := clHighLight; Font.Color := clHighLightText; end else begin // Brush.Color := celPlaylist.Color; // Font.Color := celPlaylist.Font.Color; Brush.Color := clWindow; Font.Color := clWindowText; end; FillRect(Rect); lrc_Rect := Rect; if (ARow = 0) then begin //ヘッダー case (ACol) of lciCOL_NO: ls_Value := ''; lciCOL_MEDIANAME: ls_Value := '名前'; lciCOL_MEDIAPATH: ls_Value := '場所'; else ls_Value := ''; //AIU end; if (ACol > 0) and (Abs(F_iSort) = ACol) then begin if (F_iSort > 0) then begin ls_Value := ls_Value + F_sSortMarker; //' ▲' end else if (F_iSort < 0) then begin ls_Value := ls_Value + F_sSortMarker; //' ▼' end; end; if (ACol = lciCOL_NO) then begin Dec(lrc_Rect.Right, lciMARGIN); DrawTextW(Handle, PWideChar(ls_Value), -1, lrc_Rect, DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER or DT_CENTER); end else begin //マウスが押されていたらくぼむように描画 if (gfnbKeyState(VK_LBUTTON)) then begin lpt_Pos := celPlaylist.ScreenToClient(gfnptMousePosGet); lr_Grid := celPlaylist.MouseCoord(lpt_Pos.X, lpt_Pos.Y); if (lr_Grid.Y = 0) and (lr_Grid.X = ACol) and (lpt_Pos.Y >= 0) then begin Inc(lrc_Rect.Left, 2); Inc(lrc_Rect.Top, 2); MoveTo(Rect.Left, Rect.Top); LineTo(Rect.Left, Rect.Bottom); MoveTo(Rect.Left, Rect.Top); LineTo(Rect.Right, Rect.Top); end; end; Inc(lrc_Rect.Left, lciMARGIN); Font.Assign(Self.Font); DrawTextW(Handle, PWideChar(ls_Value), -1, lrc_Rect, DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER or DT_END_ELLIPSIS); end; MoveTo(Rect.Left, Rect.Bottom -1); LineTo(Rect.Right, Rect.Bottom -1); end else begin case (ACol) of lciCOL_NO: ls_Value := IntToStr(ARow); lciCOL_MEDIANAME: ls_Value := gfnsFileNameGet(F_Player.Items[ARow-1]); //ヘッダー分で-1 lciCOL_MEDIAPATH: ls_Value := gfnsFileDirGet (F_Player.Items[ARow-1]); //ヘッダー分で-1 else ls_Value := ''; end; case (ACol) of lciCOL_NO :begin //右寄せ Dec(lrc_Rect.Right, lciMARGIN); DrawTextW(Handle, PWideChar(ls_Value), -1, lrc_Rect, DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER or DT_RIGHT); end; lciCOL_MEDIANAME :begin Inc(lrc_Rect.Left, lciMARGIN); DrawTextW(Handle, PWideChar(ls_Value), -1, lrc_Rect, DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER); end; lciCOL_MEDIAPATH :begin Inc(lrc_Rect.Left, lciMARGIN); DrawTextW(Handle, PWideChar(ls_Value), -1, lrc_Rect, DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER); end; else begin // Inc(lrc_Rect.Left, lciMARGIN); // DrawTextW(Handle, PWideChar(ls_Value), -1, lrc_Rect, DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER); end; end; if (F_Player.ItemIndex = (ARow-1)) then begin //再生中のメディアならラインを引く l_Color := Pen.Color; Pen.Color := celPlaylist.Font.Color; MoveTo(Rect.Left, Rect.Top); LineTo(Rect.Right, Rect.Top); MoveTo(Rect.Left, Rect.Bottom-1); LineTo(Rect.Right, Rect.Bottom-1); Pen.Color := l_Color; end; end; MoveTo(Rect.Right-1, Rect.Top); LineTo(Rect.Right-1, Rect.Bottom); end; // Application.ProcessMessages; //NG シフト+方向キー押しっぱなしで固まる // F_bThrough := False; end; //タグ情報描画 procedure TApp_MEDIAPlaylist.celInfoDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin with celInfo.Canvas do begin Font.Assign(celInfo.Font); Brush.Color := celInfo.Color; Font.Color := celInfo.Font.Color; FillRect(Rect); Inc(Rect.Left, lciMARGIN); DrawTextW(Handle, PWideChar(gfnsAnsiToWideEx(celInfo.Cells[ACol, ARow])), -1, Rect, DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER); end; end; //何もしない procedure TApp_MEDIAPlaylist.actNop(Sender: TObject); begin //Nop end; //ステータス procedure TApp_MEDIAPlaylist.Timer_StatusTimer(Sender: TObject); begin Timer_StatusReset.Enabled := False; Timer_Status.Enabled := False; if (Self.Caption <> F_Player.Items.ProgressMessage) then begin Self.Caption := F_Player.Items.ProgressMessage; Application.ProcessMessages; end; Timer_Status.Enabled := True; // Timer_StatusReset.Enabled := True; end; procedure TApp_MEDIAPlaylist.Timer_StatusResetTimer(Sender: TObject); begin Timer_Status.Enabled := False; Timer_StatusReset.Enabled := False; Self.Caption := 'プレイリスト'; end; //メニューアイコンクリックでメニューポップアップ procedure TApp_MEDIAPlaylist.imgIconMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin G_MainForm.IsPlayer := False; actMenu_PopupPlayerExecute(nil); // App_Wallvideo.mniPFile.Tag := -1; // App_Wallvideo.mnuPopup.Popup(pnlWindow.ClientOrigin.X, pnlWindow.ClientOrigin.Y); // mnuPopup.Popup(pnlWindow.ClientOrigin.X, pnlWindow.ClientOrigin.Y); end; // 編集 ------------------------------------------------------------------------ procedure TApp_MEDIAPlaylist.mnuEditPopup(Sender: TObject); begin if (Application.Terminated) then Exit; //編集 actEdit_Undo.Enabled := gfnbEditCanUndo(edtToolFind_Find.Edit.Handle); actEdit_Redo.Enabled := gfnbEditCanRedo(edtToolFind_Find.Edit.Handle); actEdit_Copy.Enabled := gfnbEditSelected(edtToolFind_Find.Edit.Handle); actEdit_Cut.Enabled := actEdit_Copy.Enabled; actEdit_Delete.Enabled := actEdit_Cut.Enabled; actEdit_Paste.Enabled := (gfnsStrFromClipboard <> ''); actEdit_SelectAll.Enabled := not(edtToolFind_Find.Empty); //検索 actFind_FindDown.Enabled := (edtToolFind_Find.Text <> ''); actFind_FindUp.Enabled := actFind_FindDown.Enabled; end; function TApp_MEDIAPlaylist.F_GetFocusEdit: TMyCustomEditControl; //フォーカスのあるエディットボックスを返す begin if (edtToolFind_Find.Focused) then begin Result := edtToolFind_Find.Edit; end else begin Result := nil; end; end; procedure TApp_MEDIAPlaylist.actEdit_UndoExecute(Sender: TObject); //元に戻す begin if (F_GetFocusEdit <> nil) then begin F_GetFocusEdit.Undo; end; end; procedure TApp_MEDIAPlaylist.actEdit_RedoExecute(Sender: TObject); //やり直し begin if (F_GetFocusEdit <> nil) then begin F_GetFocusEdit.Redo; end; end; procedure TApp_MEDIAPlaylist.actEdit_CutExecute(Sender: TObject); //切り取り begin if (F_GetFocusEdit <> nil) then begin F_GetFocusEdit.CutToClipboard; end; end; procedure TApp_MEDIAPlaylist.actEdit_CopyExecute(Sender: TObject); //コピー begin if (F_GetFocusEdit <> nil) then begin F_GetFocusEdit.CopyToClipboard; end; end; procedure TApp_MEDIAPlaylist.actEdit_PasteExecute(Sender: TObject); //貼り付け begin if (F_GetFocusEdit <> nil) then begin F_GetFocusEdit.PasteFromClipboard; end; end; procedure TApp_MEDIAPlaylist.actEdit_DeleteExecute(Sender: TObject); //削除 begin if (F_GetFocusEdit <> nil) then begin F_GetFocusEdit.ClearSelection; end; end; procedure TApp_MEDIAPlaylist.actEdit_SelectAllExecute(Sender: TObject); //全て選択 begin if (F_GetFocusEdit <> nil) then begin F_GetFocusEdit.SelectAll; end; end; procedure TApp_MEDIAPlaylist.actEdit_TabExecute(Sender: TObject); //Tabの入力 begin if (F_GetFocusEdit = edtToolFind_Find.Edit) then begin celPlaylist.SetFocus; end else begin edtToolFind_Find.SetFocus; end; end; //------------------------------------------------------------------------------ //検索 function TApp_MEDIAPlaylist.F_GetFindCompareString(sStr: WideString): WideString; //比較用の文字列を返す var lp_Buff: PWideChar; li_Map: DWORD; li_Len: Integer; begin Result := sStr; //http://msdn.microsoft.com/ja-jp/library/cc448052.aspx li_Map := LCMAP_UPPERCASE or LCMAP_LINGUISTIC_CASING //大文字と小文字の区別に、ファイルシステムの規則(既定値)ではなく、言語上の規則を使います。 or LCMAP_FULLWIDTH or LCMAP_KATAKANA // or LCMAP_SIMPLIFIED_CHINESE //中国語の繁体字を簡体字にマップします。 // or LCMAP_SORTKEY //正規化されたワイド文字並び替えキーを作成します。 ; //変換後の文字数を取得 li_Len := LCMapStringW(GetUserDefaultLCID(), li_Map, PWideChar(Result), -1, nil, 0); lp_Buff := AllocMem((li_Len +1) * 2); try //変換する LCMapStringW(GetUserDefaultLCID(), li_Map, PWideChar(Result), -1, lp_Buff, li_Len); Result := WideString(lp_Buff); finally FreeMem(lp_Buff); end; end; procedure TApp_MEDIAPlaylist.actFind_FindDownExecute(Sender: TObject); //検索実行 function lfnb_Compare(sFind: WideString; iIndex: Integer): Boolean; var ls_Find : WideString; l_Tag : TMyTag; begin Result := False; ls_Find := ''; if (actFind_FindFileName.Checked) then begin ls_Find := F_Player.Items[iIndex]; end else if (actFind_FindMediaName.Checked) then begin ls_Find := gfnsFileNameGet(F_Player.Items[iIndex]); end else if (actFind_FindMediaPath.Checked) then begin ls_Find := gfnsFilePathGet(F_Player.Items[iIndex]); end else begin l_Tag := TMyTag(F_Player.Items.Objects[iIndex]); if (l_Tag = nil) then begin //タグ未所得 Exit; end else if (actFind_FindArtist.Checked) then begin ls_Find := l_Tag.Artist; end else if (actFind_FindAlbum.Checked) then begin ls_Find := l_Tag.Album; end else if (actFind_FindTitle.Checked) then begin ls_Find := l_Tag.Title; end else if (actFind_FindComposer.Checked) then begin ls_Find := l_Tag.Composer; end else if (actFind_FindWriter.Checked) then begin ls_Find := l_Tag.Writer; end else if (actFind_FindConductor.Checked) then begin ls_Find := l_Tag.Conductor; end; end; Result := (Pos(sFind, F_GetFindCompareString(ls_Find)) > 0); end; var i, li_Index, li_Start: Integer; ls_Find: WideString; begin if (edtToolFind_Find.Text = '') then begin Beep; Exit; end; //履歴に追加 F_AddFindHistory(mnuFind_FindHistory.Items, edtToolFind_Find.Text); li_Index := celPlaylist.Row-1; ls_Find := F_GetFindCompareString(edtToolFind_Find.Text); if (Sender = actFind_FindUp) then begin if (gfnbKeyState(VK_CONTROL)) then begin li_Start := F_Player.Count-1; end else begin li_Start := li_Index-1; end; for i := li_Start downto 0 do begin if (lfnb_Compare(ls_Find, i)) then begin celPlaylist.Row := i+1; //ヘッダー分で+1; Exit; end; end; end else begin if (gfnbKeyState(VK_CONTROL)) then begin li_Start := 0; end else begin li_Start := li_Index+1; end; for i := li_Start to F_Player.Count-1 do begin if (lfnb_Compare(ls_Find, i)) then begin celPlaylist.Row := i+1; //ヘッダー分で+1; Exit; end; end; end; Beep; //見つからなかった //gpcShowMessage('見つからなかった'); end; procedure TApp_MEDIAPlaylist.edtToolFind_FindMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var lpt_Pos: TPoint; begin if (Button = mbRight) then begin lpt_Pos := gfnptMousePosGet; mnuEdit.Popup(lpt_Pos.X, lpt_Pos.Y); end; end; procedure TApp_MEDIAPlaylist.edtToolFind_FindKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin G_MainForm.FormKeyDown(Sender, Key, Shift); //メディアプレーヤーの専用キーに対応 case Key of VK_DOWN, VK_UP, VK_RETURN: begin Key := 0; end; end; end; procedure TApp_MEDIAPlaylist.edtToolFind_FindKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); //検索ボックスでの↑↓入力 begin G_MainForm.FormKeyUp(Sender, Key, Shift); //メディアプレーヤーの専用キーに対応 case Key of VK_F3: begin //検索 if (ssShift in Shift) then begin actFind_FindDownExecute(actFind_FindUp); //上方検索 end else begin actFind_FindDownExecute(actFind_FindDown); //上方検索 end; Key := 0; end; VK_DOWN, VK_RETURN: begin actFind_FindDownExecute(actFind_FindDown); //下方検索 Key := 0; end; VK_UP: begin actFind_FindDownExecute(actFind_FindUp); //上方検索 Key := 0; end; { // 検索対象選択 Ord('N'): begin if (ssCtrl in Shift) then begin actFind_FindMediaNameExecute(actFind_FindMediaName); end; end; Ord('H'): begin if (ssCtrl in Shift) then begin actFind_FindMediaNameExecute(actFind_FindMediaPath); end; end; Ord('L'): begin if (ssCtrl in Shift) then begin actFind_FindMediaNameExecute(actFind_FindFileName); end; end; } VK_F10: begin if (ssShift in Shift) then begin actMenu_PopupPlaylistExecute(nil); end else begin actMenu_PopupPlayerExecute(nil); // App_Wallvideo.mnuPopup.Popup(pnlWindow.ClientOrigin.X, pnlWindow.ClientOrigin.Y); end; Key := 0; end; VK_APPS: begin actMenu_PopupPlaylistExecute(nil); //アプリケーションキー。ポップアップメニューをポップアップ Key := 0; end; Ord('F'), //検索オン・オフ Ord('W'), //ウィンドウ移動 Ord('G') //再生中のファイルへ移動 : begin if (ssCtrl in Shift) then begin celPlaylistKeyUp(Sender, Key, Shift); end; end; end; end; procedure TApp_MEDIAPlaylist.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); begin //メディアプレーヤーの専用キーに対応 G_MainForm.FormKeyUp(Sender, Key, Shift); end; procedure TApp_MEDIAPlaylist.celPlaylistKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin G_MainForm.FormKeyDown(Sender, Key, Shift); end; procedure TApp_MEDIAPlaylist.celPlaylistKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); var lb_Popup: Boolean; i: Integer; begin G_MainForm.FormKeyUp(Sender, Key, Shift); case Key of //検索 VK_F :begin if (ssCtrl in Shift) then begin if (edtToolFind_Find.Focused) then begin celPlaylist.SetFocus; end else begin edtToolFind_Find.SetFocus; end; end; end; VK_F3 :begin edtToolFind_FindKeyUp(Sender, Key, Shift); end; //再生中のファイルへ移動 VK_G :begin if (ssCtrl in Shift) then begin actPlay_GoToItemIndexExecute(nil); end; end; //ウィンドウ切り替え VK_W :begin if (ssCtrl in Shift) then begin lb_Popup := False; for i := 0 to Screen.FormCount-1 do begin if (Screen.Forms[i] is TApp_MediaProperty) and (Screen.Forms[i].Visible) then begin lb_Popup := True; Break; end; end; if (lb_Popup) then begin G_MainForm.mnuWindow.Popup(Self.ClientOrigin.X, Self.ClientOrigin.Y); end else begin G_MainForm.BringToFront; end; end; end; //ソート VK_S :begin if (ssCtrl in Shift) then begin mnuSort.Popup(celPlaylist.ClientOrigin.X, celPlaylist.ClientOrigin.Y + celPlaylist.DefaultRowHeight); end; end; VK_RETURN :begin if (G_MainForm.mnuWindow.Tag = 1) then begin G_MainForm.mnuWindow.Tag := 0; end else begin actPlay_SelPlayExecute(nil); end; end; VK_F10 :begin if (ssShift in Shift) then begin actMenu_PopupPlaylistExecute(nil); end else begin actMenu_PopupPlayerExecute(nil); end; Key := 0; end; VK_APPS :begin actMenu_PopupPlaylistExecute(nil); //アプリケーションキー。ポップアップメニューをポップアップ Key := 0; end; VK_PRIOR, VK_NEXT, VK_END, VK_HOME, VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN :begin celPlaylistClick(Sender); end; end; end; procedure TApp_MEDIAPlaylist.edtToolFind_FindChange(Sender: TObject); //下方検索・上方検索のEnabled調整 begin if (csReadingState in Self.ControlState) then Exit; actFind_FindDown.Enabled := (edtToolFind_Find.Text <> ''); actFind_FindUp.Enabled := actFind_FindDown.Enabled; end; procedure TApp_MEDIAPlaylist.mniFind_HistoryDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean); //検索リストメニュー描画 const lci_MARGIN = 6; begin with ACanvas do begin if (Selected) then begin Brush.Color := clHighlight; Font.Color := clHighlightText; end else begin Brush.Color := clMenu; Font.Color := clMenuText; end; FillRect(ARect); Inc(ARect.Left, lci_MARGIN); DrawTextW(Handle, PWideChar(gfnsAnsiToWideEx(TMenuItem(Sender).Caption)), -1, ARect, DT_SINGLELINE or DT_NOPREFIX or DT_VCENTER); end; end; procedure TApp_MEDIAPlaylist.F_FindHistoryClick(Sender: TObject); var l_MenuItem: TMenuItem; begin if not(Sender is TMenuItem) then Exit; l_MenuItem := TMenuItem(Sender); edtToolFind_Find.Text := gfnsAnsiToWideEx(l_MenuItem.Caption); edtToolFind_Find.Edit.CurrentCaret := edtToolFind_Find.Edit.Length; edtToolFind_Find.SetFocus; end; procedure TApp_MEDIAPlaylist.F_AddFindHistory(MenuItem: TMenuItem; sText: WideString); //検索履歴に追加 const lci_HISTORY = 10; var i: Integer; begin //履歴の最初がsTextなら処理を抜ける if (MenuItem.Count > 0) and (F_GetFindCompareString(gfnsAnsiToWideEx(MenuItem.Items[0].Caption)) = F_GetFindCompareString(sText)) then Exit; for i := MenuItem.Count -1 downto 1 do begin if (F_GetFindCompareString(gfnsAnsiToWideEx(MenuItem.Items[i].Caption)) = F_GetFindCompareString(sText)) then begin MenuItem.Items[i].Free; Break; end; end; //最後に追加ではなく頭に挿入 MenuItem.Insert(0, NewItem( gfnsWideToAnsiEx(sText), //Caption 0, //ShortCut False, //Checked True, //Enabled F_FindHistoryClick, //OnClickイベント 0, //HelpContext gfnsAvailableName(MenuItem.Name) //Name )); with MenuItem.Items[0] do begin OnDrawItem := mniFind_HistoryDrawItem; //Unicode対応のため end; if (MenuItem.Count > lci_HISTORY) then begin MenuItem.Items[MenuItem.Count -1].Free; //最後をFree end; end; procedure TApp_MEDIAPlaylist.AddFindHistory(MenuItem: TMenuItem; slList: TMyWStrings); var i: Integer; begin for i := 0 to slList.Count-1 do begin F_AddFindHistory(MenuItem, slList[i]); end; end; procedure TApp_MEDIAPlaylist.btnToolFind_FindHistoryClick(Sender: TObject); var // lpt_Pos: TPoint; l_SpeedButton: TSpeedButton; l_Popup: TPopupMenu; begin if not(Sender is TSpeedButton) then Exit; l_SpeedButton := TSpeedButton(Sender); l_Popup := l_SpeedButton.PopupMenu; if (l_Popup.Items.Count > 0) then begin // lpt_Pos := gfnptMousePosGet; // l_Popup.Popup(lpt_Pos.X, lpt_Pos.Y); l_Popup.Popup(l_SpeedButton.ClientOrigin.X, l_SpeedButton.ClientOrigin.Y + l_SpeedButton.Height); end; end; procedure TApp_MEDIAPlaylist.btnToolFind_FindHistoryMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var l_SpeedButton: TSpeedButton; begin if not(Sender is TSpeedButton) then Exit; l_SpeedButton := TSpeedButton(Sender); l_SpeedButton.PopupMenu.PopupComponent := l_SpeedButton; end; procedure TApp_MEDIAPlaylist.actFind_FindMediaNameExecute(Sender: TObject); begin if not(Sender is TAction) then begin Exit; end; TAction(Sender).Checked := True; end; procedure TApp_MEDIAPlaylist.imgExitButtonClick(Sender: TObject); begin Close; end; procedure TApp_MEDIAPlaylist.actMenu_PopupPlayerExecute(Sender: TObject); begin //リストから呼び出されたことのフラグとして使う G_MainForm.MenuItem_PFile.Tag := -1; G_MainForm.mnuPopup.Popup(Self.ClientOrigin.X, Self.ClientOrigin.Y); end; procedure TApp_MEDIAPlaylist.actMenu_PopupPlaylistExecute(Sender: TObject); begin if (edtToolFind_Find.Focused) then begin mnuEdit.Popup(shpToolFind_Find.ClientOrigin.X, shpToolFind_Find.ClientOrigin.Y + shpToolFind_Find.Height); end else begin mnuPlaylist.Popup(celPlaylist.ClientOrigin.X, celPlaylist.ClientOrigin.Y); end; end; procedure TApp_MEDIAPlaylist.actWindow_PlayerExecute(Sender: TObject); begin if (IsIconic(Application.Handle)) then begin Application.Restore; end; if (G_MainForm.CanFocus) then begin G_MainForm.SetFocus; end; end; procedure TApp_MEDIAPlaylist.actDisp_MediaInfoExecute(Sender: TObject); begin pnlInfo.Visible := actDisp_MediaInfo.Checked; end; procedure TApp_MEDIAPlaylist.actDisp_FontExecute(Sender: TObject); begin FontDialog1.Font.Assign(celPlaylist.Font); if (FontDialog1.Execute) then begin celPlaylist.Font.Assign(FontDialog1.Font); celPlaylist.DefaultRowHeight := gfniRoundUp(gfniGridCanvasTextHeight(celPlaylist) * 1.4); celPlaylist.Refresh; end; end; procedure TApp_MEDIAPlaylist.actInfo_CopyTitleExecute(Sender: TObject); var ls_Str: WideString; begin if (Sender = actInfo_CopyTitle) then begin ls_Str := celInfo.Cells[lciCOL_VALUE, lciROW_TITLE]; end else if (Sender = actInfo_CopyArtist) then begin ls_Str := celInfo.Cells[lciCOL_VALUE, lciROW_ARTIST]; end else if (Sender = actInfo_CopyAlbum) then begin ls_Str := celInfo.Cells[lciCOL_VALUE, lciROW_ALBUM]; end else begin ls_Str := ''; end; if (ls_Str <> '') then begin gpcStrToClipboard(gfnsAnsiToWideEx(ls_Str)); end; end; procedure TApp_MEDIAPlaylist.mnuInfoPopup(Sender: TObject); var l_Tag: TMyTag; begin actInfo_CopyTitle.Enabled := (celInfo.Cells[lciCOL_VALUE, lciROW_TITLE] <> ''); actInfo_CopyArtist.Enabled := (celInfo.Cells[lciCOL_VALUE, lciROW_ARTIST] <> ''); actInfo_CopyAlbum.Enabled := (celInfo.Cells[lciCOL_VALUE, lciROW_ALBUM] <> ''); if not(G_MainForm.IsPlayer) then begin l_Tag := TMyTag.Create(F_Player.Items[celPlaylist.DataRow]); try Action_SearchTitle.Enabled := (l_Tag.Title <> ''); Action_SearchArtist.Enabled := (l_Tag.Artist <> ''); Action_SearchAlbum.Enabled := (l_Tag.Album <> ''); Action_SearchWriter.Enabled := (l_Tag.Writer <> ''); Action_SearchComposer.Enabled := (l_Tag.Composer <> ''); Action_SearchConductor.Enabled := (l_Tag.Conductor <> ''); finally l_Tag.Free; end; end else begin Action_SearchTitle.Enabled := (F_Player.MediaTitle <> ''); Action_SearchArtist.Enabled := (F_Player.MediaArtist <> ''); Action_SearchAlbum.Enabled := (F_Player.MediaAlbum <> ''); Action_SearchWriter.Enabled := (F_Player.MediaWriter <> ''); Action_SearchComposer.Enabled := (F_Player.MediaComposer <> ''); Action_SearchConductor.Enabled := (F_Player.MediaConductor <> ''); end; gpcSetMenuDefault(mniPPSearch_SelectSite); end; procedure TApp_MEDIAPlaylist.btnToolSearchMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin G_MainForm.IsPlayer := False; end; procedure TApp_MEDIAPlaylist.Action_SearchTitleExecute(Sender: TObject); var ls_Str: WideString; l_Tag: TMyTag; begin ls_Str := ''; if not(G_MainForm.IsPlayer) then begin l_Tag := TMyTag.Create(F_Player.Items[celPlaylist.DataRow]); if (Sender = Action_SearchTitle) then begin ls_Str := l_Tag.Title; end else if (Sender = Action_SearchArtist) then begin ls_Str := l_Tag.Artist; end else if (Sender = Action_SearchAlbum) then begin ls_Str := l_Tag.Album; end else if (Sender = Action_SearchWriter) then begin ls_Str := l_Tag.Writer; end else if (Sender = Action_SearchComposer) then begin ls_Str := l_Tag.Composer; end else if (Sender = Action_SearchConductor) then begin ls_Str := l_Tag.Conductor; end; end else begin if (Sender = Action_SearchTitle) then begin ls_Str := F_Player.MediaTitle; end else if (Sender = Action_SearchArtist) then begin ls_Str := F_Player.MediaArtist; end else if (Sender = Action_SearchAlbum) then begin ls_Str := F_Player.MediaAlbum; end else if (Sender = Action_SearchWriter) then begin ls_Str := F_Player.MediaWriter; end else if (Sender = Action_SearchComposer) then begin ls_Str := F_Player.MediaComposer; end else if (Sender = Action_SearchConductor) then begin ls_Str := F_Player.MediaConductor; end; end; if (ls_Str <> '') then begin gpcSearch(gfnsAnsiToWideEx(ls_Str)); end; G_MainForm.IsPlayer := False; end; procedure TApp_MEDIAPlaylist.mniSearch_SelectSiteClick(Sender: TObject); //検索サイト選択のサブメニューのOnClickイベント var l_MenuItem: TMenuItem; begin if not(Sender is TMenuItem) then begin Exit; end; l_MenuItem := TMenuItem(Sender); SetSearchIndex(l_MenuItem.Tag); // l_MenuItem.Default := True; end; procedure TApp_MEDIAPlaylist.SetSearchIndex(iIndex: Integer); begin mySearch.G_SearchList.ItemIndex := iIndex; myMessagePanel.gpcMessagePanelBroadcast(WideFormat('/FROM:%d /SEARCHINDEX:%d', [G_MainForm.MyMessagePanel1.Handle, iIndex]), G_MainForm.MyMessagePanel1.Handle); end; procedure TApp_MEDIAPlaylist.mnuSearch_SelectSitePopup(Sender: TObject); begin gpcSetMenuDefault(mnuSearch_SelectSite.Items); end; procedure TApp_MEDIAPlaylist.mnuSearchPopup(Sender: TObject); begin gpcSetMenuDefault(mniPPPSearch_SelectSite); end; //アイテム選択 ----------------------------------------------------------------- procedure TApp_MEDIAPlaylist.celPlaylistMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var l_Grid : TDrawGrid; lr_Grid : TGridCoord; begin if (Button = mbLeft) then begin l_Grid := TDrawGrid(Sender); lr_Grid := l_Grid.MouseCoord(X, Y); if (lr_Grid.X > 0) then begin if (lr_Grid.Y = 0) then begin F_iClickItem := lr_Grid.X; l_Grid.OnDrawCell(Sender, lr_Grid.X, lr_Grid.Y, l_Grid.CellRect(lr_Grid.X, lr_Grid.Y), []); SetCapture(l_Grid.Handle); end else begin //OnMouseDownイベントはOnSelectCellイベントの後に起きる。 { F_iSelRow := lr_Grid.Y; myDebug.gpcDebug('MouseDown'); if (gfnbKeyState(VK_SHIFT)) then begin end else if (gfnbKeyState(VK_CONTROL)) then begin F_SelCheck(lr_Grid.Y, not(F_GetCheck(lr_Grid.Y))); end else begin F_SelClear; F_SelCheck(lr_Grid.Y, True); end; } end; end; end; end; procedure TApp_MEDIAPlaylist.celPlaylistMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var l_Grid: TDrawGrid; lr_Grid: TGridCoord; begin //***** 不要なイベントをスキップすることで効率化できる if (F_iClickItem > 0) and (gfnbKeyState(VK_LBUTTON)) then begin l_Grid := TDrawGrid(Sender); lr_Grid := l_Grid.MouseCoord(X, Y); l_Grid.OnDrawCell(Sender, F_iClickItem, 0, l_Grid.CellRect(F_iClickItem, 0), []); end; end; procedure TApp_MEDIAPlaylist.celPlaylistMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var lr_Grid: TGridCoord; lpt_Pos: TPoint; begin if (Button = mbLeft) then begin lr_Grid := celPlaylist.MouseCoord(X, Y); if (F_iClickItem > 0) then begin //ソート ReleaseCapture; celPlaylist.OnDrawCell(celPlaylist, F_iClickItem, 0, celPlaylist.CellRect(F_iClickItem, 0), []); Application.ProcessMessages; if (lr_Grid.X > 0) and (lr_Grid.X = F_iClickItem) and (lr_Grid.Y = 0) then begin F_Sort(F_iClickItem); end; F_iClickItem := -1; //↑の前に持っていってはいけない end else if (lr_Grid.X = 0) and (lr_Grid.Y = 0) then begin mnuSort.Popup(celPlaylist.ClientOrigin.X, celPlaylist.ClientOrigin.Y + celPlaylist.DefaultRowHeight); end else begin //クリック celPlaylistClick(Sender); FormResize(nil); end; F_iSelRow := -1; end else if (Button = mbRight) then begin lpt_Pos := gfnptMousePosGet; lr_Grid := celPlaylist.MouseCoord(X, Y); if (lr_Grid.Y = 0) then begin mnuSort.Popup(lpt_Pos.X, lpt_Pos.Y); end else begin mnuPlaylist.Popup(lpt_Pos.X, lpt_Pos.Y); end; end; end; procedure TApp_MEDIAPlaylist.F_SelClear; var i : Integer; begin for i := 1 to celPlaylist.RowCount -1 do begin celPlaylist.Cells[0, i] := ''; end; end; function TApp_MEDIAPlaylist.F_GetCheck(iRow : Integer) : Boolean; begin Result := celPlaylist.Cells[0, iRow] <> ''; end; procedure TApp_MEDIAPlaylist.F_SelCheck(iRow : Integer; bSelect : Boolean); begin if (bSelect) then begin celPlaylist.Cells[0, iRow] := '1'; end else begin celPlaylist.Cells[0, iRow] := ''; end; end; procedure TApp_MEDIAPlaylist.celPlaylistSelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); begin { CanSelect := False; if (F_iSelRow > 0) then begin F_SelCheck(ARow, True); end; } end; end.