从实作标题栏按钮开始浅谈组件的制作 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; if FButtonDown then begin MoveTo(Left+1,Bottom-3); LineTo(Left+1,Top+1); LineTo(Right-2,Top+1); end else begin MoveTo(Left+1,Bottom-2); LineTo(Right-2,Bottom-2); LineTo(Right-2,Top); end; end; if Assigned(Glyph) then //如果关联了图片,则画图片 begin GlyphRect := BoundsRect; GlyphRect.Right := GlyphRect.Right - 7; GlyphRect.Bottom := GlyphRect.Bottom - 5; if FButtonDown then OffsetRect(GlyphRect,4,3) else OffsetRect(GlyphRect,3,2); with GlyphRect do
上一篇:“98五笔字型输入法”大批量造词 下一篇:如何把数据库的内容写入到Word文档中? 更多相关文章
|
推荐文章
精彩文章
|