VCL Advanced
34.1 VCL Styles
uses Vcl.Themes, Vcl.Styles;
TStyleManager.TrySetStyle('Windows11 Modern Dark');
for var S in TStyleManager.StyleNames do cboStyles.Items.Add(S);
// Per-control styling (Delphi 11+): Control.StyleName := 'Windows10 Blue';
// Project → Options → Appearance: include styles in the executable34.2 Custom Drawing and Owner Draw
GDI+ (Winapi.GDIPOBJ), Direct2D (Vcl.Direct2D), Skia for VCL (Delphi 12, Module 38), double buffering (DoubleBuffered := True).
procedure TMainForm.PaintBox1Paint(Sender: TObject);
begin
with PaintBox1.Canvas do
begin
Brush.Color := clWhite;
FillRect(PaintBox1.ClientRect);
Pen.Color := clBlue; Pen.Width := 3;
Ellipse(20, 20, 120, 120);
Brush.Color := clLime;
Rectangle(150, 20, 270, 100);
Font.Size := 14; Font.Style := [fsBold];
TextOut(20, 140, 'VCL Canvas Drawing');
end;
end;
procedure TMainForm.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
with ListBox1.Canvas do
begin
if odSelected in State then Brush.Color := clHighlight else Brush.Color := clWindow;
FillRect(Rect);
TextOut(Rect.Left + 4, Rect.Top + 2, ListBox1.Items[Index]);
end;
end; // ListBox1.Style := lbOwnerDrawFixed34.3 Printing and Reporting
Reporting tools: FastReport (bundled edition with RAD Studio), ReportBuilder, QuickReport (legacy), List & Label, TMS FlexCel (Excel/PDF reports), TPrintDialog, TPrinterSetupDialog.
uses Vcl.Printers;
Printer.BeginDoc;
try
Printer.Canvas.Font.Size := 12;
Printer.Canvas.TextOut(100, 100, 'Invoice #1001');
finally
Printer.EndDoc;
end;34.4 Windows Integration
Drag and drop (OnDragDrop, OnDragOver, file drops with WM_DROPFILES/TDropTarget), the clipboard (Vcl.Clipbrd.Clipboard.AsText), tray icons (TTrayIcon), the taskbar (TTaskbar progress/overlay), single instance (mutex), Windows messages (procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA;), and TEdgeBrowser (WebView2) for web content.