unit custom_help; //{$DEFINE _DEBUG} interface uses Windows, Messages, SysUtils, Graphics, Controls, Forms, ExtCtrls, StdCtrls, ActnList, Menus, Classes, Buttons, ComCtrls; type TForm_VersionInfo = class(TForm) ActionList1: TActionList; actFile_Close: TAction; actScroll_Up: TAction; actScroll_Down: TAction; actHelp_OnlineHelp: TAction; actMenu_Popup: TAction; actHelp_Update: TAction; mnuHelp: TPopupMenu; mniHelp_OnlineHelp: TMenuItem; mniHelp_Line1: TMenuItem; mniFile_Close: TMenuItem; //コマンドパネル pnlHelp_Ver: TPanel; imgHelp_Icon: TImage; lblHelp_Ver: TLabel; lblHelp_Text: TLabel; shpHelp_Line1: TShape; lstHelp_ShortCutKey: TListBox; shpHelp_Line2: TShape; Panel_Help_URL: TPanel; Panel_Cmd: TPanel; Button_Close: TButton; Label_Help_URL: TLabel; procedure FormCreate (Sender: TObject); procedure FormClose (Sender: TObject; var Action: TCloseAction); procedure FormKeyUp (Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); procedure actFile_CloseExecute (Sender: TObject); procedure actScroll_UpExecute (Sender: TObject); procedure actScroll_DownExecute (Sender: TObject); procedure actMenu_PopupExecute (Sender: TObject); procedure actHelp_OnlineHelpExecute (Sender: TObject); procedure actHelp_UpdateExecute (Sender: TObject); procedure lstHelp_ShortCutKeyDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure Label_Help_URLMouseEnter (Sender: TObject); procedure Label_Help_URLMouseLeave (Sender: TObject); private { Private 宣言 } procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND; procedure FSetHighDPIControlHeight; public { Public 宣言 } end; //------------------------------------------------------------------------------ procedure G_pcCreateHelpForm; procedure G_pcSetHelpComment(sText: WideString); var Form_VersionInfo: TForm_VersionInfo; G_HelpForm: TForm_VersionInfo; G_sHelpURL: WideString; //============================================================================== implementation uses {$IFDEF _DEBUG} myDebug, {$ENDIF} general, highDPIUnit, custom_base, custom_shortcut, lang, common, main; {$R *.dfm} //============================================================================== procedure G_pcCreateHelpForm; procedure _CreateForm; begin Form_VersionInfo := TForm_VersionInfo.Create(G_MainForm); end; var i: Integer; begin if (Form_VersionInfo = nil) then begin _CreateForm; end else begin for i := 0 to Screen.FormCount -1 do begin if (Screen.Forms[i] = Form_VersionInfo) then begin Exit; end; end; _CreateForm; end; end; procedure G_pcSetHelpComment(sText: WideString); begin G_pcCreateHelpForm; G_HelpForm.lblHelp_Text.Caption := sText; end; //============================================================================== procedure TForm_VersionInfo.WMSysCommand(var Msg: TWMSysCommand); begin case Msg.CmdType of 61587: begin //システムアイコンクリック actMenu_PopupExecute(nil); end; else begin inherited; end; end; end; procedure TForm_VersionInfo.FSetHighDPIControlHeight; begin //高DPI対応 gpcItemHeightSet(lstHelp_ShortCutKey, G_ActionList.Images.Height); Panel_Help_Url.ClientHeight := Label_Help_Url.Height + (G_ciCONTROL_MARGIN * 2); Label_Help_Url.Top := (Panel_Help_Url.ClientHeight - Label_Help_Url.Height) div 2; Label_Help_Url.Left := G_ciCONTROL_MARGIN; //下部のコマンドボタンの調整 gpcButtonHeightSet(Button_Close); G_PanelCmdHieghtSet(Panel_Cmd); G_ControlTopSet(Button_Close); G_CloseButtonLeftSet(Button_Close); end; procedure TForm_VersionInfo.FormCreate(Sender: TObject); var lh_Menu: HMENU; begin G_HelpForm := Self; G_pcCreateCustomBaseForm; if (G_sHelpURL <> '') then begin Label_Help_URL.Caption := G_sHelpURL; end; Self.ManualDock(G_CustomForm.tabHelp); Self.Align := alClient; Self.Visible := True; //システムメニュー 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); //最大化 DrawMenuBar(lh_Menu); //高DPI対応 FSetHighDPIControlHeight; //バージョン情報 imgHelp_Icon.Picture.Assign(Application.Icon); lblHelp_Ver.Caption := Format('%s:Ver %s', [Application.Title, gfnsFileVersionGet]); lstHelp_ShortCutKey.Align := alClient; actHelp_UpdateExecute(nil); end; procedure TForm_VersionInfo.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := caFree; end; //閉じる procedure TForm_VersionInfo.actFile_CloseExecute(Sender: TObject); begin G_CustomForm.actFile_CloseExecute(nil); // Close; end; procedure TForm_VersionInfo.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); //F10 begin if (Key = VK_F10) and not(ssAlt in Shift) and not(ssCtrl in Shift) then begin actMenu_PopupExecute(nil); end; end; procedure TForm_VersionInfo.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); begin if (WheelDelta > 0) then begin actScroll_UpExecute(nil); end else begin actScroll_DownExecute(nil); end; end; procedure TForm_VersionInfo.actScroll_UpExecute(Sender: TObject); begin SendMessage(lstHelp_ShortCutKey.Handle, WM_VSCROLL, SB_LINEUP, 0); end; procedure TForm_VersionInfo.actScroll_DownExecute(Sender: TObject); begin SendMessage(lstHelp_ShortCutKey.Handle, WM_VSCROLL, SB_LINEDOWN, 0); end; procedure TForm_VersionInfo.lstHelp_ShortCutKeyDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); var ls_Text: String; begin ls_Text := lstHelp_ShortCutKey.Items[Index]; with lstHelp_ShortCutKey.Canvas do begin if (ls_Text[1] = #9) then begin Brush.Color := clBtnFace; Font.Color := clBtnText; ls_Text := Copy(ls_Text, 2, MaxInt); end else begin Brush.Color := lstHelp_ShortCutKey.Color; Font.Color := lstHelp_ShortCutKey.Font.Color; end; FillRect(Rect); if (ls_Text <> '-') then begin Inc(Rect.Left, 8); end; //アイコン if (Index > 0) and (Index <= G_MainForm.ImageList_InfoIcon.Count) then begin G_MainForm.ImageList_InfoIcon.Draw(lstHelp_ShortCutKey.Canvas, Rect.Left, Rect.Top + gfniMax([0, (lstHelp_ShortCutKey.ItemHeight - G_ActionList.Images.Height) div 2]), Index -1); Inc(Rect.Left, G_MainForm.ImageList_InfoIcon.Width); end; if (ls_Text <> '') then begin Inc(Rect.Left, G_ciTEXT_MARGIN); Dec(Rect.Right, G_ciTEXT_MARGIN); if (lstHelp_ShortCutKey.Items[Index] = '-') then begin MoveTo(Rect.Left, Rect.Top + gfniRectHeight(Rect) div 2); LineTo(Rect.Right, Rect.Top + gfniRectHeight(Rect) div 2); end else begin DrawText(Handle, PChar(lstHelp_ShortCutKey.Items[Index]), -1, Rect, DT_VCENTER or DT_NOPREFIX or DT_SINGLELINE); end; end; end; end; procedure TForm_VersionInfo.actHelp_UpdateExecute(Sender: TObject); //ヘルプ作成 procedure lpc_ShortCutKeyListUp(sKey: String); var i: Integer; li_Key: Word; l_Shift: TShiftState; l_Action: TAction; begin ShortCutToKey(gfniTextToShortCut(sKey), li_Key, l_Shift); with G_MainForm do begin for i := 0 to G_ShortCutList.Count-1 do begin if (T_ShortCutAction(G_ShortCutList.Items[i]).Key = li_Key) then begin l_Action := T_ShortCutAction(G_ShortCutList.Items[i]).Action; lstHelp_ShortCutKey.Items.Add( Format('%*s %s/%s', [ G_iShortCutLength +2, //前後の[]で+2 Format('[%s]', [sKey]), l_Action.Category, StripHotKey(l_Action.Caption) ]) ); Break; end; end; end; end; procedure lpc_MouseGestureListUp(iIndex: Integer); var l_Action: TAction; begin case iIndex of G_ciGESTUREUP: l_Action := G_GestureUp; G_ciGESTUREDOWN: l_Action := G_GestureDown; G_ciGESTURELEFT: l_Action := G_GestureLeft; G_ciGESTURERIGHT: l_Action := G_GestureRight; else l_Action := nil; end; if (l_Action <> nil) then begin lstHelp_ShortCutKey.Items.Add( Format('%*s %s/%s', [ G_iShortCutLength +2, //前後の[]で+2 Format('[%s]', [G_csGESTURESTRING[iIndex]]), l_Action.Category, StripHotKey(l_Action.Caption) ]) ); end; end; function lfns_CommandShortCutKeyGet(AAction: TAction): String; procedure lpc_SetDispKey(var sKey: String; sAdd: String); begin sKey := Format('%s [%s]', [sKey, sAdd]); end; var i: Integer; begin Result := ''; with G_MainForm do begin for i := 0 to G_ShortCutList.Count-1 do begin if (T_ShortCutAction(G_ShortCutList.Items[i]).Action = AAction) then begin lpc_SetDispKey(Result, gfnsShortCutToText(T_ShortCutAction(G_ShortCutList.Items[i]).Key)); end; end; end; if (AAction = G_GestureUp) then lpc_SetDispKey(Result, G_csGESTURESTRING[G_ciGESTUREUP]); if (AAction = G_GestureDown) then lpc_SetDispKey(Result, G_csGESTURESTRING[G_ciGESTUREDOWN]); if (AAction = G_GestureLeft) then lpc_SetDispKey(Result, G_csGESTURESTRING[G_ciGESTURELEFT]); if (AAction = G_GestureRight) then lpc_SetDispKey(Result, G_csGESTURESTRING[G_ciGESTURERIGHT]); end; var i : Integer; li_Len : Integer; l_Action : TAction; ls_Key : String; begin lstHelp_ShortCutKey.Items.Clear; //アイコン説明 lstHelp_ShortCutKey.Items.Add(G_csCustomHelp_StatusIconTitle); lstHelp_ShortCutKey.Items.Add(Format('%s/%s', [StripHotKey(G_MainForm.Action_Write_InfoCash.Caption), G_MainForm.Action_Write_InfoCash.Hint])); lstHelp_ShortCutKey.Items.Add(Format('%s/%s', [StripHotKey(G_MainForm.Action_Opt_StayOnTop.Caption), G_MainForm.Action_Opt_StayOnTop.Hint])); lstHelp_ShortCutKey.Items.Add(Format('%s/%s', [StripHotKey(G_MainForm.Action_Capture_SmoothCapture.Caption), G_MainForm.Action_Capture_SmoothCapture.Hint])); lstHelp_ShortCutKey.Items.Add(Format('%s/%s', [StripHotKey(G_MainForm.Action_Capture_Pause.Caption), G_MainForm.Action_Capture_Pause.Hint])); lstHelp_ShortCutKey.Items.Add(Format('%s/%s', [StripHotKey(G_MainForm.Action_Capture_Lupe.Caption), G_MainForm.Action_Capture_Lupe.Hint])); lstHelp_ShortCutKey.Items.Add(Format('%s/%s', [StripHotKey(G_MainForm.Action_Capture_Fixed.Caption), G_MainForm.Action_Capture_Fixed.Hint])); //ショートカットキー lstHelp_ShortCutKey.Items.Add('-'); lstHelp_ShortCutKey.Items.Add(G_csCustomHelp_ShortCutKeyList); for i := 0 to High(G_csSHORTCUTKEY) do begin lpc_ShortCutKeyListUp(G_csSHORTCUTKEY[i, G_ciSHORTCUTDISP]); end; //マウスジェスチャ lstHelp_ShortCutKey.Items.Add(G_csCustomHelp_MouseGestureList); lpc_MouseGestureListUp(G_ciGESTUREUP); lpc_MouseGestureListUp(G_ciGESTUREDOWN); lpc_MouseGestureListUp(G_ciGESTURELEFT); lpc_MouseGestureListUp(G_ciGESTURERIGHT); //設定コマンド一覧 lstHelp_ShortCutKey.Items.Add('-'); lstHelp_ShortCutKey.Items.Add(G_csCustomHelp_CommandList); li_Len := 0; for i := 0 to G_ActionList.ActionCount-1 do begin l_Action := TAction(G_ActionList.Actions[i]); ls_Key := lfns_CommandShortCutKeyGet(l_Action); if (ls_Key <> '') then begin li_Len := gfniMax([li_Len, Length(G_fnsCommandDescriptionGet(l_Action))]); end; end; for i := 0 to G_ActionList.ActionCount-1 do begin l_Action := TAction(G_ActionList.Actions[i]); ls_Key := lfns_CommandShortCutKeyGet(l_Action); if (ls_Key <> '') then begin lstHelp_ShortCutKey.Items.Add( Format('%-*s %s', [ li_Len, G_fnsCommandDescriptionGet(l_Action), ls_Key ]) ); end; end; end; procedure TForm_VersionInfo.actHelp_OnlineHelpExecute(Sender: TObject); //オンラインヘルプ begin gfnhExecute(Label_Help_URL.Caption); end; procedure TForm_VersionInfo.Label_Help_URLMouseEnter(Sender: TObject); //アンダーラインを引く begin if not(fsUnderline in Label_Help_URL.Font.Style) then begin Label_Help_URL.Font.Style := Label_Help_URL.Font.Style + [fsUnderline]; end; Screen.Cursor := crHandPoint; end; procedure TForm_VersionInfo.Label_Help_URLMouseLeave(Sender: TObject); //アンダーラインを戻す begin if (fsUnderline in Label_Help_URL.Font.Style) then begin Label_Help_URL.Font.Style := Label_Help_URL.Font.Style - [fsUnderline]; end; Screen.Cursor := crDefault; end; procedure TForm_VersionInfo.actMenu_PopupExecute(Sender: TObject); begin mnuHelp.Popup(Self.ClientOrigin.X, Self.ClientOrigin.Y); end; end.