?? extcreatepen2unit.pas
字號:
unit extCreatePen2Unit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
NewPen, OldPen: HPen; // holds the old and new pens
FormDC: HDC; // holds a handle to the form's device context
BrushInfo: TLogBrush; // the logical brush structure
MiterLimit: Single; // the mite limit
begin
{get the form's device context}
FormDC := GetDC(Form1.Handle);
{define the brush}
with BrushInfo do
begin
lbStyle := BS_SOLID;
lbColor := clBlue;
lbHatch := 0;
end;
{create a geometric pen with square end caps and mitered joins, 20 units wide}
NewPen := ExtCreatePen(PS_GEOMETRIC or PS_ENDCAP_SQUARE or PS_JOIN_MITER, 20,
BrushInfo, 0, nil);
{select the pen into the form's device context}
OldPen := SelectObject(FormDC, NewPen);
{begin a path bracket}
BeginPath(FormDC);
{define a closed triangle path}
MoveToEx(FormDC, ClientWidth div 2, 20, nil);
LineTo(FormDC, ClientWidth-20, 90);
LineTo(FormDC, 20, 90);
CloseFigure(FormDC);
{end the path bracket}
EndPath(FormDC);
{insure that the miter limit is 2 units}
GetMiterLimit(FormDC, MiterLimit);
if MiterLimit>2 then
SetMiterLimit(FormDC, 2, NIL);
{draw the path with the geometric pen}
StrokePath(FormDC);
{delete the pen and the device context}
SelectObject(FormDC, OldPen);
ReleaseDC(Form1.Handle, FormDC);
DeleteObject(NewPen);
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -