掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
フォーム右上の閉じるボタンのヒント表示を変更するには (ID:47080)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
○ Windows7 Aero × Windows 2000(Virtual PC) × Windows XP クラシック表示(Virtual PC) △ Windows XP XPスタイル(Virtual PC) 参考資料:http://www.progtown.com/topic1060130-how-to-superimpose-system-buttons.html type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private SysTooltip: HWND; procedure WMNCMouseMove(var aMsg: TMessage); message WM_NCMOUSEMOVE; public { Public 宣言 } end; var Form1: TForm1; implementation {$R *.DFM} function GetSystemTooltip(aWnd: HWND; alPrm: LPARAM): BOOL; stdcall; var clsName: array[0..255] of Char; pSysTooltip: ^Integer; begin GetClassName(aWnd, clsName, 255); Result := StrPas(clsName) <> '#32774'; if not Result then begin pSysTooltip := Pointer(alPrm); pSysTooltip^ := aWnd; end; end; procedure TForm1.FormCreate(Sender: TObject); begin SysTooltip := 0; EnumWindows (@GetSystemTooltip, Integer(@SysTooltip)); end; procedure TForm1.WMNCMouseMove(var aMsg: TMessage); var toolTipDC: HDC; rc: TRect; toolTipCanvas: TCanvas; hintText: string; begin inherited; if not IsWindow(SysTooltip) then EnumWindows(@GetSystemTooltip, Integer(@SysTooltip)); if not IsWindowVisible(SysTooltip) then Exit; case aMsg.WParam of HTCLOSE: hintText := '閉'#$D#$A'じ'#$D#$A'る'#$D#$A'の'#$D#$A'?'; HTMAXBUTTON: hintText := '最'#$D#$A'大'#$D#$A'化'; HTMINBUTTON: hintText := '最 '#$D#$A' 小 '#$D#$A' 化'; else Exit; end; toolTipDC := GetDC(SysTooltip); if toolTipDC = 0 then Exit; try toolTipCanvas := TCanvas.Create; try toolTipCanvas.Handle := toolTipDC; //文字の描画範囲取得 FillChar(rc, SizeOf(TRect), 0); DrawText(toolTipCanvas.Handle, PChar(hintText), Length(hintText), rc, DT_CALCRECT); rc.BottomRight := Point(rc.Right + 10, rc.Bottom + 4); //ツールチップのサイズを設定 SetWindowPos(SysTooltip, HWND_TOPMOST, 0, 0, rc.Right, rc.Bottom, SWP_NOMOVE or SWP_NOACTIVATE or SWP_NOOWNERZORDER); //矩形範囲を取得 Windows.GetClientRect(SysTooltip, rc); //塗りつぶしと枠の描画 toolTipCanvas.Brush.Color := clInfoBk; toolTipCanvas.FillRect(rc); toolTipCanvas.Pen.Color := ClBlack; toolTipCanvas.Rectangle(rc); //文字の縦描画位置調整 InflateRect(rc, 0, -2); //描画 DrawText(toolTipDC, PChar(hintText), Length(hintText), rc, DT_CENTER or DT_VCENTER); finally toolTipCanvas.Free; end; finally ReleaseDC(SysTooltip, toolTipDC); end; end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.