📄 xwindows.pas
字号:
unit xWindows;
interface
uses Windows, SysUtils, Controls, Forms;
const
DEFAULT_FOCUSRECT_WIDTH = 3;
function GetWindowCaption(Wnd: THandle): string;
function GetWindowClassName(Wnd: THandle): string;
function FindControl(Handle: THandle; ProcessId: DWORD = 0): TWinControl;
function IsDelphiHandle(Handle: THandle; ProcessId: DWORD = 0): Boolean;
function FindTopmostWindow(ParentWnd: THandle; PT: TPoint): THandle;
procedure MyDrawFocusRect(DC: HDC; R: TRect; Width: Integer = DEFAULT_FOCUSRECT_WIDTH);
procedure DrawWindowFocusRect(Wnd: THandle; Width: Integer = DEFAULT_FOCUSRECT_WIDTH);
procedure DrawControlFocusRect(Control: TControl; Width: Integer = DEFAULT_FOCUSRECT_WIDTH);
function SearchChildByClassName(Window: THandle; WindwClassName: string): THandle;
implementation
uses xKernel;
var
WindowAtom : TAtom;
ControlAtom: TAtom;
AtomText : array[0..31] of Char;
{ Find a TWinControl given a window handle }
function FindControl(Handle: THandle; ProcessId: DWORD = 0): TWinControl;
begin
// DebugStrFmt('Find Control Handle = %x',[Handle]);
if Handle <> 0 then
begin
if ProcessId = 0 then
GetWindowThreadProcessId(Handle, @ProcessId);
WindowAtom := GlobalAddAtom(StrFmt(AtomText, 'Delphi%.8X',[ProcessId]));
Result := Pointer(GetProp(Handle, MakeIntAtom(WindowAtom)));
// DebugStrFmt('Find Control PID = %x Result = %p',[ProcessID, Pointer(Result)]);
end else
Result := nil;
end;
function IsDelphiHandle(Handle: THandle; ProcessId: DWORD = 0): Boolean;
begin
Result := FindControl(Handle, ProcessId) <> nil;
end;
function FindTopmostWindow(ParentWnd: THandle; PT: TPoint): THandle;
var
R: TRect;
begin
Result := GetWindow(ParentWnd, GW_CHILD); //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -