Get a specific glyph from Delphi VCL Style

522 views Asked by At

I want to get at a specific bitmap from a VCL style - and set it as an image on a button - it is actually the help question mark. In the Bitmap Style Editor is is the btnHelp image, from the Form.

1

There are 1 answers

1
RRUZ On BEST ANSWER

To get a Visual element (glyph) from a VCL Style you must use the GetElementDetails and the TCustomStyleServices.DrawElement procedure.

Try this sample

uses
  Vcl.Themes;

{$R *.dfm}

procedure TForm1.PaintBox1Paint(Sender: TObject);
var
  LDetails : TThemedElementDetails;
begin
  //Get the detailsfor the HelpButton
  LDetails := StyleServices.GetElementDetails(twHelpButtonNormal);
  //Draw the the element in the canvas.
  StyleServices.DrawElement(TPaintBox(Sender).Canvas.Handle, LDetails, TPaintBox(Sender).ClientRect);
end;

enter image description here