Get a specific glyph from Delphi VCL Style

时光总嘲笑我的痴心妄想 提交于 2019-12-10 10:34:00

问题


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:


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;



来源:https://stackoverflow.com/questions/41201617/get-a-specific-glyph-from-delphi-vcl-style

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!