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

📄 getboundsrectunit.pas

📁 Delphi Win32核心API参考光盘源码 本书包含了常用的Windows API函数
💻 PAS
字号:
unit GetBoundsRectUnit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  TheRect: TRect;         // receives the bounding rectangle
  FormDC: HDC;            // a handle to the form's device context
  BoundRectState: UINT;   // holds the bounding rectangle state
begin
  {get the device context of the form}
  FormDC := GetDC(Form1.Handle);

  {initialize and set the bounds rectangle}
  TheRect := Rect(10, 10, 110, 110);
  SetBoundsRect(FormDC, @TheRect, DCB_ENABLE);

  {retrieve the bounds rectangle}
  BoundRectState := GetBoundsRect(FormDC, TheRect, 0);

  {release the device context}
  ReleaseDC(Form1.Handle, FormDC);

  {display the bounds rectangle coordinates}
  with TheRect do
  begin
    Label1.Caption := 'Top: '+IntToStr(Top) +' Left: '+IntToStr(Left)+
                      ' Bottom: '+IntToStr(Bottom)+' Right: '+IntToStr(Right);
  end;

  {display the bounds rectangle state}
  case BoundRectState of
    DCB_DISABLE:  Label2.Caption := 'State: DCB_DISABLE';
    DCB_ENABLE:   Label2.Caption := 'State: DCB_ENABLE';
    DCB_RESET:    Label2.Caption := 'State: DCB_RESET';
    DCB_SET:      Label2.Caption := 'State: DCB_SET';
  end; 
end;

end.

⌨️ 快捷键说明

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