Author: Jonas Bilinkevicius
How to fake the caption bar of a borderless form
Answer:
1 procedure TForm1.FormPaint(Sender: TObject);
2 var
3 r: TRect;
4 begin
5 r := Clientrect;
6 DrawEdge(canvas.handle, r, EDGE_RAISED, BF_RECT or BF_ADJUST);
7 r.bottom := r.top + GetSystemMetrics(SM_CYCAPTION);
8 DrawCaption(self.handle, canvas.handle, r, DC_ACTIVE or DC_ICON or DC_TEXT);
9 InflateRect(r, -2, -2);
10 r.Left := r.right - GetSystemMetrics(SM_CXSIZE) + 2;
11 DrawFrameControl(canvas.handle, r, DFC_CAPTION, DFCS_CAPTIONCLOSE);
12 r.right := r.left - 2;
13 r.Left := r.right - GetSystemMetrics(SM_CXSIZE) + 2;
14 DrawFrameControl(canvas.handle, r, DFC_CAPTION, DFCS_CAPTIONMAX);
15 r.right := r.left;
16 r.Left := r.right - GetSystemMetrics(SM_CXSIZE) + 2;
17 DrawFrameControl(canvas.handle, r, DFC_CAPTION, DFCS_CAPTIONMIN);
18 end;
|