我正在使用win api for delphi。 我尝试使用DrawString程序超过几个小时,但仍然无法做到正确。 Delphi保留给我的信息'没有'DrawString'的重载版本,可以用这些争论调用'。 我试过一个表单并在一个custompanel上写消息......
uses
WinApi.Windows, WinApi.Messages, System.SysUtils, System.Classes, Vcl.Dialogs,
System.DateUtils,
WinApi.GDIPApi,
WinApi.GDIPObj,
Vcl.Forms, Vcl.Controls, Vcl.Graphics,
dxSkinsCore, dxSkinsDefaultPainters, cxGraphics, cxControls, cxLookAndFeels,
cxLookAndFeelPainters, cxContainer, cxEdit, cxGroupBox, cxCheckGroup,
Data.DB, SHIS.Dataset, Datasnap.DBClient, cxTextEdit, cxDBEdit,
cxImageComboBox, Vcl.Menus, cxCheckBox, Vcl.StdCtrls,
cxMaskEdit, cxDropDownEdit,
cxCheckComboBox, SHIS.Editor, cxButtons, SHIS.Ctrl, SHIS.ExtCommCdControl;
type
TCommCdF = class(TForm)
btn4: TButton;
procedure btn4Click(Sender: TObject);
private
protected
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure InitParams; override;
end;
implementation
{$R *.dfm}
uses
procedure TCommCdF.btn4Click(Sender: TObject);
var
testgraphics : TGPGraphics;
testPen : TGPPen;
testBrush : TGPSolidBrush;
testFont : TGPFont;
testFontFamily : TGPFontFamily;
begin
testgraphics := TGPGraphics.Create(SElf.Handle);
testPen := TGPPen.Create(aclBlack);
testFontFamily := TGPFontFamily.Create('Arial');
// testFont := TGPFont.Create(testFontFamily, 12, FontStyleBold, UnitPixel);
testFont := TGPFont.Create('Arial', 20);
testBrush := TGPSolidBrush.Create(aclBlack);
// testgraphics.DrawString('Hello', 5, testFont, MakeRect(0,0,50,50),testBrush);
// testgraphics.DrawString('Hello Finally', testFont, MakePoint(0, 0), testBrush);
end;