2007. augusztus 10., péntek

Fake the caption bar of a borderless form


Problem/Question/Abstract:

How to fake the caption bar of a borderless form

Answer:

procedure TForm1.FormPaint(Sender: TObject);
var
  r: TRect;
begin
  r := Clientrect;
  DrawEdge(canvas.handle, r, EDGE_RAISED, BF_RECT or BF_ADJUST);
  r.bottom := r.top + GetSystemMetrics(SM_CYCAPTION);
  DrawCaption(self.handle, canvas.handle, r, DC_ACTIVE or DC_ICON or DC_TEXT);
  InflateRect(r, -2, -2);
  r.Left := r.right - GetSystemMetrics(SM_CXSIZE) + 2;
  DrawFrameControl(canvas.handle, r, DFC_CAPTION, DFCS_CAPTIONCLOSE);
  r.right := r.left - 2;
  r.Left := r.right - GetSystemMetrics(SM_CXSIZE) + 2;
  DrawFrameControl(canvas.handle, r, DFC_CAPTION, DFCS_CAPTIONMAX);
  r.right := r.left;
  r.Left := r.right - GetSystemMetrics(SM_CXSIZE) + 2;
  DrawFrameControl(canvas.handle, r, DFC_CAPTION, DFCS_CAPTIONMIN);
end;

Nincsenek megjegyzések:

Megjegyzés küldése