unit main; {$DEFINE _DEBUG} interface uses my_apitest, Windows, Messages, SysUtils, ActnList, Classes, Controls, ExtCtrls, Forms, Grids, Menus, StdCtrls, AppEvnts, Vcl.ToolWin, Vcl.ComCtrls, System.Actions; type TApp_TOOLWinfo = class(TForm) ActionList1: TActionList; Action_File_Exit: TAction; Action_Edit_Copy: TAction; Action_Edit_CopyHandle10: TAction; Action_Edit_CopyHandle16: TAction; Action_Window_All: TAction; Action_Window_PtInRect: TAction; Action_Window_Visible: TAction; Action_Window_Simple: TAction; Action_Opt_SizeFit: TAction; Action_Opt_StayOnTop: TAction; Action_Opt_EnumChildWindow: TAction; Action_Opt_DispAPITest: TAction; Action_Capture_Pause: TAction; Action_Help_VersionInfo: TAction; Menu_Main: TPopupMenu; MenuItem_Edit_Copy: TMenuItem; MenuItem_Edit_CopyHandle10: TMenuItem; MenuItem_Edit_CopyHandle16: TMenuItem; MenuImte_Line_1: TMenuItem; MenuItem_Window_All: TMenuItem; MenuItem_Window_PtInRect: TMenuItem; MenuItem_Window_Visible: TMenuItem; MenuItem_Window_Simple: TMenuItem; MenuItem_Line_2: TMenuItem; MenuItem_Opt_StayOnTop: TMenuItem; MenuItem_Opt_EnumChildWindow: TMenuItem; MenuItem_Opt_ShowAPITest: TMenuItem; MenuItem_Capture_Pause: TMenuItem; MenuItem_Line_4: TMenuItem; MenuItem_Help_VersionInfo: TMenuItem; MenuItem_Line_5: TMenuItem; MenuItem_File_Exit: TMenuItem; Menu_Item: TPopupMenu; MenuItem_Item_ClassName: TMenuItem; MenuItem_Item_Handle: TMenuItem; MenuItem_Item_Text: TMenuItem; MenuItem_Item_WindowSize: TMenuItem; MenuItem_Item_ClientSize: TMenuItem; MenuItem_Item_Rect: TMenuItem; MenuItem_Item_ControlID: TMenuItem; MenuItem_Item_Unicode: TMenuItem; MenuItem_Item_Visible: TMenuItem; MenuItem_Item_ClientOrigin: TMenuItem; MenuItem_Item_Enabled: TMenuItem; MenuItem_Item_APITest: TMenuItem; Label_ExeName: TLabel; Shape_Border: TShape; Grid_Winfo: TStringGrid; Timer: TTimer; ApplicationEvents1: TApplicationEvents; Action_Edit_CopyTree: TAction; MenuItem_Edit_CopyTree: TMenuItem; procedure FormCreate (Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Action_File_ExitExecute (Sender: TObject); procedure Action_Edit_CopyExecute (Sender: TObject); procedure Action_Edit_CopyHandle10Execute(Sender: TObject); procedure Action_Edit_CopyHandle16Execute(Sender: TObject); procedure Action_Opt_SizeFitExecute (Sender: TObject); procedure Action_Window_AllExecute (Sender: TObject); procedure Action_Opt_StayOnTopExecute (Sender: TObject); procedure Action_Opt_DispAPITestExecute (Sender: TObject); procedure Action_Capture_PauseExecute (Sender: TObject); procedure Action_Help_VersionInfoExecute (Sender: TObject); procedure actNop(Sender: TObject); procedure Menu_MainPopup (Sender: TObject); procedure MenuItem_Item_HandleClick (Sender: TObject); procedure Grid_WinfoDblClick (Sender: TObject); procedure Grid_WinfoMouseMove (Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure Grid_WinfoMouseDown (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Grid_WinfoMouseUp (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Grid_WinfoDrawCell (Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); procedure TimerTimer (Sender: TObject); procedure ApplicationEvents1Exception(Sender: TObject; E: Exception); procedure Action_Edit_CopyTreeExecute(Sender: TObject); private { Private 宣言 } FptMousePos : TPoint; //マウスポインタの位置 FiPassTime : DWORD; //前回情報を取得した時間 FbDrag : Boolean; //グリッドの幅を変えるためにドラッグしたフラッグ FptMouseGesture : TPoint; //マウスジェスチャー FList : TList; FGridOriginProc : TWndMethod; //元のウィンドウ関数保持用 procedure FGridClassProc(var Msg: TMessage); //入れ替え用手続き procedure FSetWidth; procedure FSetHeight; procedure FLoadIni; //後方互換のため残す procedure FSaveIni; // function FLoadBin: Boolean; // procedure FSaveBin; function FGetAPICaption: String; //システム終了 procedure WMQueryEndSession(var Msg: TWMQueryEndSession); message WM_QUERYENDSESSION; procedure WMDisplayChange(var Msg: TMessage); message WM_DISPLAYCHANGE; public { Public 宣言 } procedure SetAPICaption; end; var App_TOOLWinfo: TApp_TOOLWinfo; G_APITestCallWindow: TApp_TOOLWinfo; const G_csAPPTITLE = 'ウィンドウ情報'; implementation uses {$IFDEF _DEBUG} _myDebug, {$ENDIF} Clipbrd, Graphics, System.Types, _myHelpVersionInfo, _myIniFile, _myMessageDlg, // my_settingfile, sub_api, general; const //ウィンドウ状態のビット比較用 Fci_FLAG_TARGET = $1; Fci_FLAG_OUTOFRECT = $2; Fci_FLAG_INVISIBLE = $4; const //フラグ用 Fci_COL_FLAG = 0; //フラグを格納する列(表示はしない) //表示する情報 Fci_COL_CLASSNAME = 1; Fcs_TITLE_CLASSNAME = 'クラス名'; Fci_COL_HANDLE = 2; Fcs_TITLE_HANDLE = 'ハンドル'; Fci_COL_TEXT = 3; Fcs_TITLE_TEXT = 'テキスト'; Fci_COL_WINDOWSIZE = 4; Fcs_TITLE_WINDOWSIZE = 'Wサイズ'; Fci_COL_CLIENTSIZE = 5; Fcs_TITLE_CLIENTSIZE = 'Cサイズ'; Fci_COL_CLIENTORIGIN = 6; Fcs_TITLE_CLIENTORIGIN = 'C原点'; Fci_COL_RECT = 7; Fcs_TITLE_RECT = 'Rect'; Fci_COL_CONTROLID = 8; Fcs_TITLE_CONTROLID = 'ID'; Fci_COL_UNICODE = 9; Fcs_TITLE_UNICODE = 'Unicode'; Fci_COL_VISIBLE = 10; Fcs_TITLE_VISIBLE = 'Visible'; Fci_COL_ENABLED = 11; Fcs_TITLE_ENABLED = 'Enabled'; Fci_COL_APITEST = 12; Fcs_TITLE_APITEST = 'API Test'; Fci_COL_START = Fci_COL_CLASSNAME; Fci_COL_END = Fci_COL_APITEST; type T_WInfo = record //表示用 iIndent : Integer; hHandle : HWND; sClassName : WideString; //敢えてWideString sText : WideString; //敢えてWideString szWindowSize : TMyBounds; rcBoundsRect : TRect; rcClientRect : TRect; ptClientOrigin : TPoint; iControlID : Longint; bUnicode : Boolean; bVisible : Boolean; bEnabled : Boolean; sAPITest : WideString; //状態判定用 rcInheritRect : TRect; //本来はクリッピング領域とでもいうのだろうか bInheritVisible : Boolean; //親ウィンドウが非表示なら子は表示されない end; P_WInfo = ^T_WInfo; {$R *.dfm} procedure TApp_TOOLWinfo.FGridClassProc(var Msg: TMessage); var l_Msg: TMessage; begin if (Msg.Msg = WM_MOUSEWHEEL) then begin FillChar(l_Msg, SizeOf(l_Msg), 0); if (TWMMouseWheel(Msg).WheelDelta > 0) then begin l_Msg.WParamLo := SB_LINEUP; end else begin l_Msg.WParamLo := SB_LINEDOWN; end; l_Msg.Result :=0; SendMessage(Grid_Winfo.Handle, WM_VSCROLL, l_Msg.WParam, l_Msg.LParam); end else begin FGridOriginProc(Msg); end; end; //================================================================================== procedure TApp_TOOLWinfo.FormCreate(Sender: TObject); var lh_Menu: hMenu; begin {$IFDEF _DEBUG} // _myDebug.gpcMessageModeSet(True); {$ENDIF} G_APITestCallWindow := Self; //メニュー 最大化は必要ないので消去 lh_Menu := GetSystemMenu(Handle, False); DeleteMenu(lh_Menu, SC_MAXIMIZE, MF_BYCOMMAND); //最大化 // DeleteMenu(lh_Menu, 2, MF_BYPOSITION); //区切り線 DrawMenuBar(lh_Menu); FiPassTime := 0; FptMousePos := Point(-1, -1); FList := TList.Create; Label_ExeName.Caption := ''; //API Testフォームを作成する。 // G_CreateAPITestForm; FGridOriginProc := Grid_Winfo.WindowProc; Grid_Winfo.WindowProc := FGridClassProc; with Grid_Winfo do begin Align := alClient; ColCount := Fci_COL_END + 2; //フラグ用に一つプラスして2 RowCount := 5;//lciWINDOW_OWNER + 1; ColWidths[Fci_COL_FLAG] := 0; Cells[Fci_COL_CLASSNAME, 0] := Fcs_TITLE_CLASSNAME; Cells[Fci_COL_HANDLE, 0] := Fcs_TITLE_HANDLE; Cells[Fci_COL_TEXT, 0] := Fcs_TITLE_TEXT; Cells[Fci_COL_WINDOWSIZE, 0] := Fcs_TITLE_WINDOWSIZE; Cells[Fci_COL_CLIENTSIZE, 0] := Fcs_TITLE_CLIENTSIZE; Cells[Fci_COL_CLIENTORIGIN, 0] := Fcs_TITLE_CLIENTORIGIN; Cells[Fci_COL_RECT, 0] := Fcs_TITLE_RECT; Cells[Fci_COL_CONTROLID, 0] := Fcs_TITLE_CONTROLID; Cells[Fci_COL_UNICODE, 0] := Fcs_TITLE_UNICODE; Cells[Fci_COL_VISIBLE, 0] := Fcs_TITLE_VISIBLE; Cells[Fci_COL_ENABLED, 0] := Fcs_TITLE_ENABLED; Cells[Fci_COL_APITEST, 0] := Fcs_TITLE_APITEST; //行の高さをセット DefaultRowHeight := Self.Canvas.TextHeight('A') + G_ciMARGIN * 2; //幅を初期化後自動調整 MenuItem_Item_ClassName.Tag := Self.Canvas.TextWidth('App_ClassName') + G_ciMARGIN * 2; MenuItem_Item_Handle.Tag := Self.Canvas.TextWidth('xFFFFFFF 1234567') + G_ciMARGIN * 2; MenuItem_Item_Text.Tag := Self.Canvas.TextWidth('キャプション') + G_ciMARGIN * 2; MenuItem_Item_WindowSize.Tag := Self.Canvas.TextWidth('1600 1200') + G_ciMARGIN * 2; MenuItem_Item_ClientSize.Tag := Self.Canvas.TextWidth('1600 1200') + G_ciMARGIN * 2; MenuItem_Item_ClientOrigin.Tag := Self.Canvas.TextWidth('1600,1200') + G_ciMARGIN * 2; MenuItem_Item_Rect.Tag := Self.Canvas.TextWidth('1000,1000,1200,1200') + G_ciMARGIN * 2; MenuItem_Item_ControlID.Tag := Self.Canvas.TextWidth('1234567') + G_ciMARGIN * 2; MenuItem_Item_Unicode.Tag := Self.Canvas.TextWidth('Unicode') + G_ciMARGIN * 2; MenuItem_Item_Visible.Tag := Self.Canvas.TextWidth('Visible') + G_ciMARGIN * 2; MenuItem_Item_Enabled.Tag := Self.Canvas.TextWidth('Enabled') + G_ciMARGIN * 2; MenuItem_Item_APITest.Tag := Self.Canvas.TextWidth('API テスト') + G_ciMARGIN * 2; end; //Application.Title := Format('%s Ver %s', [Application.Title, gfnsFileVersionGet]); Self.Caption := Application.Title; Self.Tag := 1; //開始 FLoadIni; // FLoadBin; //グリッドにウィンドウ幅を合わせる FSetWidth; //高さを自動調整 //API Testフォームを作成する。 G_CreateAPITestForm; SetAPICaption; Action_Opt_DispAPITestExecute(nil); Timer.Enabled := True; end; //破棄 procedure TApp_TOOLWinfo.FormDestroy(Sender: TObject); begin Tag := 0; Timer.Enabled := False; FSaveIni; // FSaveBin; gpcListFree(FList); end; procedure TApp_TOOLWinfo.WMQueryEndSession(var Msg: TWMQueryEndSession); begin //http://www.wwlnk.com/boheme/delphi/tips/tec0690.htm FormDestroy(Self); Msg.Result := 1; end; procedure TApp_TOOLWinfo.WMDisplayChange(var Msg: TMessage); begin //TScreenのMonitorsプロパティがディスプレイの変更に追随しない不具合の回避のため Self.Monitor; end; //--- Timer --- procedure TApp_TOOLWinfo.TimerTimer(Sender: TObject); procedure _InfoDisp(iRow: Integer; iFlag: DWORD); procedure _SetCells(MenuItem: TMenuItem; var iCol: Integer; iRow: Integer; sStr: String); begin if (MenuItem.Checked) then begin Grid_Winfo.Cells[iCol, iRow] := sStr; Inc(iCol); end; end; var i : Integer; li_Col : Integer; l_Info : T_WInfo; begin l_Info := T_WInfo(FList[iRow]^); iRow := iRow + 1; //ヘッダー分で+1。 Grid_Winfo.Cells[Fci_COL_FLAG, iRow] := IntToStr(iFlag); //iFlagには列の表示情報が格納されている。 if (l_Info.hHandle <> 0) then begin with l_Info do begin li_Col := Fci_COL_START; for i := Fci_COL_START to Fci_COL_END do begin case i of Fci_COL_CLASSNAME : _SetCells(MenuItem_Item_ClassName, li_Col, iRow, sClassName); Fci_COL_HANDLE : _SetCells(MenuItem_Item_Handle, li_Col, iRow, Format('%.8x %0:d', [hHandle])); Fci_COL_TEXT : _SetCells(MenuItem_Item_Text, li_Col, iRow, sText); // ウィンドウテキスト Fci_COL_WINDOWSIZE : _SetCells(MenuItem_Item_WindowSize, li_Col, iRow, Format('%d,%d %dx%d' , [szWindowSize.Left, szWindowSize.Top, szWindowSize.Width, szWindowSize.Height])); Fci_COL_CLIENTSIZE : _SetCells(MenuItem_Item_ClientSize, li_Col, iRow, Format('%dx%d' , [rcClientRect.Right, rcClientRect.Bottom])); Fci_COL_CLIENTORIGIN : _SetCells(MenuItem_Item_ClientOrigin, li_Col, iRow, Format('%d,%d', [ptClientOrigin.X, ptClientOrigin.Y])); Fci_COL_RECT : _SetCells(MenuItem_Item_Rect, li_Col, iRow, Format('%d,%d,%d,%d', [rcBoundsRect.Left, rcBoundsRect.Top, rcBoundsRect.Right, rcBoundsRect.Bottom])); // Fci_COL_CONTROLID : _SetCells(MenuItem_Item_ControlID, li_Col, iRow, Format('%.8x %0:d', [iControlID])); Fci_COL_CONTROLID : _SetCells(MenuItem_Item_ControlID, li_Col, iRow, Format('%0:d', [iControlID])); Fci_COL_UNICODE : _SetCells(MenuItem_Item_Unicode, li_Col, iRow, gfnsBoolToStr(bUnicode)); Fci_COL_VISIBLE : _SetCells(MenuItem_Item_Visible, li_Col, iRow, gfnsBoolToStr(bVisible)); Fci_COL_ENABLED : _SetCells(MenuItem_Item_Enabled, li_Col, iRow, gfnsBoolToStr(bEnabled)); Fci_COL_APITEST : _SetCells(MenuItem_Item_APITest, li_Col, iRow, sAPITest); end; end; end; end else begin Grid_Winfo.Rows[iRow].Clear; end; end; procedure _InfoSet(var rInfo: T_WInfo); //各種ウィンドウ情報をセット begin if (IsWindow(rInfo.hHandle)) then begin rInfo.sClassName := gfnsClassNameGet(rInfo.hHandle); rInfo.sText := gfnsWindowTextGet(rInfo.hHandle); rInfo.szWindowSize := gfnszWindowSizeGet(rInfo.hHandle); rInfo.rcClientRect := gfnrcClientRectGet(rInfo.hHandle); rInfo.ptClientOrigin := gfnptClientToScreen(rInfo.hHandle); rInfo.rcBoundsRect := gfnrcWindowRectGet(rInfo.hHandle); rInfo.iControlID := GetWindowLong(rInfo.hHandle, GWL_ID); rInfo.bUnicode := IsWindowUnicode(rInfo.hHandle); rInfo.bVisible := IsWindowVisible(rInfo.hHandle); rInfo.bEnabled := IsWindowEnabled(rInfo.hHandle); rInfo.sAPITest := sub_api.G_TestExecute(rInfo.hHandle, gfnptMousePosGet); end; end; procedure _InfoAdd(hHandle: HWND; List: TList); var lp_Info: P_WInfo; begin New(lp_Info); FillChar(lp_Info^, SizeOf(lp_Info^), 0); lp_Info^.iIndent := 0; lp_Info^.hHandle := hHandle; //lp_Info^.hHandleを基に各種ウィンドウ情報をlp_Infoにセット _InfoSet(lp_Info^); lp_Info^.rcInheritRect := lp_Info^.rcBoundsRect; lp_Info^.bInheritVisible := lp_Info^.bInheritVisible; if (App_TOOLWinfo.Action_Opt_EnumChildWindow.Checked) // and not(App_TOOLWinfo.Action_Window_Simple.Checked) then begin List.Insert(0, lp_Info); end else begin List.Add(lp_Info); end; end; function _ChildWindowProc(hWindow: HDC; AList: TList): Boolean stdcall; //子ウィンドウを列挙 function _ParentGet(hParent: HWND; List: TList): Integer; //リストにhParentが登録されていればそのインデックスを返す //リストにまだhParentが登録されていなければ-1を返す var i: Integer; begin Result := -1; if (hParent = 0) then begin Exit; end; for i := 0 to List.Count-1 do begin if (T_WInfo(List[i]^).hHandle = hParent) then begin //既に登録されていた //インデックスを返す Result := i; Break; end; end; end; var lp_Info: P_WInfo; li_Index: Integer; begin New(lp_Info); try FillChar(lp_Info^, SizeOf(lp_Info^), 0); with lp_Info^ do begin iIndent := 2; hHandle := hWindow; //hHandleの親ウィンドウのリストのインデックスを取得 //****** ここが肝 ****** li_Index := _ParentGet(gfnhParentWindowGet(hHandle), AList); if (li_Index >= 0) then begin //親ウィンドウがあったので親ウィンドウのインデント+1 iIndent := T_WInfo(AList[li_Index]^).iIndent +1; end; //hHandle(hWindow)を基に各種ウィンドウ情報をセット _InfoSet(lp_Info^); //マウスカーソルに範囲がかかるかの判定と可視状態の判定 //このlp_Info^のrcInheritRectとbInheritVisibleの値を調べるだけで判定できる //いちいち親ウィンドウに遡って調べる必要はない if (li_Index >= 0) then begin //親ウィンドウは登録されている //親ウィンドウの範囲内にあるかの状態と可視状態を引き継ぐ lp_Info^.rcInheritRect := gfnrcMinRect([lp_Info^.rcBoundsRect, T_WInfo(AList[li_Index]^).rcInheritRect]); lp_Info^.bInheritVisible := lp_Info^.bVisible and T_WInfo(AList[li_Index]^).bInheritVisible; end else begin //親ウィンドウはない //つまりトップレベルウィンドウ直下のウィンドウ lp_Info^.rcInheritRect := lp_Info^.rcBoundsRect; lp_Info^.bInheritVisible := lp_Info^.bVisible; end; if (App_TOOLWinfo.Action_Opt_EnumChildWindow.Checked) then begin //EnumChildWindowに合わせるため単純に追加 AList.Add(lp_Info); end else begin //****** ここが肝 ****** if (li_Index >= 0) then begin //Zオーダーを見た目と同じようにするため親ウィンドウがリストにあれば挿入 AList.Insert(li_Index, lp_Info); end else begin //親ウィンドウはないので追加 AList.Add(lp_Info); end; end; end; Result := True; except on E: Exception do begin Result := False; gpcShowMessage(E.Message); Dispose(lp_Info); end; end; end; var i : Integer; lh_Window : HWND; lpt_Pos : TPoint; l_Info : T_WInfo; l_Target : T_WInfo; lb_Target : Boolean; li_Toplevel : Integer; li_Candidate : Integer; li_Flag : DWORD; begin if (Tag = 0) then begin Exit; end; Timer.Enabled := False; GetCursorPos(lpt_Pos); if not(gfnbEqual(lpt_Pos, FptMousePos)) //前回と今回とでマウスカーソルの位置が違っている。 or (FiPassTime = 0) //前回の時間が0である=起動直後か意識的に取得したいとき。 or (Abs(GetTickCount - FiPassTime) > Timer.Tag) //前回からリフレッシュ時間を過ぎている。Timer.Tagにリフレッシュの間隔を指定している。 or (Sender = nil) // then begin //上記のどれかに合致したらば↓の処理に入る。 gpcListClear(FList); gpcGridDataClear(Grid_Winfo); FptMousePos := lpt_Pos; if (Action_Opt_StayOnTop.Checked) then begin Caption := Format('↑%s (%d,%d)', [Application.Title, lpt_Pos.X, lpt_Pos.Y]); end else begin Caption := Format('%s (%d,%d)', [Application.Title, lpt_Pos.X, lpt_Pos.Y]); end; if (Action_Window_Simple.Checked) then begin //シンプル解析。 lh_Window := gfnhWindowGet(lpt_Pos); //キャプションに実行ファイル名をセット。 Label_ExeName.Caption := gfnsExeNameGet(lh_Window); //対象ウィンドウ。 _InfoAdd(lh_Window, FList); //親ウィンドウ。 _InfoAdd(gfnhParentWindowGet(lh_Window), FList); //トップレベルウィンドウ。 _InfoAdd(gfnhToplevelWindowGet(lh_Window), FList); //オーナーウィンドウ。 _InfoAdd(gfnhOwnerWindowGet(lh_Window), FList); _InfoDisp(0, 0); _InfoDisp(1, 0); _InfoDisp(2, 0); _InfoDisp(3, 0); end else begin //シンプル解析以外の表示。 //カーソル下の見えている一番手前のトップレベルウィンドウのハンドルを得る。 lh_Window := gfnhToplevelWindowGet(lpt_Pos); //子ウィンドウを列挙。 EnumChildWindows(lh_Window, @_ChildWindowProc, LPARAM(FList)); //トップレベルウィンドウの情報を追加。 _InfoAdd(lh_Window, FList); //最初(トップレベル)のRectと可視状態をセット。 //ちなみに可視状態は必ずTrue。 if (Action_Opt_EnumChildWindow.Checked) then begin li_Toplevel := 0; end else begin li_Toplevel := FList.Count-1; end; T_WInfo(FList[li_Toplevel]^).rcInheritRect := T_WInfo(FList[li_Toplevel]^).rcInheritRect; T_WInfo(FList[li_Toplevel]^).bInheritVisible := T_WInfo(FList[li_Toplevel]^).bVisible; //表示対象でないウィンドウの情報をリストから削除。 if (Action_Window_PtInRect.Checked) //マウスカーソルにかかるウィンドウ。 or (Action_Window_Visible.Checked) //見えているウィンドウ。 then begin for i := FList.Count-1 downto 0 do begin l_Info := T_WInfo(FList[i]^); if not(PtInRect(l_Info.rcInheritRect, lpt_Pos)) or ((Action_Window_Visible.Checked) and not(l_Info.bInheritVisible)) then begin //_myDebug.gpcDebug(l_Info.sClassName, l_Info.rcBoundsRect); //マウスカーソルにかからないウィンドウの情報は表示しないので破棄。 //または見えるウィンドウのみの表示、かつ見えないウィンドウの情報は表示しないので破棄。 Dispose(FList.Items[i]); FList.Delete(i); end; end; end; //グリッドの行数を設定。 Grid_Winfo.RowCount := FList.Count +1; //ヘッダーの分。 Label_ExeName.Caption := gfnsExeNameGet(lh_Window); li_Candidate := -1; lb_Target := False; for i := 0 to FList.Count-1 do begin li_Flag := 0; //表示する時ビット判定させるためのフラグ。 l_Info := T_WInfo(FList[i]^); if not(l_Info.bVisible) then begin //非表示(淡色表示) li_Flag := li_Flag or Fci_FLAG_INVISIBLE; end; if not(PtInRect(l_Info.rcBoundsRect, lpt_Pos)) then begin //RECT外(打ち消しあるいはアンダーライン表示) li_Flag := li_Flag or Fci_FLAG_OUTOFRECT; end; Inc(li_Flag, l_Info.iIndent shl 16); //フラグにインデント幅をセット(インデントを100倍(16/8=2で10の2乗ということ)して足している) if not(Action_Opt_EnumChildWindow.Checked) then begin //EnumChildWindowに合わせない場合は単純にリストを上から見ていけばよい。 if not(lb_Target) //まだ対象ウィンドウに出会っていない。 and (l_Info.bInheritVisible) //見えているウィンドウである。 and (PtInRect(l_Info.rcInheritRect, lpt_Pos)) //マウスカーソルにかかるウィンドウである。 then begin //これが対象ウィンドウ li_Flag := li_Flag or Fci_FLAG_TARGET; //ターゲット(クラス名を太字で表示) lb_Target := True; end; end else begin //EnumChildWindowに合わせる場合は子ウィンドウが親ウィンドウの次から列挙されるのでちょっとややこしい。 if not(lb_Target) //まだ対象ウィンドウに出会っていない。 and (l_Info.bInheritVisible) //見えているウィンドウである。 and (PtInRect(l_Info.rcInheritRect, lpt_Pos)) //マウスカーソルにかかるウィンドウである。 then begin //対象ウィンドウ候補。 if (li_Candidate < 0) then begin //まだターゲットがなかった。 l_Target := l_Info; li_Candidate := i; end else begin //ターゲットはある。 if (l_Info.iIndent > l_Target.iIndent) then begin //子ウィンドウ。 //候補が移る。 l_Target := l_Info; li_Candidate := i; end else begin //ヘッダー分があるので+1。 Grid_Winfo.Cells[Fci_COL_FLAG, li_Candidate+1] := IntToStr(gfniStrToInt(Grid_Winfo.Cells[Fci_COL_FLAG, li_Candidate+1]) or Fci_FLAG_TARGET); //Grid_Winfo.Cells[Fci_COL_FLAG, 1]には列の表示情報が格納されている。 lb_Target := True; end; end; end; end; _InfoDisp(i, li_Flag); end; if (Action_Opt_EnumChildWindow.Checked) then begin if (li_Candidate < 0) then begin //ヘッダー分があるのでトップレベルのセルのインデックスは0ではなく1。 Grid_Winfo.Cells[Fci_COL_FLAG, 1] := IntToStr(gfniStrToInt(Grid_Winfo.Cells[Fci_COL_FLAG, 1]) or Fci_FLAG_TARGET); //Grid_Winfo.Cells[Fci_COL_FLAG, 1]には列の表示情報が格納されている。 //Grid_Winfo.Cells[Fci_COL_FLAG, 1] := '1'; //実質はこういうことになる。 end else begin //ヘッダー分があるので+1。 Grid_Winfo.Cells[Fci_COL_FLAG, li_Candidate+1] := IntToStr(gfniStrToInt(Grid_Winfo.Cells[Fci_COL_FLAG, li_Candidate+1]) or Fci_FLAG_TARGET); //Grid_Winfo.Cells[Fci_COL_FLAG, 1]には列の表示情報が格納されている。 end; end; end; FiPassTime := GetTickCount; end; if not(Action_Capture_Pause.Checked) then begin Timer.Enabled := True; end; end; procedure TApp_TOOLWinfo.SetAPICaption; begin MenuItem_Item_HandleClick(nil); end; function TApp_TOOLWinfo.FGetAPICaption: String; begin if not(gfnbFormExists(App_TOOL_APITest)) then begin Result := Fcs_TITLE_APITEST; end else begin Result := Format('%s %s/%s', [Fcs_TITLE_APITEST, App_TOOL_APITest.ComboBox_API.Text, App_TOOL_APITest.ComboBox_APIParam.Text]); end; end; procedure TApp_TOOLWinfo.MenuItem_Item_HandleClick(Sender: TObject); procedure _SetTitle(AMenuItem : TMenuItem; sTitle : String; var iCol : Integer); begin if (AMenuItem.Checked) then begin Grid_Winfo.Cells[iCol, 0] := sTitle; Grid_Winfo.ColWidths[iCol] := AMenuItem.Tag; Inc(iCol); end; end; var i : Integer; li_ColCount : Integer; li_Col : Integer; begin li_ColCount := 1; //タイトル for i := 0 to Menu_Item.Items.Count -1 do begin if (Menu_Item.Items[i].Checked) then begin Inc(li_ColCount); end; end; Grid_Winfo.ColCount := li_ColCount; li_Col := Fci_COL_START; for i := Fci_COL_START to Fci_COL_END do begin case i of Fci_COL_CLASSNAME :begin //クラス名 ※実は必須 _SetTitle(MenuItem_Item_ClassName, Fcs_TITLE_CLASSNAME, li_Col); end; Fci_COL_HANDLE :begin //ハンドル _SetTitle(MenuItem_Item_Handle, Fcs_TITLE_HANDLE, li_Col); end; Fci_COL_TEXT :begin //テキスト _SetTitle(MenuItem_Item_Text, Fcs_TITLE_TEXT, li_Col); end; Fci_COL_WINDOWSIZE :begin //ウィンドウサイズ _SetTitle(MenuItem_Item_WindowSize, Fcs_TITLE_WINDOWSIZE, li_Col); end; Fci_COL_CLIENTSIZE :begin //クライアントサイズ _SetTitle(MenuItem_Item_ClientSize, Fcs_TITLE_CLIENTSIZE, li_Col); end; Fci_COL_CLIENTORIGIN :begin //クライアント原点 _SetTitle(MenuItem_Item_ClientOrigin, Fcs_TITLE_CLIENTORIGIN, li_Col); end; Fci_COL_RECT :begin //Rect _SetTitle(MenuItem_Item_Rect, Fcs_TITLE_RECT, li_Col); end; Fci_COL_CONTROLID :begin //Control-ID _SetTitle(MenuItem_Item_ControlID, Fcs_TITLE_CONTROLID, li_Col); end; Fci_COL_UNICODE :begin //Unicode _SetTitle(MenuItem_Item_Unicode, Fcs_TITLE_UNICODE, li_Col); end; Fci_COL_VISIBLE :begin //Visible _SetTitle(MenuItem_Item_Visible, Fcs_TITLE_VISIBLE, li_Col); end; Fci_COL_ENABLED :begin //Enabled _SetTitle(MenuItem_Item_Enabled, Fcs_TITLE_ENABLED, li_Col); end; Fci_COL_APITEST :begin //APIテスト _SetTitle(MenuItem_Item_APITest, FGetAPICaption, li_Col); end; end; end; // FSetWidth; end; //--- MenuItem --- procedure TApp_TOOLWinfo.Menu_MainPopup(Sender: TObject); var lpt_Pos : TPoint; lpt_Client : TPoint; li_Col : Integer; li_Row : Integer; l_GridRect : TGridRect; begin // Exit; //右クリックした場所のセルを取得 with Grid_Winfo do begin lpt_Pos := gfnptMousePosGet; lpt_Client := ScreenToClient(lpt_Pos); MouseToCell(lpt_Client.X, lpt_Client.Y, li_Col, li_Row); if (li_Row > 0) then begin if (li_Col > 0) then begin l_GridRect.Left := li_Col; l_GridRect.Top := li_Row; l_GridRect.Right := li_Col; l_GridRect.Bottom := li_Row; Selection := l_GridRect; // Action_Edit_Copy.Visible := (li_Col <> Fci_COL_HANDLE); // and (li_Col <> Fci_COL_CONTROLID); // Action_Edit_CopyHandle10.Visible := not(Action_Edit_Copy.Visible); Action_Edit_CopyHandle10.Visible := (li_Col <> Fci_COL_HANDLE); Action_Edit_CopyHandle16.Visible := Action_Edit_CopyHandle10.Visible; end else begin Action_Edit_Copy.Enabled := False; Action_Edit_CopyHandle10.Enabled := Action_Edit_Copy.Enabled; Action_Edit_CopyHandle16.Enabled := Action_Edit_CopyHandle10.Enabled; end; end; end; if (gfnbFormExists(App_TOOL_APITest)) then begin Action_Opt_DispAPITest.Checked := IsWindowVisible(App_TOOL_APITest.Handle); end; end; procedure TApp_TOOLWinfo.Action_Edit_CopyHandle10Execute(Sender: TObject); var l_GridRect : TGridRect; ls_Str : String; ls_Title : String; begin //10進 l_GridRect := Grid_Winfo.Selection; ls_Title := Grid_Winfo.Cells[l_GridRect.Left, 0]; if (ls_Title = Fcs_TITLE_HANDLE) then begin ls_Str := Format('%d', [T_WInfo(FList[l_GridRect.Top -1]^).hHandle]); end else if (ls_Title = Fcs_TITLE_CONTROLID) then begin ls_Str := Format('%d', [T_WInfo(FList[l_GridRect.Top -1]^).iControlID]); end else begin Exit; end; Clipboard.AsText := ls_Str; end; procedure TApp_TOOLWinfo.Action_Edit_CopyHandle16Execute(Sender: TObject); var l_GridRect : TGridRect; ls_Str : String; ls_Title : String; begin //16進 l_GridRect := Grid_Winfo.Selection; ls_Title := Grid_Winfo.Cells[l_GridRect.Left, 0]; if (ls_Title = Fcs_TITLE_HANDLE) then begin ls_Str := Format('%.8x', [T_WInfo(FList[l_GridRect.Top -1]^).hHandle]); end else if (ls_Title = Fcs_TITLE_CONTROLID) then begin ls_Str := Format('%.8x', [T_WInfo(FList[l_GridRect.Top -1]^).iControlID]); end else begin Exit; end; Clipboard.AsText := ls_Str; end; procedure TApp_TOOLWinfo.Action_Edit_CopyTreeExecute(Sender: TObject); var li_NumWidth : Integer; //行番号の最大幅 li_DepthWidth : Integer; //クラス名のインデントの最大幅 procedure _SetData(var sData: String; bVisible: Boolean; iIndex: Integer; var iCol: Integer; iRow: Integer); var li_Flag : DWORD; li_Indent : Integer; ls_Dat : String; begin if (bVisible) then begin ls_Dat := Grid_Winfo.Cells[iCol, iRow]; case iIndex of Fci_COL_CLASSNAME :begin li_Flag := DWORD(gfniStrToInt(Grid_Winfo.Cells[Fci_COL_FLAG, iRow])); li_Indent := li_Flag shr 16; ls_Dat := Copy(Format('%*s', [li_Indent, ' ']), 2, MAXINT) + ls_Dat; // ls_Dat := Format('%*s', [li_Indent -1, ' ']) + ls_Dat; if BOOL(li_Flag and Fci_FLAG_INVISIBLE) then begin //非表示なら行頭に'-'を追加 sData := '-' + ls_Dat; end else if BOOL(li_Flag and Fci_FLAG_TARGET) then begin //ターゲットウィンドウなら行頭に'* 'を追加 sData := '*' + ls_Dat; end else begin sData := ' ' + ls_Dat; end; if (li_Indent > 0) then Dec(li_Indent); sData := Format('%*d %*d %s', [li_NumWidth, iRow, li_DepthWidth, li_Indent, sData]); end; Fci_COL_TEXT :begin sData := sData + ' "' + ls_Dat + '"'; end; Fci_COL_WINDOWSIZE, Fci_COL_CLIENTSIZE, Fci_COL_CLIENTORIGIN, Fci_COL_RECT :begin sData := sData + ' (' + ls_Dat + ')'; end; else begin sData := sData + ' ' + ls_Dat; end; end; Inc(iCol); end; end; function _GetNumWidth(iNum: Integer): Integer; begin Result := Length(IntToStr(iNum)); end; var i : Integer; li_Col : Integer; li_Row : Integer; l_List : TStrings; ls_Data : String; li_Max : Integer; begin li_Max := 0; for li_Row := Grid_Winfo.FixedRows to Grid_Winfo.RowCount -1 do begin li_Max := gfniMax([li_Max, DWORD(gfniStrToInt(Grid_Winfo.Cells[Fci_COL_FLAG, li_Row])) shr 16]); end; li_DepthWidth := _GetNumWidth(li_Max); li_NumWidth := _GetNumWidth(Grid_Winfo.RowCount - Grid_Winfo.FixedRows); l_List := nil; try l_List := TStringList.Create; for li_Row := Grid_Winfo.FixedRows to Grid_Winfo.RowCount -1 do begin ls_Data := ''; li_Col := Fci_COL_START; for i := Fci_COL_START to Fci_COL_END do begin case i of Fci_COL_CLASSNAME : _SetData(ls_Data, MenuItem_Item_ClassName.Checked, i, li_Col, li_Row); Fci_COL_HANDLE : _SetData(ls_Data, MenuItem_Item_Handle.Checked, i, li_Col, li_Row); Fci_COL_TEXT : _SetData(ls_Data, MenuItem_Item_Text.Checked, i, li_Col, li_Row); Fci_COL_WINDOWSIZE : _SetData(ls_Data, MenuItem_Item_WindowSize.Checked, i, li_Col, li_Row); Fci_COL_CLIENTSIZE : _SetData(ls_Data, MenuItem_Item_ClientSize.Checked, i, li_Col, li_Row); Fci_COL_CLIENTORIGIN : _SetData(ls_Data, MenuItem_Item_ClientOrigin.Checked, i, li_Col, li_Row); Fci_COL_RECT : _SetData(ls_Data, MenuItem_Item_Rect.Checked, i, li_Col, li_Row); Fci_COL_CONTROLID : _SetData(ls_Data, MenuItem_Item_ControlID.Checked, i, li_Col, li_Row); Fci_COL_UNICODE : _SetData(ls_Data, MenuItem_Item_Unicode.Checked, i, li_Col, li_Row); Fci_COL_VISIBLE : _SetData(ls_Data, MenuItem_Item_Visible.Checked, i, li_Col, li_Row); Fci_COL_ENABLED : _SetData(ls_Data, MenuItem_Item_Enabled.Checked, i, li_Col, li_Row); Fci_COL_APITEST : _SetData(ls_Data, MenuItem_Item_APITest.Checked, i, li_Col, li_Row); end; end; l_List.Add(ls_Data) end; Clipboard.AsText := l_List.Text; Beep; finally l_List.Free; end; end; procedure TApp_TOOLWinfo.Action_Edit_CopyExecute(Sender: TObject); var l_GridRect : TGridRect; ls_Str : String; ls_Title : String; li_Value : DWORD; begin l_GridRect := Grid_Winfo.Selection; ls_Str := Grid_Winfo.Cells[l_GridRect.Left, l_GridRect.Top]; ls_Title := Grid_Winfo.Cells[l_GridRect.Left, 0]; if (ls_Title = Fcs_TITLE_HANDLE) or (ls_Title = Fcs_TITLE_CONTROLID) then begin if (ls_Title = Fcs_TITLE_HANDLE) then begin li_Value := T_WInfo(FList[l_GridRect.Top -1]^).hHandle end else begin li_Value := T_WInfo(FList[l_GridRect.Top -1]^).iControlID; end; if (gfnbKeyState(VK_SHIFT)) then begin //16進 ls_Str := Format('%.8x', [li_Value]); end else begin //10進 ls_Str := Format('%d', [li_Value]); end; end else if (ls_Title = Fcs_TITLE_CLASSNAME) then begin ls_Str := Trim(ls_Str); end; Clipboard.AsText := ls_Str; end; //ウィンドウの幅をグリッドに合わせる procedure TApp_TOOLWinfo.FSetWidth; var i, li_Width: Integer; begin li_Width := 0; for i := 0 to Grid_Winfo.ColCount -1 do begin li_Width := li_Width + Grid_Winfo.ColWidths[i] + Grid_Winfo.GridLineWidth; end; if (Grid_Winfo.BorderStyle <> bsNone) then begin Inc(li_Width, 2); end; ClientWidth := li_Width; { if (Action_Window_Simple.Checked) then begin ClientWidth := li_Width; end else begin ClientWidth := li_Width + GetSystemMetrics(SM_CXVSCROLL); end; } end; //ウィンドウの高さをグリッドに合わせる procedure TApp_TOOLWinfo.FSetHeight; var li_Height: Integer; begin li_Height := Grid_Winfo.DefaultRowHeight * Grid_Winfo.RowCount + Grid_Winfo.GridLineWidth * Grid_Winfo.RowCount + Label_ExeName.Height + Shape_Border.Height; if (Grid_Winfo.BorderStyle <> bsNone) then begin Inc(li_Height, 2); end; if (Self.ClientHeight <> li_Height) then begin Self.ClientHeight := li_Height; end; end; //常に前面に表示 procedure TApp_TOOLWinfo.Action_Opt_StayOnTopExecute(Sender: TObject); begin Action_Opt_StayOnTop.Checked := not Action_Opt_StayOnTop.Checked; if (Action_Opt_StayOnTop.Checked) then begin // SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE); SetWindowPos(Application.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE); Caption := gfnsStrHeadFit(Caption, '↑'); end else begin // SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE); SetWindowPos(Application.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE); Caption := gfnsStrHeadCut(Caption, '↑'); end; end; //すべての親ウィンドウを表示 procedure TApp_TOOLWinfo.Action_Window_AllExecute(Sender: TObject); begin if (Action_Window_Simple.Checked) then begin //簡易解析 Grid_Winfo.RowCount := 5; //lciWINDOW_OWNER + 1; ClientWidth := Grid_Winfo.Width; end else begin //すべての親を表示 //スクロールバーの分幅を狭める ClientWidth := gfniGridWidthGet(Grid_Winfo) + GetSystemMetrics(SM_CXVSCROLL); end; FSetWidth; FiPassTime := 0; TimerTimer(nil); // actWindow_SizeFitExecute(nil); end; //一時停止 procedure TApp_TOOLWinfo.Action_Capture_PauseExecute(Sender: TObject); begin Action_Capture_Pause.Checked := not(Action_Capture_Pause.Checked); Timer.Enabled := not(Action_Capture_Pause.Checked); if (Action_Capture_Pause.Checked) then begin Grid_Winfo.Color := clInfoBk; Grid_Winfo.Font.Color := clInfoText; end else begin Grid_Winfo.Color := clWindow; Grid_Winfo.Font.Color := clWindowText; end; end; //終了 procedure TApp_TOOLWinfo.Action_File_ExitExecute(Sender: TObject); begin Hide; Close; end; //--- StringGrid --- { procedure TApp_TOOLWinfo.Label_ExeNameMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin Grid_Winfo.ColWidths[Fci_COL_FLAG] := 0; if (Button = mbLeft) then begin // end else begin Grid_WinfoMouseDown(Sender, Button, Shift, X, Y); end; end; } procedure TApp_TOOLWinfo.Grid_WinfoMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var lr_Pos: TGridCoord; begin if (FbDrag = False) and (gfnbKeyState(VK_LBUTTON)) then begin lr_Pos := Grid_Winfo.MouseCoord(X, Y); if (lr_Pos.X > 0) and (lr_Pos.Y = 0) then begin FbDrag := True; end; end; end; procedure TApp_TOOLWinfo.Grid_WinfoMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if (Button = mbRight) then begin FptMouseGesture := gfnptMousePosGet; end; end; procedure TApp_TOOLWinfo.Grid_WinfoMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure _SetTag(MenuItem: TMenuItem; var iCol: Integer); begin if (MenuItem.Checked) then begin MenuItem.Tag := Grid_Winfo.ColWidths[iCol]; Inc(iCol); end; end; var i : Integer; lr_Rect : TGridRect; li_Col : Integer; li_Row : Integer; ls_Compas : String; begin if (Button = mbLeft) // and (FbDrag) then begin FbDrag := False; FSetWidth; li_Col := Fci_COL_START; for i := Fci_COL_START to Fci_COL_END do begin case i of Fci_COL_CLASSNAME :begin _SetTag(MenuItem_Item_ClassName, li_Col); end; Fci_COL_HANDLE :begin _SetTag(MenuItem_Item_Handle, li_Col); end; Fci_COL_TEXT :begin _SetTag(MenuItem_Item_Text, li_Col); end; Fci_COL_WINDOWSIZE :begin _SetTag(MenuItem_Item_WindowSize, li_Col); end; Fci_COL_CLIENTSIZE :begin _SetTag(MenuItem_Item_ClientSize, li_Col); end; Fci_COL_CLIENTORIGIN :begin _SetTag(MenuItem_Item_ClientOrigin, li_Col); end; Fci_COL_RECT :begin _SetTag(MenuItem_Item_Rect, li_Col); end; Fci_COL_CONTROLID :begin _SetTag(MenuItem_Item_ControlID, li_Col); end; Fci_COL_UNICODE :begin _SetTag(MenuItem_Item_Unicode, li_Col); end; Fci_COL_VISIBLE :begin _SetTag(MenuItem_Item_Visible, li_Col); end; Fci_COL_ENABLED :begin _SetTag(MenuItem_Item_Enabled, li_Col); end; Fci_COL_APITEST :begin _SetTag(MenuItem_Item_APITest, li_Col); end; end; end; end else if (Button = mbRight) then begin //右クリックした場所のセルを取得 //マウスジェスチャー ls_Compas := gfnsCompasGet(FptMouseGesture, gfnptMousePosGet); if (ls_Compas = '') then begin //いわゆる右クリック if (Sender <> Grid_Winfo) then begin //ポップアップメニュー Action_Edit_Copy.Enabled := False; Menu_Main.Popup(X + ClientOrigin.X, Y + ClientOrigin.Y); end else begin Grid_Winfo.MouseToCell(X, Y, li_Col, li_Row); if (li_Row = 0) then begin Menu_Item.Popup(X + Grid_Winfo.ClientOrigin.X, Y + Grid_Winfo.ClientOrigin.Y); end else begin if (li_Row > 0) then begin lr_Rect.Left := li_Col; lr_Rect.Top := li_Row; lr_Rect.Right := li_Col; lr_Rect.Bottom := li_Row; Grid_Winfo.Selection := lr_Rect; Action_Edit_Copy.Enabled := True; end else begin Action_Edit_Copy.Enabled := False; end; Menu_Main.Popup(X + Grid_Winfo.ClientOrigin.X, Y + Grid_Winfo.ClientOrigin.Y); end; end; end else if (ls_Compas = '右') then begin //API Testフォームの表示のOn/Off Action_Opt_DispAPITest.Checked := not(Action_Opt_DispAPITest.Checked); Action_Opt_DispAPITestExecute(nil); end else if (ls_Compas = '左') then begin //すべての親を表示 Action_Window_All.Checked := True; Action_Window_AllExecute(nil); end else if (ls_Compas = '上') then begin //常に前面に表示 Action_Opt_StayOnTopExecute(nil); end else if (ls_Compas = '下') then begin //一時停止 Action_Capture_PauseExecute(nil); end; end; end; // 設定ファイル ---------------------------------------------------------------- //--- IniFile --- const lcsSECT_VISIBLE = 'Visible'; lcsSECT_WIDTH = 'Width'; lcsKEY_HANDLE = 'Handle'; lcsKEY_CLASSNAME = 'Class'; lcsKEY_TEXT = 'Text'; lcsKEY_WINDOWSIZE = 'WindowSize'; lcsKEY_CLIENTSIZE = 'ClientSize'; lcsKEY_CLIENTORIGIN = 'ClientOrigin'; lcsKEY_RECT = 'Rect'; lcsKEY_CONTROLID = 'Control-ID'; lcsKEY_UNICODE = 'Unicode'; lcsKEY_VISIBLE = 'Visible'; lcsKEY_ENABLED = 'Enabled'; lcsKEY_APITEST = 'APITest'; lcsSECT_WINDOW = 'Window'; lcsKEY_WINDOW_ALL = 'AllWindow'; lcsKEY_WINDOW_PTINRECT = 'InRectWindow'; lcsKEY_WINDOW_VISIBLE = 'VisibleWindow'; // lcsKEY_WINDOW_SIMPLE = 'Simple'; lcsSECT_OPT = 'Option'; lcsKEY_STAYONTOP = 'StayOnTop'; // lcsKEY_ENUMCHILDWINDOW = 'EnumChildWindow'; lcsKEY_OPT_APITEST = 'APITestWindow'; procedure TApp_TOOLWinfo.FLoadIni; const lci_MINWIDTH = 10; var l_IniFile: TMyIniFile; begin //Shift+Ctrl起動で設定を読み込まない。 if (gfnbKeyStateAnd([VK_SHIFT, VK_CONTROL])) then begin Exit; end; l_IniFile := TMyIniFile.Create; with l_IniFile do begin try SetMonitorBoundsRect(Self); //クラス名は必ずチェック // MenuItem_ClassName.Checked := ReadBool(lcsSECT_VISIBLE, lcsKEY_CLASSNAME, MenuItem_Item_ClassName.Checked); MenuItem_Item_Handle.Checked := ReadBool(lcsSECT_VISIBLE, lcsKEY_HANDLE, MenuItem_Item_Handle.Checked); MenuItem_Item_Text.Checked := ReadBool(lcsSECT_VISIBLE, lcsKEY_TEXT, MenuItem_Item_Text.Checked); MenuItem_Item_WindowSize.Checked := ReadBool(lcsSECT_VISIBLE, lcsKEY_WINDOWSIZE, MenuItem_Item_WindowSize.Checked); MenuItem_Item_ClientSize.Checked := ReadBool(lcsSECT_VISIBLE, lcsKEY_CLIENTSIZE, MenuItem_Item_ClientSize.Checked); MenuItem_Item_ClientOrigin.Checked := ReadBool(lcsSECT_VISIBLE, lcsKEY_CLIENTORIGIN, MenuItem_Item_ClientOrigin.Checked); MenuItem_Item_Rect.Checked := ReadBool(lcsSECT_VISIBLE, lcsKEY_RECT, MenuItem_Item_Rect.Checked); MenuItem_Item_ControlID.Checked := ReadBool(lcsSECT_VISIBLE, lcsKEY_CONTROLID, MenuItem_Item_ControlID.Checked); MenuItem_Item_Unicode.Checked := ReadBool(lcsSECT_VISIBLE, lcsKEY_UNICODE, MenuItem_Item_Unicode.Checked); MenuItem_Item_Visible.Checked := ReadBool(lcsSECT_VISIBLE, lcsKEY_VISIBLE, MenuItem_Item_Visible.Checked); MenuItem_Item_Enabled.Checked := ReadBool(lcsSECT_VISIBLE, lcsKEY_ENABLED, MenuItem_Item_Enabled.Checked); MenuItem_Item_APITest.Checked := ReadBool(lcsSECT_VISIBLE, lcsKEY_APITEST, MenuItem_Item_APITest.Checked); MenuItem_Item_ClassName.Tag := gfniNumLimit(ReadInteger(lcsSECT_WIDTH, lcsKEY_CLASSNAME, MenuItem_Item_ClassName.Tag), Grid_Winfo.DefaultColWidth, Grid_Winfo.ClientWidth); //クラス名の幅だけは最小値を設ける MenuItem_Item_Handle.Tag := gfniMax([ReadInteger(lcsSECT_WIDTH, lcsKEY_HANDLE, MenuItem_Item_Handle.Tag), lci_MINWIDTH]); MenuItem_Item_Text.Tag := gfniMax([ReadInteger(lcsSECT_WIDTH, lcsKEY_TEXT, MenuItem_Item_Text.Tag), lci_MINWIDTH]); MenuItem_Item_WindowSize.Tag := gfniMax([ReadInteger(lcsSECT_WIDTH, lcsKEY_WINDOWSIZE, MenuItem_Item_WindowSize.Tag), lci_MINWIDTH]); MenuItem_Item_ClientSize.Tag := gfniMax([ReadInteger(lcsSECT_WIDTH, lcsKEY_CLIENTSIZE, MenuItem_Item_ClientSize.Tag), lci_MINWIDTH]); MenuItem_Item_ClientOrigin.Tag := gfniMax([ReadInteger(lcsSECT_WIDTH, lcsKEY_CLIENTORIGIN, MenuItem_Item_ClientOrigin.Tag), lci_MINWIDTH]); MenuItem_Item_Rect.Tag := gfniMax([ReadInteger(lcsSECT_WIDTH, lcsKEY_RECT, MenuItem_Item_Rect.Tag), lci_MINWIDTH]); MenuItem_Item_ControlID.Tag := gfniMax([ReadInteger(lcsSECT_WIDTH, lcsKEY_CONTROLID, MenuItem_Item_ControlID.Tag), lci_MINWIDTH]); MenuItem_Item_Unicode.Tag := gfniMax([ReadInteger(lcsSECT_WIDTH, lcsKEY_UNICODE, MenuItem_Item_Unicode.Tag), lci_MINWIDTH]); MenuItem_Item_Visible.Tag := gfniMax([ReadInteger(lcsSECT_WIDTH, lcsKEY_VISIBLE, MenuItem_Item_Visible.Tag), lci_MINWIDTH]); MenuItem_Item_Enabled.Tag := gfniMax([ReadInteger(lcsSECT_WIDTH, lcsKEY_ENABLED, MenuItem_Item_Enabled.Tag), lci_MINWIDTH]); MenuItem_Item_APITest.Tag := gfniMax([ReadInteger(lcsSECT_WIDTH, lcsKEY_APITEST, MenuItem_Item_APITest.Tag), lci_MINWIDTH]); MenuItem_Item_HandleClick(nil); //Window Action_Window_PtInRect.Checked := ReadBool(lcsSECT_WINDOW, lcsKEY_WINDOW_PTINRECT, Action_Window_PtInRect.Checked); Action_Window_Visible.Checked := ReadBool(lcsSECT_WINDOW, lcsKEY_WINDOW_VISIBLE, Action_Window_Visible.Checked); // Action_Window_Simple.Checked := ReadBool(lcsSECT_WINDOW, lcsKEY_WINDOW_SIMPLE, Action_Window_Simple.Checked); Action_Window_All.Checked := ReadBool(lcsSECT_WINDOW, lcsKEY_WINDOW_ALL, Action_Window_All.Checked); //Option Action_Opt_StayOnTop.Checked := not(ReadBool(lcsSECT_OPT, lcsKEY_STAYONTOP, Action_Opt_StayOnTop.Checked)); //↓でCheckedを反転させている Action_Opt_StayOnTopExecute(nil); // Action_Opt_EnumChildWindow.Checked := ReadBool(lcsSECT_OPT, lcsKEY_ENUMCHILDWINDOW, Action_Opt_EnumChildWindow.Checked); Action_Opt_EnumChildWindow.Checked := True; Action_Opt_DispAPITest.Checked := ReadBool(lcsSECT_OPT, lcsKEY_OPT_APITEST, Action_Opt_DispAPITest.Checked); finally Free; end; end; end; procedure TApp_TOOLWinfo.FSaveIni; var l_IniFile: TMyIniFile; begin //Shift+Ctrl終了で設定を書き込まない。 if (gfnbKeyStateAnd([VK_SHIFT, VK_CONTROL])) then begin Exit; end; l_IniFile := TMyIniFile.Create; with l_IniFile do begin try WriteBoundsRect(Self); WriteBool(lcsSECT_VISIBLE, lcsKEY_HANDLE, MenuItem_Item_Handle.Checked); // WriteBool(lcsSECT_VISIBLE, lcsKEY_CLASSNAME, MenuItem_Item_ClassName.Checked); WriteBool(lcsSECT_VISIBLE, lcsKEY_HANDLE, MenuItem_Item_Handle.Checked); WriteBool(lcsSECT_VISIBLE, lcsKEY_TEXT, MenuItem_Item_Text.Checked); WriteBool(lcsSECT_VISIBLE, lcsKEY_WINDOWSIZE, MenuItem_Item_WindowSize.Checked); WriteBool(lcsSECT_VISIBLE, lcsKEY_CLIENTSIZE, MenuItem_Item_ClientSize.Checked); WriteBool(lcsSECT_VISIBLE, lcsKEY_CLIENTORIGIN, MenuItem_Item_ClientOrigin.Checked); WriteBool(lcsSECT_VISIBLE, lcsKEY_RECT, MenuItem_Item_Rect.Checked); WriteBool(lcsSECT_VISIBLE, lcsKEY_CONTROLID, MenuItem_Item_ControlID.Checked); WriteBool(lcsSECT_VISIBLE, lcsKEY_UNICODE, MenuItem_Item_Unicode.Checked); WriteBool(lcsSECT_VISIBLE, lcsKEY_VISIBLE, MenuItem_Item_Visible.Checked); WriteBool(lcsSECT_VISIBLE, lcsKEY_ENABLED, MenuItem_Item_Enabled.Checked); WriteBool(lcsSECT_VISIBLE, lcsKEY_APITEST, MenuItem_Item_APITest.Checked); WriteInteger(lcsSECT_WIDTH, lcsKEY_CLASSNAME, MenuItem_Item_ClassName.Tag); //クラス名の幅だけは最小値を設ける WriteInteger(lcsSECT_WIDTH, lcsKEY_HANDLE, MenuItem_Item_Handle.Tag); WriteInteger(lcsSECT_WIDTH, lcsKEY_TEXT, MenuItem_Item_Text.Tag); WriteInteger(lcsSECT_WIDTH, lcsKEY_WINDOWSIZE, MenuItem_Item_WindowSize.Tag); WriteInteger(lcsSECT_WIDTH, lcsKEY_CLIENTSIZE, MenuItem_Item_ClientSize.Tag); WriteInteger(lcsSECT_WIDTH, lcsKEY_CLIENTORIGIN, MenuItem_Item_ClientOrigin.Tag); WriteInteger(lcsSECT_WIDTH, lcsKEY_RECT, MenuItem_Item_Rect.Tag); WriteInteger(lcsSECT_WIDTH, lcsKEY_CONTROLID, MenuItem_Item_ControlID.Tag); WriteInteger(lcsSECT_WIDTH, lcsKEY_UNICODE, MenuItem_Item_Unicode.Tag); WriteInteger(lcsSECT_WIDTH, lcsKEY_VISIBLE, MenuItem_Item_Visible.Tag); WriteInteger(lcsSECT_WIDTH, lcsKEY_ENABLED, MenuItem_Item_Enabled.Tag); WriteInteger(lcsSECT_WIDTH, lcsKEY_APITEST, MenuItem_Item_APITest.Tag); WriteBool(lcsSECT_WINDOW, lcsKEY_WINDOW_PTINRECT, Action_Window_PtInRect.Checked); WriteBool(lcsSECT_WINDOW, lcsKEY_WINDOW_VISIBLE, Action_Window_Visible.Checked); WriteBool(lcsSECT_WINDOW, lcsKEY_WINDOW_ALL, Action_Window_All.Checked); // WriteBool(lcsSECT_WINDOW, lcsKEY_WINDOW_SIMPLE, Action_Window_Simple.Checked); //Option WriteBool(lcsSECT_OPT, lcsKEY_STAYONTOP, Action_Opt_StayOnTop.Checked); // WriteBool(lcsSECT_OPT, lcsKEY_ENUMCHILDWINDOW, Action_Opt_EnumChildWindow.Checked); WriteBool(lcsSECT_OPT, lcsKEY_OPT_APITEST, Action_Opt_DispAPITest.Checked); finally Free; end; end; end; (* function TApp_TOOLWinfo.FLoadBin: Boolean; const lci_MINWIDTH = 10; begin Result := False; //Shift+Ctrl起動で設定を読み込まない。 if (gfnbKeyStateAnd([VK_SHIFT, VK_CONTROL])) then begin Exit; end; Result := G_fnbSettingRead; //(lr_SettingInfo, lr_ShortCutKeys, lr_MouseGesture); if not(Result) then begin FLoadIni; Exit; end; //[Bounds] gpcSetMonitorBounds(Self, G_rSettingInfo.rcRect); //[ItemDisp] //クラス名は必ずチェック MenuItem_Item_ClassName.Checked := True; MenuItem_Item_Handle.Checked := gfnbFlagCheck(G_rSettingInfo.iItemHideFlag, G_ciFLG_ITEM_HANDLE); MenuItem_Item_Text.Checked := gfnbFlagCheck(G_rSettingInfo.iItemHideFlag, G_ciFLG_ITEM_TEXT); MenuItem_Item_WindowSize.Checked := gfnbFlagCheck(G_rSettingInfo.iItemHideFlag, G_ciFLG_ITEM_WINDOWSIZE); MenuItem_Item_ClientSize.Checked := gfnbFlagCheck(G_rSettingInfo.iItemHideFlag, G_ciFLG_ITEM_CLIENTSIZE); MenuItem_Item_ClientOrigin.Checked := gfnbFlagCheck(G_rSettingInfo.iItemHideFlag, G_ciFLG_ITEM_CLIENTORIGIN); MenuItem_Item_Rect.Checked := gfnbFlagCheck(G_rSettingInfo.iItemHideFlag, G_ciFLG_ITEM_RECT); MenuItem_Item_ControlID.Checked := gfnbFlagCheck(G_rSettingInfo.iItemHideFlag, G_ciFLG_ITEM_CONTROLID); MenuItem_Item_Unicode.Checked := gfnbFlagCheck(G_rSettingInfo.iItemHideFlag, G_ciFLG_ITEM_ISUNICODE); MenuItem_Item_Visible.Checked := gfnbFlagCheck(G_rSettingInfo.iItemHideFlag, G_ciFLG_ITEM_ISVISIBLE); MenuItem_Item_Enabled.Checked := gfnbFlagCheck(G_rSettingInfo.iItemHideFlag, G_ciFLG_ITEM_ISENABLED); MenuItem_Item_APITest.Checked := gfnbFlagCheck(G_rSettingInfo.iItemHideFlag, G_ciFLG_ITEM_APITEST); //[ItemWidth] MenuItem_Item_ClassName.Tag := gfniNumLimit(G_rSettingInfo.iItemWidth[Fci_COL_CLASSNAME], Grid_Winfo.DefaultColWidth, Grid_Winfo.ClientWidth); MenuItem_Item_Handle.Tag := gfniMax([G_rSettingInfo.iItemWidth[Fci_COL_HANDLE], lci_MINWIDTH]); MenuItem_Item_Text.Tag := gfniMax([G_rSettingInfo.iItemWidth[Fci_COL_TEXT], lci_MINWIDTH]); MenuItem_Item_WindowSize.Tag := gfniMax([G_rSettingInfo.iItemWidth[Fci_COL_WINDOWSIZE], lci_MINWIDTH]); MenuItem_Item_ClientSize.Tag := gfniMax([G_rSettingInfo.iItemWidth[Fci_COL_CLIENTSIZE], lci_MINWIDTH]); MenuItem_Item_ClientOrigin.Tag := gfniMax([G_rSettingInfo.iItemWidth[Fci_COL_CLIENTORIGIN], lci_MINWIDTH]); MenuItem_Item_Rect.Tag := gfniMax([G_rSettingInfo.iItemWidth[Fci_COL_RECT], lci_MINWIDTH]); MenuItem_Item_ControlID.Tag := gfniMax([G_rSettingInfo.iItemWidth[Fci_COL_CONTROLID], lci_MINWIDTH]); MenuItem_Item_Unicode.Tag := gfniMax([G_rSettingInfo.iItemWidth[Fci_COL_UNICODE], lci_MINWIDTH]); MenuItem_Item_Visible.Tag := gfniMax([G_rSettingInfo.iItemWidth[Fci_COL_VISIBLE], lci_MINWIDTH]); MenuItem_Item_Enabled.Tag := gfniMax([G_rSettingInfo.iItemWidth[Fci_COL_ENABLED], lci_MINWIDTH]); MenuItem_Item_APITest.Tag := gfniMax([G_rSettingInfo.iItemWidth[Fci_COL_APITEST], lci_MINWIDTH]); MenuItem_Item_HandleClick(nil); //[WindowDispType] { case G_rSettingInfo.iWindowDispType of G_ciFLG_WINDOW_PTINRECT: Action_Window_PtInRect.Checked := True; G_ciFLG_WINDOW_VISIBLE : Action_Window_Visible.Checked := True; G_ciFLG_WINDOW_SIMPLE : Action_Window_Simple.Checked := True; else Action_Window_All.Checked := True; //G_ciFLG_WINDOW_ALL end; } Action_Window_All.Checked := True; //Option Action_Opt_StayOnTop.Checked := not(gfnbFlagCheck(G_rSettingInfo.iOptionFlag, G_ciFLG_OPT_STAYONTOP)); //↓でCheckedを反転させているので↑で反転させる Action_Opt_StayOnTopExecute(nil); // Action_Opt_EnumChildWindow.Checked := gfnbFlagCheck(G_rSettingInfo.iOptionFlag, G_ciFLG_OPT_ENUMCHILDWINDOW); Action_Opt_EnumChildWindow.Checked := True; Action_Opt_DispAPITest.Checked := gfnbFlagCheck(G_rSettingInfo.iOptionFlag, G_ciFLG_OPT_DISP_APITEST); end; //設定保存 procedure TApp_TOOLWinfo.FSaveBin; begin //Shift+Ctrl起動で設定を書き込まない。 if (gfnbKeyStateAnd([VK_SHIFT, VK_CONTROL])) then begin Exit; end; //[Bounds] G_rSettingInfo.rcRect := Self.BoundsRect; //[Item]項目の表示・非表示 G_rSettingInfo.iItemHideFlag := 0; //初期化する if (MenuItem_Item_Handle.Checked) then G_rSettingInfo.iItemHideFlag := G_rSettingInfo.iItemHideFlag or G_ciFLG_ITEM_HANDLE; if (MenuItem_Item_Text.Checked) then G_rSettingInfo.iItemHideFlag := G_rSettingInfo.iItemHideFlag or G_ciFLG_ITEM_TEXT; if (MenuItem_Item_WindowSize.Checked) then G_rSettingInfo.iItemHideFlag := G_rSettingInfo.iItemHideFlag or G_ciFLG_ITEM_WINDOWSIZE; if (MenuItem_Item_ClientSize.Checked) then G_rSettingInfo.iItemHideFlag := G_rSettingInfo.iItemHideFlag or G_ciFLG_ITEM_CLIENTSIZE; if (MenuItem_Item_ClientOrigin.Checked) then G_rSettingInfo.iItemHideFlag := G_rSettingInfo.iItemHideFlag or G_ciFLG_ITEM_CLIENTORIGIN; if (MenuItem_Item_Rect.Checked) then G_rSettingInfo.iItemHideFlag := G_rSettingInfo.iItemHideFlag or G_ciFLG_ITEM_RECT; if (MenuItem_Item_ControlID.Checked) then G_rSettingInfo.iItemHideFlag := G_rSettingInfo.iItemHideFlag or G_ciFLG_ITEM_CONTROLID; if (MenuItem_Item_Unicode.Checked) then G_rSettingInfo.iItemHideFlag := G_rSettingInfo.iItemHideFlag or G_ciFLG_ITEM_ISUNICODE; if (MenuItem_Item_Visible.Checked) then G_rSettingInfo.iItemHideFlag := G_rSettingInfo.iItemHideFlag or G_ciFLG_ITEM_ISVISIBLE; if (MenuItem_Item_Enabled.Checked) then G_rSettingInfo.iItemHideFlag := G_rSettingInfo.iItemHideFlag or G_ciFLG_ITEM_ISENABLED; if (MenuItem_Item_APITest.Checked) then G_rSettingInfo.iItemHideFlag := G_rSettingInfo.iItemHideFlag or G_ciFLG_ITEM_APITEST; //[ItemWidth] G_rSettingInfo.iItemWidth[Fci_COL_CLASSNAME] := MenuItem_Item_ClassName.Tag; G_rSettingInfo.iItemWidth[Fci_COL_HANDLE] := MenuItem_Item_Handle.Tag; G_rSettingInfo.iItemWidth[Fci_COL_TEXT] := MenuItem_Item_Text.Tag; G_rSettingInfo.iItemWidth[Fci_COL_WINDOWSIZE] := MenuItem_Item_WindowSize.Tag; G_rSettingInfo.iItemWidth[Fci_COL_CLIENTSIZE] := MenuItem_Item_ClientSize.Tag; G_rSettingInfo.iItemWidth[Fci_COL_CLIENTORIGIN] := MenuItem_Item_ClientOrigin.Tag; G_rSettingInfo.iItemWidth[Fci_COL_RECT] := MenuItem_Item_Rect.Tag; G_rSettingInfo.iItemWidth[Fci_COL_CONTROLID] := MenuItem_Item_ControlID.Tag; G_rSettingInfo.iItemWidth[Fci_COL_UNICODE] := MenuItem_Item_Unicode.Tag; G_rSettingInfo.iItemWidth[Fci_COL_VISIBLE] := MenuItem_Item_Visible.Tag; G_rSettingInfo.iItemWidth[Fci_COL_ENABLED] := MenuItem_Item_Enabled.Tag; G_rSettingInfo.iItemWidth[Fci_COL_APITEST] := MenuItem_Item_APITest.Tag; //Window if (Action_Window_PtInRect.Checked) then begin G_rSettingInfo.iWindowDispType := G_ciFLG_WINDOW_PTINRECT; end else if (Action_Window_Visible.Checked) then begin G_rSettingInfo.iWindowDispType := G_ciFLG_WINDOW_VISIBLE; end else if (Action_Window_Simple.Checked) then begin G_rSettingInfo.iWindowDispType := G_ciFLG_WINDOW_SIMPLE; end else // if (Action_Window_All.Checked) // then begin G_rSettingInfo.iWindowDispType := G_ciFLG_WINDOW_ALL; end; //Option G_rSettingInfo.iOptionFlag := 0; //初期化する if (Action_Opt_StayOnTop.Checked) then G_rSettingInfo.iOptionFlag := G_rSettingInfo.iOptionFlag or G_ciFLG_OPT_STAYONTOP; if (Action_Opt_EnumChildWindow.Checked) then G_rSettingInfo.iOptionFlag := G_rSettingInfo.iOptionFlag or G_ciFLG_OPT_ENUMCHILDWINDOW; if (Action_Opt_DispAPITest.Checked) then G_rSettingInfo.iOptionFlag := G_rSettingInfo.iOptionFlag or G_ciFLG_OPT_DISP_APITEST; G_pcSettingWrite; end; *) procedure TApp_TOOLWinfo.Grid_WinfoDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var l_Rect : TRect; li_Flag : DWORD; begin with Grid_Winfo do begin Canvas.Font.Assign(Font); // Canvas.Font.Name := Font.Name; //'MS ゴシック'; // Canvas.Font.Style := Font.Style; //[]; l_Rect := Rect; Inc(l_Rect.Left, G_ciMARGIN); if (ARow = 0) then begin //タイトル Canvas.Font.Color := clBtnText; Canvas.Brush.Color := clBtnFace; Canvas.FillRect(Rect); li_Flag := DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER; if (Canvas.TextWidth(Cells[ACol, ARow]) <= ColWidths[ACol]) then begin li_Flag := li_Flag or DT_CENTER; end; DrawText(Canvas.Handle, PChar(Cells[ACol, ARow]), -1, l_Rect, li_Flag); { if (Canvas.TextWidth(Cells[ACol, ARow]) > ColWidths[ACol]) then begin //タイトル文字列がセル幅より大きければ左寄せ DrawText(Canvas.Handle, PChar(Cells[ACol, ARow]), -1, lrc_Rect, DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER); end else begin //タイトルはセンタリング DrawText(Canvas.Handle, PChar(Cells[ACol, ARow]), -1, lrc_Rect, DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER or DT_CENTER); end; } end else begin if (gdSelected in State) then begin Canvas.Font.Color := clHighlightText; Canvas.Brush.Color := clHighlight; end else begin Canvas.Font.Color := Font.Color; //clWindowText; Canvas.Brush.Color := Color; //clWindow; end; li_Flag := DWORD(gfniStrToInt(Cells[Fci_COL_FLAG, ARow])); if (ACol = Fci_COL_CLASSNAME) then begin; //クラス名 if BOOL(li_Flag and Fci_FLAG_OUTOFRECT) then begin //範囲外なら打消し表示 //Canvas.Font.Style := [fsStrikeOut]; Canvas.Font.Style := [fsUnderline]; //Canvas.Font.Style := [fsItalic]; end; if BOOL(li_Flag and Fci_FLAG_INVISIBLE) then begin //非表示なら淡色表示 Canvas.Font.Color := clGrayText; end else if BOOL(li_Flag and Fci_FLAG_TARGET) then begin //ターゲットウィンドウなら太字で表示 Canvas.Font.Style := [fsBold]; end; Inc(l_Rect.Left, Self.Canvas.TextWidth(Copy(Format('%*s', [li_Flag shr 16, ' ']), 2, MAXINT))); end else if (ACol = Fci_COL_RECT) then begin //Rect if BOOL(li_Flag and Fci_FLAG_OUTOFRECT) then begin //範囲外なら淡色表示 Canvas.Font.Color := clGrayText; end; end; Canvas.FillRect(Rect); // if (ACol = Fci_COL_FLAG) // then begin // DrawText(Canvas.Handle, PChar(Format('"%*s"', [li_Flag shr 16, ' '])), -1, l_Rect, DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER); // end // else // begin DrawText(Canvas.Handle, PChar(Cells[ACol, ARow]), -1, l_Rect, DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER); // end; end; end; end; procedure TApp_TOOLWinfo.Grid_WinfoDblClick(Sender: TObject); begin FSetWidth; end; procedure TApp_TOOLWinfo.Action_Opt_SizeFitExecute(Sender: TObject); begin FiPassTime := 0; //すぐに更新 TimerTimer(nil); FSetWidth; FSetHeight; end; procedure TApp_TOOLWinfo.Action_Help_VersionInfoExecute(Sender: TObject); begin gpcVersionInfoCreate; gpcVersionInfoMemoSet( 'ウィンドウの親子関係をクラス名のインデントで表現'#13 + // '上にいくほど手前のウィンドウ'#13#13 + '太字はマウス下にある一番手前のウィンドウ'#13 + 'アンダーライン表示はマウス位置にかからないウィンドウ'#13 + '淡色表示は非可視のウィンドウ'//#13#13 + // Format('「%s」でマウス位置にかからないウィンドウを非表示に', [gfnsShortCutTextErase(actWindow_PtInRect.Caption)]) + #13 + // Format('「%s」で更に非可視ウィンドウを非表示に', [gfnsShortCutTextErase(actWindow_Visible.Caption)]) ); gpcVersionInfoURLSet('http://drang.s4.xrea.com/program/tool/winfo/help/'); gpcVersionInfoShowModal; gpcVersionInfoRelease; end; procedure TApp_TOOLWinfo.actNop(Sender: TObject); begin //何もしない end; procedure TApp_TOOLWinfo.ApplicationEvents1Exception(Sender: TObject; E: Exception); begin gpcShowMessage(E.Message); end; procedure TApp_TOOLWinfo.Action_Opt_DispAPITestExecute(Sender: TObject); begin G_CreateAPITestForm; App_TOOL_APITest.Visible := Action_Opt_DispAPITest.Checked; if (Action_Opt_DispAPITest.Checked) and not(MenuItem_Item_APITest.Checked) then begin MenuItem_Item_APITest.Checked := True; MenuItem_Item_HandleClick(nil); end; end; end.