unit list; {$DEFINE _DEBUG} interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, myListBox, Buttons, ExtCtrls, ActnList, Menus, CheckLst, Grids, ToolWin, AppCommand, myDShow, myEdit, mySendTo, myShape, myTag, myWStrings, info_get; type TApp_CheaPlayerList = class(TForm) ActionList1: TActionList; Action_File_Property: TAction; Action_FileCmd_Rename: TAction; Action_FileCmd: TAction; Action_FileCmd_Move: TAction; Action_FileCmd_Copy: TAction; Action_FileCmd_Trash: TAction; Action_FileCmd_RemoveFromHDD: TAction; Action_List_FolderName: TAction; Action_List_Copy: TAction; Action_List_Del: TAction; Action_List_SelectAll: TAction; Action_Play_Play: TAction; Action_Play_ItemIndex: TAction; Action_Edit_Undo: TAction; Action_Edit_Redo: TAction; Action_Edit_Cut: TAction; Action_Edit_Copy: TAction; Action_Edit_Paste: TAction; Action_Edit_Delete: TAction; Action_Edit_SelectAll: TAction; Action_Find_Down: TAction; Action_Find_Up: TAction; Action_Zoom_Capture: TAction; PopupMenu_Playlist: TPopupMenu; MenuItem_PPlayPlay: TMenuItem; MenuItem_PPlayItemIndex: TMenuItem; MenuItem_PListSelectAll: TMenuItem; MenuItem_PLine1: TMenuItem; MenuItem_PListDel: TMenuItem; PopupMenu_Edit: TPopupMenu; MenuItem_PEditUndo: TMenuItem; MenuItem_PEditRedo: TMenuItem; MenuItem_PEditLine1: TMenuItem; MenuItem_PEditCut: TMenuItem; MenuItem_PEditCopy: TMenuItem; MenuItem_PEditPaste: TMenuItem; MenuItem_PEditDelete: TMenuItem; MenuItem_PEditLine2: TMenuItem; MenuItem_PEditSelectAll: TMenuItem; MenuItem_PEditLine3: TMenuItem; MenuItem_PFindDown: TMenuItem; MenuItem_PFindUp: TMenuItem; PopupMenu_FindHistory: TPopupMenu; ToolBar_PlayList: TToolBar; ToolButton_File_OpenThisFolder: TToolButton; ToolButton_Spc1: TToolButton; ToolButton_List_FolderName: TToolButton; ToolButton_Sort: TToolButton; ToolButton_ListDel: TToolButton; ToolButton_ListClear: TToolButton; ToolButton_Spc2: TToolButton; Panel_Find: TPanel; Button_FindHistory: TSpeedButton; Shape_Find: TMyShape; Edit_Find: TMyEdit; ToolButton_FindDown: TToolButton; ToolButton_FindUp: TToolButton; ToolButton_Spc3: TToolButton; ToolButton_ZoomCapture: TToolButton; ToolButton_PlayItemIndex: TToolButton; ToolButton_FileProperty: TToolButton; ListBox_PlayList: TListBox; Grid_Info: TStringGrid; Shape_Info: TShape; PopupMenu_Sort: TPopupMenu; MenuItem_SSortFileName: TMenuItem; MenuItem_SSortPath: TMenuItem; MenuItem_SSortName: TMenuItem; MenuItem_SSortExt: TMenuItem; MenuItem_SSortLine1: TMenuItem; MenuItem_SSortShuffle: TMenuItem; MenuItem_PSort: TMenuItem; MenuItem_PSortFileName: TMenuItem; MenuItem_PSortPath: TMenuItem; MenuItem_PSortName: TMenuItem; MenuItem_PSortExt: TMenuItem; MenuItem_PSortLine1: TMenuItem; MenuItem_PSortShuffle: TMenuItem; MenuItem_PLine2: TMenuItem; MenuItem_PListCopy: TMenuItem; MenuItem_PLine3: TMenuItem; MenuItem_PFileCmd: TMenuItem; MenuItem_PFileCmdRename: TMenuItem; MenuItem_PFileCmdCopy: TMenuItem; MenuItem_PFileCmdMove: TMenuItem; MenuItem_PFileCmdLine1: TMenuItem; MenuItem_PFileCmdRemoveFromHDD: TMenuItem; MenuItem_PFileCmdTrash: TMenuItem; MenuItem_PSendTo: TMenuItem; ToolButton1: TToolButton; ToolButton2: TToolButton; MenuItem_PLine4: TMenuItem; MenuItem_File_Property: TMenuItem; MenuItem_List_Clear: TMenuItem; procedure actNop(Sender: TObject); procedure Action_File_PropertyExecute (Sender: TObject); procedure Action_FileCmd_RenameExecute (Sender: TObject); procedure Action_FileCmd_CopyExecute (Sender: TObject); procedure Action_FileCmd_MoveExecute (Sender: TObject); procedure Action_FileCmd_TrashExecute (Sender: TObject); procedure Action_List_CopyExecute (Sender: TObject); procedure Action_List_DelExecute (Sender: TObject); procedure Action_List_SelectAllExecute (Sender: TObject); procedure Action_List_FolderNameExecute(Sender: TObject); procedure Action_Play_PlayExecute (Sender: TObject); procedure Action_Play_ItemIndexExecute (Sender: TObject); procedure Action_Find_DownExecute (Sender: TObject); procedure Action_Edit_UndoExecute (Sender: TObject); procedure Action_Edit_RedoExecute (Sender: TObject); procedure Action_Edit_CutExecute (Sender: TObject); procedure Action_Edit_CopyExecute (Sender: TObject); procedure Action_Edit_PasteExecute (Sender: TObject); procedure Action_Edit_DeleteExecute (Sender: TObject); procedure Action_Edit_SelectAllExecute (Sender: TObject); procedure Action_Zoom_CaptureExecute (Sender: TObject); procedure PopupMenu_PlaylistPopup(Sender: TObject); procedure PopupMenu_EditPopup (Sender: TObject); procedure MenuItem_FindHistoryDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean); procedure MenuItem_FindHistoryClick (Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormResize(Sender: TObject); procedure ListBox_PlayListDrawItem (Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure ListBox_PlaylistClick (Sender: TObject); procedure Edit_FindChange (Sender: TObject); procedure Edit_FindKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure Edit_FindKeyUp (Sender: TObject; var Key: Word; Shift: TShiftState); procedure Button_FindHistoryClick(Sender: TObject); procedure Grid_InfoDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); private { Private 宣言 } FsFindText : WideString; //送る FSendTo : TMySendTo; procedure WMAppCommand(var Msg: TMessage); message WM_APPCOMMAND; function FGetFindText(sStr: WideString): WideString; procedure FAddFindHistory(AMenuItem: TMenuItem; sText: WideString); // procedure FSendToOpenFileFolder(Sender: TObject; var bReplace: Boolean); // procedure FSendToSelectProgram (Sender: TObject; var bReplace: Boolean); public { Public 宣言 } procedure AddFindHistory(AMenuItem: TMenuItem; AList: TMyWStrings); //情報表示 procedure SetInfo (Sender: T_MyInfoGet; iIndex: Integer; ATag: TMyTag); procedure SetInfo2(Sender: T_MyInfoGet; iIndex: Integer; ATag: TMyTag); procedure ItemIndexRefresh; end; var App_CheaPlayerList : TApp_CheaPlayerList; G_PlaylistForm : TApp_CheaPlayerList; implementation uses {$IFDEF _DEBUG} myDebug, {$ENDIF} myClipbrd, myControl, myFile, myGrid, myMenu, myMessageBox, myMonitor, myNum, mySize, myWindow, main; {$R *.dfm} const lciMARGIN = 2; const lciCOL_ITEM = 0; lciCOL_VALUE = 1; lciROW_TITLE = 0; lciROW_ARTIST = 1; lciROW_ALBUM = 2; lciROW_FILEINFO = 3; procedure TApp_CheaPlayerList.WMAppCommand(var Msg: TMessage); begin G_MainForm.WMAppCommand(Msg); end; procedure TApp_CheaPlayerList.FormCreate(Sender: TObject); var l_Monitor : TMonitor; lh_Menu : hMenu; begin //デフォルトは真ん中に。 G_PlaylistForm := Self; G_PlaylistStrings := G_MainForm.ComboBox_Playlist.Items; G_MainForm.SetCaption(Self, '再生リスト'); l_Monitor := gfnMonitorGet(gfnptMousePosGet); SetBounds( (gfniRectWidth (l_Monitor.WorkareaRect) - Width) div 2, (gfniRectHeight(l_Monitor.WorkareaRect) - Height) div 2, Width, Height ); Self.Icon := Application.Icon; ListBox_Playlist.Align := alClient; with Grid_Info 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(Grid_Info, Cells[lciCOL_ITEM, lciROW_FILEINFO]) + lciMARGIN * 2; end; //システムメニューの最大化、最小化は必要ないので削除。 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(PopupMenu_Playlist); //送る FSendTo := TMySendTo.Create(Self); // FSendTo.OnOpenFileFolder := FSendToOpenFileFolder; // FSendTo.OnSelectProgram := FSendToSelectProgram; FSendTo.AddMenuItem(MenuItem_PSendTo); FSendTo.CreateSendToMenu; end; procedure TApp_CheaPlayerList.FormResize(Sender: TObject); begin //lciCOL_PATHとlciCOL_NAMEは使わず直接1や2を指定すること Grid_Info.ColWidths[1] := gfniGridCellWidthsGet(Grid_Info) - Grid_Info.ColWidths[0]; end; { procedure TApp_CheaPlayerList.Header_PlaylistDrawSection(HeaderControl: THeaderControl; Section: THeaderSection; const Rect: TRect; Pressed: Boolean); var l_Rect : TRect; begin with HeaderControl.Canvas do begin Brush.Color := clActiveCaption; Font.Color := clCaptionText; Font.Style := [fsBold]; FillRect(Rect); l_Rect := Rect; DrawText(Handle, PAnsiChar(Section.Text), -1, l_Rect, DT_CENTER or DT_VCENTER or DT_NOPREFIX or DT_SINGLELINE); if (Section.Text = '場所') then begin Pen.Color := clBtnShadow; MoveTo(l_Rect.Left - 1, l_Rect.Top); LineTo(l_Rect.Left - 1, l_Rect.Bottom); end; end; end; procedure TApp_CheaPlayerList.Header_PlaylistSectionResize(HeaderControl: THeaderControl; Section: THeaderSection); begin Section.Width := gfniNumLimit(Section.Width, Section.MinWidth, ClientWidth - HeaderControl.Sections[1].MinWidth); HeaderControl.Sections[1].Width := ClientWidth - Section.Width + 2; ListBox_PlayList.Repaint; end; } procedure TApp_CheaPlayerList.ListBox_PlayListDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); const lci_MARGIN = 2; var ls_File : WideString; begin ls_File := G_MainForm.ComboBox_Playlist.Items[Index]; with ListBox_PlayList.Canvas do begin Font.Assign(ListBox_Playlist.Font); Brush.Color := ListBox_Playlist.Color; if (odSelected in State) or (odFocused in State) then begin Brush.Color := clHighLight; Font.Color := clHighLightText; end; if (Index = G_MainForm.ComboBox_Playlist.ItemIndex) then begin Font.Style := Font.Style + [fsBold]; end; FillRect(Rect); if not(Action_List_FolderName.Checked) then begin ls_File := gfnsFileNameGet(ls_File); end; ls_File := WideFormat('%d: %s', [Index +1, ls_File]); Inc(Rect.Left, lci_MARGIN); DrawTextW(Handle, PWideChar(ls_File), -1, Rect, DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER); end; end; procedure TApp_CheaPlayerList.Action_List_CopyExecute(Sender: TObject); var i: Integer; l_List : TMyWStrings; begin if (ListBox_Playlist.SelCount > 0) then begin if (ListBox_Playlist.SelCount = ListBox_Playlist.Items.Count) then begin //全部コピー削除 gpcStrToClipboard(G_MainForm.ComboBox_Playlist.Items.Text); end else begin //選択コピー l_List := TMyWStrings.Create; try for i := 0 to ListBox_Playlist.Items.Count -1 do begin if (ListBox_Playlist.Selected[i]) then begin l_List.Add(G_MainForm.ComboBox_Playlist.Items[i]); end; end; gpcStrToClipboard(l_List.Text); finally l_List.Free; end; end; end; end; procedure TApp_CheaPlayerList.Action_List_DelExecute(Sender: TObject); var i : Integer; lb_Stop : Boolean; li_Index : Integer; begin if (ListBox_Playlist.SelCount > 0) and (gfniMessageBoxYesNo('選択ファイルをリストから削除しますか') = ID_YES) then begin G_MainForm.ComboBox_Playlist.Items.BeginUpdate; try if (ListBox_Playlist.SelCount = ListBox_Playlist.Items.Count) then begin //全削除 G_MainForm.Action_List_ClearExecute(nil); end else begin //部分削除 lb_Stop := False; li_Index := G_MainForm.ComboBox_Playlist.ItemIndex -1; for i := ListBox_Playlist.Items.Count -1 downto 0 do begin if (ListBox_Playlist.Selected[i]) then begin // G_MainForm.DeleteItem(i); lb_Stop := (G_MainForm.ComboBox_Playlist.ItemIndex = i); if (lb_Stop) then begin G_MainForm.Stop; end else if (i < li_Index) then begin Dec(li_Index); end; G_MainForm.ComboBox_Playlist.Items.Delete(i); end; end; if (lb_Stop) then begin //G_MainForm.ComboBox_Playlist.ItemIndex := li_Index; G_MainForm.Action_Play_NextExecute(G_MainForm.Action_Play_Next); end; ListBox_Playlist.Items.BeginUpdate; try //BeginUpdate〜EndUpdateで囲まないとえらくちらつく。 ListBox_Playlist.ClearSelection; finally ListBox_Playlist.Items.EndUpdate; end; end; G_MainForm.ResetCount; finally G_MainForm.ComboBox_Playlist.Items.EndUpdate; ListBox_Playlist.Refresh; end; end; end; //すべて選択 procedure TApp_CheaPlayerList.Action_List_SelectAllExecute(Sender: TObject); begin ListBox_PlayList.SelectAll; end; procedure TApp_CheaPlayerList.ListBox_PlaylistClick(Sender: TObject); var l_InfoGet : T_MyInfoGet; li_Index : Integer; begin Action_Zoom_Capture.Enabled := False; if (ListBox_PlayList.Items.Count > 0) then begin // G_MainForm.SetCaption(Self, WideFormat('再生リスト [%d/%d]', [ListBox_PlayList.ItemIndex +1, ListBox_PlayList.Items.Count])); { if (ListBox_Playlist.SelCount > 0) then begin FSendTo.Args.Clear; for i := 0 to ListBox_Playlist.Count -1 do begin if (ListBox_Playlist.Selected[i]) then begin FSendTo.Args.Add(G_MainForm.ComboBox_Playlist.Items[i]); end; end; end else begin ListBox_Playlist.ItemIndex := gfniNumLimit(ListBox_Playlist.ItemIndex, 0, ListBox_Playlist.Count -1); FSendTo.Arg := G_MainForm.ComboBox_Playlist.Items[ListBox_Playlist.ItemIndex]; end; } ListBox_Playlist.ItemIndex := gfniNumLimit(ListBox_Playlist.ItemIndex, 0, ListBox_Playlist.Count -1); FSendTo.Arg := G_MainForm.ComboBox_Playlist.Items[ListBox_Playlist.ItemIndex]; li_Index := ListBox_Playlist.ItemIndex; l_InfoGet := T_MyInfoGet.Create(li_Index, G_PlaylistStrings[li_Index]); if (l_InfoGet = nil) then begin // Beep; end; end else begin // G_MainForm.SetCaption(Self, '再生リスト'); end; PopupMenu_PlaylistPopup(nil); end; procedure TApp_CheaPlayerList.ItemIndexRefresh; var lb_Selects : array of Boolean; i : Integer; li_Top : Integer; li_Bottom : Integer; l_Rect : TRect; l_State : TOwnerDrawState; begin ListBox_Playlist.Refresh; Exit; SetLength(lb_Selects, ListBox_Playlist.Count); for i := 0 to ListBox_Playlist.Count -1 do begin lb_Selects[i] := ListBox_Playlist.Selected[i]; end; ListBox_Playlist.Refresh; for i := 0 to ListBox_Playlist.Count -1 do begin ListBox_Playlist.Selected[i] := lb_Selects[i]; end; Exit; li_Top := gfniListBoxViewTopGet (ListBox_Playlist); li_Bottom := gfniListBoxViewBottomGet(ListBox_Playlist); for i := li_Top to li_Bottom do begin //myDebug.gpcDebug(i, ListBox_Playlist.Selected[i]); l_Rect := ListBox_Playlist.ItemRect(i); l_State := []; if (ListBox_Playlist.Selected[i]) then begin l_State := l_State + [odSelected]; end; ListBox_Playlist.OnDrawItem( ListBox_Playlist, i, l_Rect, l_State ); end; end; procedure TApp_CheaPlayerList.SetInfo(Sender: T_MyInfoGet; iIndex: Integer; ATag: TMyTag); var l_Tag : TMyTag; begin with Grid_Info do begin Cells[1, lciROW_TITLE] := ''; Cells[1, lciROW_ARTIST] := ''; Cells[1, lciROW_ALBUM] := ''; Cells[1, lciROW_FILEINFO] := ''; end; if (iIndex = ListBox_Playlist.ItemIndex) then begin if (ATag = nil) then begin l_Tag := TMyTag(G_PlaylistStrings.Objects[iIndex]); end else begin l_Tag := ATag; end; if (WideUpperCase(G_PlaylistStrings[iIndex]) = WideUpperCase(l_Tag.FileName)) then begin //タイトル Grid_Info.Cells[1, lciROW_TITLE] := gfnsWideToAnsiEx(l_Tag.Title); //アーティスト Grid_Info.Cells[1, lciROW_ARTIST] := gfnsWideToAnsiEx(l_Tag.Artist); if (l_Tag.OriginalArtist <> '') then begin Grid_Info.Cells[1, lciROW_ARTIST] := Grid_Info.Cells[1, lciROW_ARTIST] + '//' + gfnsWideToAnsiEx(l_Tag.OriginalArtist); end; //アルバム Grid_Info.Cells[1, lciROW_ALBUM] := gfnsWideToAnsiEx(l_Tag.Album); if (l_Tag.OriginalAlbum <> '') then begin Grid_Info.Cells[1, lciROW_ALBUM] := Grid_Info.Cells[1, lciROW_ALBUM] + '//' + gfnsWideToAnsiEx(l_Tag.OriginalAlbum); end; end; end else begin Sender.Terminate; end; end; procedure TApp_CheaPlayerList.SetInfo2(Sender: T_MyInfoGet; iIndex: Integer; ATag : TMyTag); var l_Tag : TMyTag; ls_Info : WideString; begin if (iIndex <> ListBox_Playlist.ItemIndex) then begin Sender.Terminate; Exit; end else begin if (ATag = nil) then begin if (Assigned(G_PlaylistStrings.Objects[iIndex])) then begin l_Tag := TMyTag(G_PlaylistStrings.Objects[iIndex]); end else begin l_Tag := TMyTag.Create(ATag); G_PlaylistStrings.Objects[iIndex] := l_Tag; end; end else begin l_Tag := ATag; end; if (WideUpperCase(G_PlaylistStrings[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.MediaLength), l_Tag.FileWriteTimeString]); if (l_Tag.MediaHasVideo) then begin ls_Info := WideFormat('%s %dx%d', [ls_Info, l_Tag.VideoWidth, l_Tag.VideoHeight]); Action_Zoom_Capture.Enabled := True; end; if (l_Tag.VideoFrameRate > 0) then begin ls_Info := ls_Info + Format(' %.2ffps', [l_Tag.VideoFrameRate]); end; if (l_Tag.BitRate > 0) then begin ls_Info := ls_Info + Format(' %dbps', [l_Tag.Bitrate]); end; end else begin ls_Info := 'ファイルが存在しません'; end; Grid_Info.Cells[1, lciROW_FILEINFO] := ls_Info; end; end; end; procedure TApp_CheaPlayerList.Grid_InfoDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin with Grid_Info.Canvas do begin Font.Assign(Grid_Info.Font); Brush.Color := Grid_Info.Color; Font.Color := Grid_Info.Font.Color; FillRect(Rect); Inc(Rect.Left, lciMARGIN); DrawTextW(Handle, PWideChar(gfnsAnsiToWideEx(Grid_Info.Cells[ACol, ARow])), -1, Rect, DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER); end; end; procedure TApp_CheaPlayerList.Action_List_FolderNameExecute(Sender: TObject); begin ListBox_PlayList.Refresh; end; procedure TApp_CheaPlayerList.Action_Play_PlayExecute(Sender: TObject); //再生 begin G_MainForm.Play(ListBox_Playlist.ItemIndex); end; procedure TApp_CheaPlayerList.Action_Play_ItemIndexExecute(Sender: TObject); //再生中のファイルへ移動 var li_Index : Integer; begin li_Index := G_MainForm.ComboBox_Playlist.ItemIndex; if (li_Index < 0) then begin Exit; end; ListBox_Playlist.TopIndex := li_Index; end; procedure TApp_CheaPlayerList.PopupMenu_PlaylistPopup(Sender: TObject); begin //再生 Action_Play_Play.Enabled := gfnbIsInsideRange(ListBox_Playlist.ItemIndex, 0, ListBox_Playlist.Items.Count -1); Action_Play_ItemIndex.Enabled := (ListBox_Playlist.Items.Count > 0) and (G_MainForm.ComboBox_Playlist.ItemIndex >= 0); //リスト Action_List_Copy.Enabled := (ListBox_Playlist.SelCount > 0); Action_List_Del.Enabled := Action_List_Copy.Enabled; Action_List_SelectAll.Enabled := (ListBox_Playlist.Items.Count > 0); //ファイル Action_File_Property.Enabled := Action_Play_ItemIndex.Enabled; //ビデオ // Action_Zoom_Capture.Enabled := Action_FileProperty.Enabled; //ファイル操作 Action_FileCmd.Enabled := (ListBox_Playlist.SelCount > 0); FSendTo.MenuItemState; G_MainForm.PopupMenu_MainPopup(nil); end; procedure TApp_CheaPlayerList.Edit_FindChange(Sender: TObject); begin if (csLoading in Self.ComponentState) then begin Exit; end; Action_Find_Down.Enabled := (Trim(Edit_Find.Text) <> ''); Action_Find_Up.Enabled := Action_Find_Down.Enabled; end; function TApp_CheaPlayerList.FGetFindText(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_CheaPlayerList.Action_Find_DownExecute(Sender: TObject); function _IsMatch(iIndex: Integer): Boolean; begin Result := Pos(FsFindText, FGetFindText(G_MainForm.ComboBox_Playlist.Items[iIndex])) > 0; if (Result) then begin ListBox_Playlist.Items.BeginUpdate; try ListBox_Playlist.ClearSelection; ListBox_Playlist.ItemIndex := iIndex; ListBox_Playlist.TopIndex := iIndex; ListBox_Playlist.Selected[iIndex] := True; finally ListBox_Playlist.Items.EndUpdate; end; end; end; var i : Integer; begin ListBox_Playlist.ItemIndex := gfniNumLimit(ListBox_Playlist.ItemIndex, 0, ListBox_Playlist.Items.Count -1); FsFindText := FGetFindText(Edit_Find.Text); //履歴に追加 FAddFindHistory(PopupMenu_FindHistory.Items, Edit_Find.Text); if (Sender = Action_Find_Down) then begin for i := ListBox_Playlist.ItemIndex +1 to ListBox_Playlist.Items.Count -1 do begin if (_IsMatch(i)) then begin Exit; end; end; end else begin for i := ListBox_Playlist.ItemIndex -1 downto 0 do begin if (_IsMatch(i)) then begin Exit; end; end; end; //現在位置より上あるいは下には見つからなかった。 Beep; if (_IsMatch(ListBox_Playlist.ItemIndex)) then begin //現在位置にしかなかった。 Exit; end; end; procedure TApp_CheaPlayerList.MenuItem_FindHistoryDrawItem(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_CheaPlayerList.MenuItem_FindHistoryClick(Sender: TObject); var l_MenuItem: TMenuItem; begin if not(Sender is TMenuItem) then begin Exit; end; l_MenuItem := TMenuItem(Sender); Edit_Find.Text := gfnsAnsiToWideEx(l_MenuItem.Hint); Edit_Find.Edit.CurrentCaret := Edit_Find.Length; Edit_Find.SetFocus; end; procedure TApp_CheaPlayerList.FAddFindHistory(AMenuItem: TMenuItem; sText: WideString); //検索履歴に追加 const lci_HISTORY = 10; var i : Integer; l_MenuItem : TMenuItem; begin //履歴の最初がsTextなら処理を抜ける if (AMenuItem.Count > 0) and (FGetFindText(gfnsAnsiToWideEx(AMenuItem.Items[0].Hint)) = FGetFindText(sText)) then begin Exit; end; for i := AMenuItem.Count -1 downto 1 do begin if (FGetFindText(gfnsAnsiToWideEx(AMenuItem.Items[i].Hint)) = FGetFindText(sText)) then begin AMenuItem.Items[i].Free; Break; end; end; //最後に追加ではなく頭に挿入 l_MenuItem := NewItem( gfnsWideToAnsi(sText), //Caption 0, //ShortCut False, //Checked True, //Enabled MenuItem_FindHistoryClick, //OnClickイベント 0, //HelpContext gfnsAvailableName(AMenuItem.Name) //Name ); l_MenuItem.Hint := gfnsWideToAnsiEx(sText); l_MenuItem.OnDrawItem := MenuItem_FindHistoryDrawItem; //Unicode対応のため AMenuItem.Insert(0, l_MenuItem); if (AMenuItem.Count > lci_HISTORY) then begin AMenuItem.Items[AMenuItem.Count -1].Free; //最後をFree end; end; procedure TApp_CheaPlayerList.AddFindHistory(AMenuItem: TMenuItem; AList: TMyWStrings); var i: Integer; begin for i := 0 to AList.Count-1 do begin FAddFindHistory(AMenuItem, AList[i]); end; end; procedure TApp_CheaPlayerList.Button_FindHistoryClick(Sender: TObject); var l_SpeedButton : TSpeedButton; l_Popup : TPopupMenu; begin if not(Sender is TSpeedButton) then begin Exit; end; l_SpeedButton := TSpeedButton(Sender); l_Popup := l_SpeedButton.PopupMenu; if (l_Popup.Items.Count > 0) then begin l_Popup.Popup(l_SpeedButton.ClientOrigin.X, l_SpeedButton.ClientOrigin.Y + l_SpeedButton.Height); end; end; //編集 procedure TApp_CheaPlayerList.Action_Edit_UndoExecute(Sender: TObject); begin Edit_Find.Undo; end; procedure TApp_CheaPlayerList.Action_Edit_RedoExecute(Sender: TObject); begin Edit_Find.Redo; end; procedure TApp_CheaPlayerList.Action_Edit_CutExecute(Sender: TObject); begin Edit_Find.CutToClipboard; end; procedure TApp_CheaPlayerList.Action_Edit_CopyExecute(Sender: TObject); begin Edit_Find.CopyToClipboard; end; procedure TApp_CheaPlayerList.Action_Edit_PasteExecute(Sender: TObject); begin Edit_Find.PasteFromClipboard; end; procedure TApp_CheaPlayerList.Action_Edit_DeleteExecute(Sender: TObject); begin Edit_Find.ClearSelection; end; procedure TApp_CheaPlayerList.Action_Edit_SelectAllExecute(Sender: TObject); begin Edit_Find.SelectAll; end; procedure TApp_CheaPlayerList.PopupMenu_EditPopup(Sender: TObject); begin if (csDestroying in Self.ComponentState) then begin Exit; end; //編集 Action_Edit_Undo.Enabled := Edit_Find.CanUndo; Action_Edit_Redo.Enabled := Edit_Find.CanRedo; Action_Edit_Copy.Enabled := Edit_Find.Selected; Action_Edit_Cut.Enabled := Action_Edit_Copy.Enabled; Action_Edit_Delete.Enabled := Action_Edit_Copy.Enabled; Action_Edit_Paste.Enabled := (gfnsStrFromClipboard <> ''); Action_Edit_SelectAll.Enabled := not(Edit_Find.Empty); end; procedure TApp_CheaPlayerList.Edit_FindKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin case Key of VK_DOWN, VK_UP, VK_RETURN: begin Key := 0; end; end; end; procedure TApp_CheaPlayerList.Edit_FindKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); begin case Key of VK_F3: begin //検索 if (ssShift in Shift) then begin Action_Find_DownExecute(Action_Find_Up); //上方検索 end else begin Action_Find_DownExecute(Action_Find_Down); //上方検索 end; Key := 0; end; // VK_RETURN, VK_DOWN :begin Action_Find_DownExecute(Action_Find_Down); //下方検索 Key := 0; end; VK_UP :begin Action_Find_DownExecute(Action_Find_Up); //上方検索 Key := 0; end; end; end; procedure TApp_CheaPlayerList.Action_File_PropertyExecute(Sender: TObject); begin G_MainForm.OpenProperty(ListBox_Playlist.ItemIndex); end; procedure TApp_CheaPlayerList.Action_Zoom_CaptureExecute(Sender: TObject); //ビデオ映像をキャプチャ var ls_File : WideString; begin if (ListBox_Playlist.ItemIndex < 0) then begin Exit; end; // ls_File := ListBox_Playlist.Items[ListBox_Playlist.ItemIndex]; ls_File := G_MainForm.ComboBox_Playlist.Items[ListBox_Playlist.ItemIndex]; if not(gfnbFileExists(ls_File)) then begin Exit; end; G_MainForm.DoCapture(ls_File, 0); end; procedure TApp_CheaPlayerList.actNop(Sender: TObject); begin // end; //ファイル名変更 procedure TApp_CheaPlayerList.Action_FileCmd_RenameExecute(Sender: TObject); var i : Integer; li_Ret : Integer; lb_Renamed : Boolean; begin if (ListBox_Playlist.SelCount <= 0) then begin Exit; end; G_MainForm.BeginFunc; ListBox_Playlist.Items.BeginUpdate; try lb_Renamed := False; for i := 0 to ListBox_Playlist.Count -1 do begin if (ListBox_Playlist.Selected[i]) then begin li_Ret := G_MainForm.FileRename(G_MainForm.ComboBox_Playlist.Items[i]); if (li_Ret = ID_CANCEL) then begin Break; end else if (li_Ret = ID_YES) then begin lb_Renamed := True; end; end; end; ListBox_Playlist.ClearSelection; if (lb_Renamed) then begin //ソートマーカーを消すため G_MainForm.Action_Sort_FileNameExecute(nil); end; finally ListBox_Playlist.Items.EndUpdate; G_MainForm.EndFunc; end; end; //ファイルコピー procedure TApp_CheaPlayerList.Action_FileCmd_CopyExecute(Sender: TObject); var i : Integer; begin if (ListBox_Playlist.SelCount <= 0) then begin Exit; end; G_MainForm.Dialog_FileCmd_Copy.Owner := Screen.ActiveForm; if (G_MainForm.Dialog_FileCmd_Copy.Execute) then begin G_MainForm.Dialog_FileCmd_Copy.InitialDir := G_MainForm.Dialog_FileCmd_Copy.FolderName; G_MainForm.BeginFunc; ListBox_Playlist.Items.BeginUpdate; try for i := 0 to ListBox_Playlist.Count -1 do begin if (ListBox_Playlist.Selected[i]) then begin if (G_MainForm.FileCopy(G_MainForm.ComboBox_Playlist.Items[i]) = ID_CANCEL) then begin Break; end; end; end; ListBox_Playlist.ClearSelection; finally ListBox_Playlist.Items.EndUpdate; G_MainForm.EndFunc; end; end; end; //ファイル移動 procedure TApp_CheaPlayerList.Action_FileCmd_MoveExecute(Sender: TObject); var i : Integer; li_Ret : Integer; lb_Moved : Boolean; begin if (ListBox_Playlist.SelCount <= 0) then begin Exit; end; G_MainForm.Dialog_FileCmd_Move.Owner := Screen.ActiveForm; if (G_MainForm.Dialog_FileCmd_Move.Execute) then begin G_MainForm.Dialog_FileCmd_Move.InitialDir := G_MainForm.Dialog_FileCmd_Move.FolderName; G_MainForm.BeginFunc; ListBox_Playlist.Items.BeginUpdate; try lb_Moved := False; for i := 0 to ListBox_Playlist.Count -1 do begin if (ListBox_Playlist.Selected[i]) then begin li_Ret := G_MainForm.FileMove(G_MainForm.ComboBox_Playlist.Items[i]); if (li_Ret = ID_CANCEL) then begin Break; end else if (li_Ret = ID_YES) then begin lb_Moved := True; end; end; end; ListBox_Playlist.ClearSelection; if (lb_Moved) then begin //ソートマーカーを消すため G_MainForm.Action_Sort_FileNameExecute(nil); end; finally ListBox_Playlist.Items.EndUpdate; G_MainForm.EndFunc; end; end; end; //ファイル削除 procedure TApp_CheaPlayerList.Action_FileCmd_TrashExecute(Sender: TObject); var i : Integer; begin if (ListBox_Playlist.SelCount <= 0) then begin Exit; end; if (gfniMessageBoxYesNo('選択したファイルをメディアから削除します'#13'よろしいですか', 'ファイル削除', MB_DEFBUTTON2) = ID_YES) then begin G_MainForm.BeginFunc; ListBox_Playlist.Items.BeginUpdate; try for i := ListBox_Playlist.Count -1 downto 0 do begin if (ListBox_Playlist.Selected[i]) then begin if (G_MainForm.FileTrash(G_MainForm.ComboBox_Playlist.Items[i]) = ID_CANCEL) then begin Break; end; end; end; ListBox_Playlist.ClearSelection; finally ListBox_Playlist.Items.EndUpdate; G_MainForm.EndFunc; end; end; end; { procedure TApp_CheaPlayerList.FSendToOpenFileFolder(Sender: TObject; var bReplace: Boolean); var i : Integer; begin if (ListBox_Playlist.SelCount <= 0) then begin Exit; end; FSendTo.Args.Clear; for i := 0 to ListBox_Playlist.Count -1 do begin if (ListBox_Playlist.Selected[i]) then begin FSendTo.Args.Add(G_MainForm.ComboBox_Playlist.Items[i]); end; end; // FSendTo.OpenFileFolderExecute(nil); end; procedure TApp_CheaPlayerList.FSendToSelectProgram(Sender: TObject; var bReplace: Boolean); var i : Integer; begin FSendTo.Args.Clear; for i := 0 to ListBox_Playlist.Count -1 do begin if (ListBox_Playlist.Selected[i]) then begin FSendTo.Args.Add(G_MainForm.ComboBox_Playlist.Items[i]); end; end; // FSendTo.SelectProgramExecute(nil); end; } end.