unit windowstyle; //{$DEFINE _DEBUG} interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Menus, ActnList, ComCtrls, my_settingfile; type TApp_BugsEyeWindowStyle = class(TForm) ActionList1: TActionList; Action_WindowStyle_TextOpen: TAction; Action_WindowStyle_TextCopy: TAction; actFile_Close: TAction; actMenu_Popup: TAction; mnuWindowStyle: TPopupMenu; mniPWinStyleText_Copy: TMenuItem; mniPWindowStyle_Line2: TMenuItem; mniPFile_Close: TMenuItem; pnlControl: TPanel; Shape2: TShape; chkStatic: TCheckBox; chkEdit: TCheckBox; chkButton: TCheckBox; chkComboBox: TCheckBox; chkListBox: TCheckBox; chkDialog: TCheckBox; chkScrollBar: TCheckBox; edtStyle: TMemo; edtExStyle: TMemo; edtButton: TMemo; edtEdit: TMemo; edtStatic: TMemo; edtComboBox: TMemo; edtListBox: TMemo; Splitter1: TSplitter; ListBox_Style: TListBox; Memo_Hint: TMemo; procedure Action_WindowStyle_TextOpenExecute(Sender: TObject); procedure Action_WindowStyle_TextCopyExecute(Sender: TObject); procedure actFile_CloseExecute (Sender: TObject); procedure actMenu_PopupExecute (Sender: TObject); procedure FormCreate (Sender: TObject); procedure FormClose (Sender: TObject; var Action: TCloseAction); procedure FormKeyUp (Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState); procedure chkButtonClick(Sender: TObject); procedure ListBox_StyleClick(Sender: TObject); procedure ListBox_StyleDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); private { Private 宣言 } // F_bmpBuff : TBitmap; // F_iLineHeight : Integer; // F_clBrushColor, // F_clFontColor : TColor; FiStyle : Longint; FiExStyle : Longint; procedure FSetConfig; procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND; public { Public 宣言 } procedure DrawStyle(AList: TStrings; hHandle: HWND; sClassName: String; sWinText: WideString; iStyle, iStyleEx: LongInt); procedure SetTextSize; // property BackColor: TColor read F_clBrushColor write F_clBrushColor; // property TextColor: TColor read F_clFontColor write F_clFontColor; end; //function gfnbStyleCheck(iStyle: Longint; iCheck: Longint): Boolean; var App_BugsEyeWindowStyle: TApp_BugsEyeWindowStyle; //============================================================================== implementation uses {$IFDEF _DEBUG} myDebug, {$ENDIF} lang, general, main; {$R *.dfm} procedure TApp_BugsEyeWindowStyle.WMSysCommand(var Msg: TWMSysCommand); begin case Msg.CmdType of 61587 :begin //システムアイコンクリック actMenu_PopupExecute(nil); end; else begin inherited; end; end; end; procedure TApp_BugsEyeWindowStyle.DrawStyle(AList: TStrings; hHandle: HWND; sClassName: String; sWinText: WideString; iStyle, iStyleEx: LongInt); procedure _AddList(AList: TStrings; sStr: WideString); begin if (AList = nil) then begin ListBox_Style.Items.Add(sStr); end else begin App_BugsEye.AddList(AList, sStr); end; end; procedure _ChkStyle(AList: TStrings; iStyle: Longint; StyleList: TMemo); const lciPOS = 10; //数値を取り出すため var li_Comp: Longint; i: Integer; ls_Str : String; begin for i := 0 to StyleList.Lines.Count-1 do begin ls_Str := StyleList.Lines[i]; if (Trim(ls_Str) = '') then begin Continue; end; li_Comp := Longint(StrToIntDef(Trim(Copy(ls_Str, 1, lciPOS)), 0)); if (li_Comp = 0) then begin if ((iStyle and 1) = 0) then begin _AddList(AList, ls_Str); end; end else if (gfnbFlagCheck(iStyle, li_Comp)) then begin _AddList(AList, ls_Str); end; end; end; //var // ls_Title : WideString; begin //開くのときは更新処理をしない。 // if (actWindowStyleText_Open.Tag = 1) then Exit; try if (AList = nil) then begin ListBox_Style.Items.BeginUpdate; end; if (FiStyle = iStyle) and (FiExStyle = iStyleEx) and (AList = nil) then begin //ウィンドウハンドル、クラス名、ウィンドウテキストを出力。 // _AddList(AList, WideFormat(G_csWINSTYLE_STYLE, [LowerCase(Format('%x', [hHandle])), hHandle, sClassName, sWinText])); end else begin if (AList = nil) then begin FiStyle := iStyle; FiExStyle := iStyleEx; ListBox_Style.Items.Clear; end; //ウィンドウハンドル、クラス名、ウィンドウテキストを出力。 _AddList(AList, WideFormat('0x%.8x %0:d %s "%s"', [hHandle, sClassName, sWinText])); //ウィンドウスタイル。 _AddList(AList, Format(#9'%10s %s', [Format('0x%.8x %0:u', [DWORD(iStyle)]), G_csWINSTYLE_STYLE])); _ChkStyle(AList, iStyle, edtStyle); //拡張ウィンドウスタイル _AddList(AList, Format(#9'%10s %s', [Format('0x%.8x %0:u', [DWORD(iStyleEx)]), G_csWINSTYLE_STYLEEX])); _ChkStyle(AList, iStyleEx, edtExStyle); //ボタンコントロール if (chkButton.Checked) then begin _AddList(AList, Format(#9'%10s %s', [' ', G_csWINSTYLE_BUTTON])); _ChkStyle(AList, iStyle, edtButton); end; //エディットコントロール if (chkEdit.Checked) then begin _AddList(AList, Format(#9'%10s %s', [' ', G_csWINSTYLE_EDIT])); _ChkStyle(AList, iStyle, edtEdit); end; //スタティックコントロール if (chkStatic.Checked) then begin _AddList(AList, Format(#9'%10s %s', [' ', G_csWINSTYLE_STATIC])); _ChkStyle(AList, iStyle, edtStatic); end; //コンボボックスコントロール if (chkComboBox.Checked) then begin _AddList(AList, Format(#9'%10s %s', [' ', G_csWINSTYLE_COMBOBOX])); _ChkStyle(AList, iStyle, edtComboBox); end; //リストボックスコントロール if (chkListBox.Checked) then begin _AddList(AList, Format(#9'%10s %s', [' ', G_csWINSTYLE_LISTBOX])); _ChkStyle(AList, iStyle, edtListBox); end; end; finally if (AList = nil) then begin ListBox_Style.Items.EndUpdate; end; end; end; procedure TApp_BugsEyeWindowStyle.FormCreate(Sender: TObject); var lh_Menu : HMENU; begin {$IFDEF _DEBUG} myDebug.gpcMessageModeSet(True); {$ENDIF} //システムメニュー 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); ListBox_Style.Align := alClient; ListBox_Style.DoubleBuffered := True; edtStyle.SetBounds (-1, -1, 0, 0); edtExStyle.SetBounds (-1, -1, 0, 0); edtButton.SetBounds (-1, -1, 0, 0); edtEdit.SetBounds (-1, -1, 0, 0); edtComboBox.SetBounds(-1, -1, 0, 0); edtListBox.SetBounds (-1, -1, 0, 0); edtStatic.SetBounds (-1, -1, 0, 0); SetTextSize; FSetConfig; end; procedure TApp_BugsEyeWindowStyle.FormClose(Sender: TObject; var Action: TCloseAction); begin App_BugsEye.Action_WinInfo_StyleVerbose.Checked := False; //actWinInfo_StyleVerboseExecuteは呼ばなくて良い // ShowWindow(Self.Handle, SW_HIDE); end; procedure TApp_BugsEyeWindowStyle.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin App_BugsEye.FormKeyDown(Sender, Key, Shift); end; procedure TApp_BugsEyeWindowStyle.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); begin case Key of VK_APPS :begin actMenu_PopupExecute(nil); Key := 0; end; VK_F10 :begin if (ssAlt in Shift) or (ssCtrl in Shift) then begin App_BugsEye.FormKeyUp(Sender, Key, Shift); end else begin actMenu_PopupExecute(nil); Key := 0; end; end; else begin App_BugsEye.FormKeyUp(Sender, Key, Shift); end; end; end; procedure TApp_BugsEyeWindowStyle.actFile_CloseExecute(Sender: TObject); begin Close; end; procedure TApp_BugsEyeWindowStyle.SetTextSize; begin ListBox_Style.Font.Assign(App_BugsEye.DrawFont); end; procedure TApp_BugsEyeWindowStyle.FSetConfig; begin if (gfniRectWidth (G_WindowStyleInfo.rcRect) = 0) or (gfniRectHeight(G_WindowStyleInfo.rcRect) = 0) then begin Exit; end; gpcSetMonitorBounds(Self, G_WindowStyleInfo.rcRect); Memo_Hint.Height := G_WindowStyleInfo.iHintHeight; if (gfnbFlagCheck(G_WindowStyleInfo.iCheckFlag, chkButton.Tag)) then chkButton.Checked := True; if (gfnbFlagCheck(G_WindowStyleInfo.iCheckFlag, chkEdit.Tag)) then chkEdit.Checked := True; if (gfnbFlagCheck(G_WindowStyleInfo.iCheckFlag, chkStatic.Tag)) then chkStatic.Checked := True; if (gfnbFlagCheck(G_WindowStyleInfo.iCheckFlag, chkComboBox.Tag)) then chkComboBox.Checked := True; if (gfnbFlagCheck(G_WindowStyleInfo.iCheckFlag, chkListBox.Tag)) then chkListBox.Checked := True; if (gfnbFlagCheck(G_WindowStyleInfo.iCheckFlag, chkDialog.Tag)) then chkDialog.Checked := True; if (gfnbFlagCheck(G_WindowStyleInfo.iCheckFlag, chkScrollBar.Tag)) then chkScrollBar.Checked := True; end; procedure TApp_BugsEyeWindowStyle.chkButtonClick(Sender: TObject); begin FiStyle := Longint(-1); FiExStyle := Longint(-1); if (gfnbFormExists(App_BugsEyeWindowStyle)) then begin App_BugsEye.DrawNow; end; end; procedure TApp_BugsEyeWindowStyle.Action_WindowStyle_TextOpenExecute(Sender: TObject); //表示内容を*.txtに関連付けられたアプリで開く。 begin //更新処理をスキップさせるため Action_WindowStyle_TextOpen.Tag := 1; App_BugsEye.Action_Copy_WinInfoStyleVerbose.OnExecute(Action_WindowStyle_TextOpen); Action_WindowStyle_TextOpen.Tag := 0; end; procedure TApp_BugsEyeWindowStyle.Action_WindowStyle_TextCopyExecute(Sender: TObject); //表示内容をクリップボードへコピー。 begin //更新処理をスキップさせるため Action_WindowStyle_TextOpen.Tag := 1; App_BugsEye.Action_Copy_WinInfoStyleVerbose.OnExecute(Action_WindowStyle_TextCopy); Action_WindowStyle_TextOpen.Tag := 0; end; procedure TApp_BugsEyeWindowStyle.actMenu_PopupExecute(Sender: TObject); begin mnuWindowStyle.Popup(Self.ClientOrigin.X, Self.ClientOrigin.Y); end; procedure TApp_BugsEyeWindowStyle.ListBox_StyleClick(Sender: TObject); const lci_POS_DESCRIPTION = 35; const lciSTART_STYLENAME = 12; lciSTART_STYLETEXT = 35; var ls_Str : WideString; ls_Hint : WideString; li_Pos : Integer; begin ls_Hint := ''; if (ListBox_Style.ItemIndex >= 0) then begin ls_Str := ListBox_Style.Items[ListBox_Style.ItemIndex]; if (ls_Str <> '') and (ls_Str[1] <> #9) //Length(ls_Str) > lci_POS_DESCRIPTION) then begin ls_Hint := WideFormat('%s %s', [ Trim(Copy(ls_Str, lciSTART_STYLENAME, lciSTART_STYLETEXT - lciSTART_STYLENAME)), Copy(ls_Str, lciSTART_STYLETEXT, MaxInt) ]); //ヒントを下部のヒントメッセージ欄に表示させる li_Pos := Pos('。', ls_Hint); if (li_Pos > 0) then begin ls_Hint := WideFormat('%s'#13#10'%s', [ Copy(ls_Hint, 1, li_Pos), Copy(ls_Hint, li_Pos + 1, MAXINT) ]); end; end else begin Memo_Hint.Text := ''; end; Memo_Hint.Text := ls_Hint; end; end; procedure TApp_BugsEyeWindowStyle.ListBox_StyleDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); //スタイルリストの描画 const lci_MARGIN = 2; var lrc_Rect : TRect; begin //タイトルを色分け if (ListBox_Style.Items[Index] <> '') and (ListBox_Style.Items[Index][1] = #9) then begin ListBox_Style.Canvas.Font.Color := clBtnText; ListBox_Style.Canvas.Brush.Color := clBtnFace; end; ListBox_Style.Canvas.FillRect(Rect); lrc_Rect := Rect; Inc(lrc_Rect.Left, lci_MARGIN); DrawText(ListBox_Style.Canvas.Handle, PChar(ListBox_Style.Items[Index]), -1, lrc_Rect, DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX); //タイトルの上に線を引く // if (Index > 0) if (ListBox_Style.Items[Index] <> '') and (ListBox_Style.Items[Index][1] = #9) then begin ListBox_Style.Canvas.MoveTo(Rect.Left, Rect.Top); ListBox_Style.Canvas.LineTo(Rect.Right, Rect.Top) end; end; end.