?? getboundsrectunit.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 + -