⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xwindows.pas

📁 在深度历险网站上发布的所有delphi程序原码。对初学delphi者很有用。
💻 PAS
字号:
unit xWindows;

interface

uses Windows, Sysutils, Controls, Forms;

const
  DEFAULT_FOCUSRECT_WIDTH = 3;
  
function FindControl(Handle: HWND; ProcessID: DWORD = 0): TWinControl;
function IsDelphiHandle(Handle: HWND; ProcessID: DWORD = 0): Boolean;

function FindTopmostWindow(ParentWnd: HWND; Pt: TPoint): HWND;

procedure MyDrawFocusRect(DC: HDC; R: TRect; Width: Integer = DEFAULT_FOCUSRECT_WIDTH);
procedure DrawWindowFocusRect(Wnd: HWND; Width: Integer = DEFAULT_FOCUSRECT_WIDTH);
procedure DrawControlFocusRect(Control: TControl; Width: Integer = DEFAULT_FOCUSRECT_WIDTH);

implementation

uses xKernel;

var
  WindowAtom : TAtom;               
  ControlAtom: TAtom;               
  
  AtomText   : array[0..31] of Char;
  
  { Find a TWinControl given a window handle }
  
function FindControl(Handle: HWND; 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: HWND; ProcessID: DWORD = 0): Boolean;
begin
  Result := FindControl(Handle, ProcessID) <> nil;
end;

function FindTopmostWindow(ParentWnd: HWND; Pt: TPoint): HWND;
var
  R: TRect;
begin
  Result := GetWindow(ParentWnd, GW_CHILD); // 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -