ted;
if (Operation = opRemove) and (Component = FPopup) then
FPopup := nil;
end;
function TTitleBarButton.GetBoundsRect: TRect;
var
Rec: TRect;
FrameThick: Integer; //窗体框架厚度
BtnWidth,BtnHeight: Integer; //标题栏按钮的宽度和高度
begin
GetWindowRect(FForm.Handle,Rec); //得到窗体边界矩形,相对于屏幕左上角
with Result do
begin
FrameThick := GetSystemMetrics(SM_CYFRAME);
Left := (Rec.Right - Rec.Left) - RightMargin - FrameThick;
Top := FrameThick;
if FForm.Borderstyle in [bsSizeToolWin, bsSizeable] then
begin
Dec(Left, 2); Inc(Top, 2);
end
else begin
Dec(Left); Inc(Top);
end;
if (FForm.Borderstyle in [bsSizeToolWin,bsToolWindow]) then
begin
BtnWidth := GetSystemMetrics(SM_CXSMSIZE) - 2;
BtnHeight := GetSystemMetrics(SM_CYSMSIZE) - 4;
end
else begin
BtnWidth := GetSystemMetrics(SM_CXSIZE) - 2;
BtnHeight := GetSystemMetrics(SM_CYSIZE) - 4;
end;
Right := Left + BtnWidth;
Bottom := Top + BtnHeight;
end;
end;
procedure TTitleBarButton.Paint;
var
GlyphRect: TRect;
begin
if not FVisible then Exit;
with TCanvas.Create do
begin
try
Handle := GetWindowDC(FForm.Handle); //得到窗体DC,包括标题栏、菜单、滚动条等
Brush.Color := FColor; //画Button凸起和按下时的外观
if FButtonDown then
Pen.Color := clBtnHighlight
else
Pen.Color := cl3DDkShadow;
Rectangle(BoundsRect);
with BoundsRect do
begin
if FButtonDown then
Pen.Color := cl3DDkShadow
else
Pen.Color := clBtnHighLight;
MoveTo(Left,Bottom-2);
LineTo(Left,Top);
LineTo(Right-1,Top);
Pen.Color := clGray;
&