Jump to content
Software FX Community

Re: How to set the charset for the font programmatically?

User (Legacy)

Recommended Posts

First of all, thanks, Frank, for the answer on setting 

the desired charset. Being quite new to COM, I would like

to ask you (or others) if my solution is optimal.

The original question was...


>> I am using Cfx4032.dll (version in the C++

>> (VC++ ver. 6.0) application (ATL, no MFC).


>> I am filling the series legend [...]

>> Later, I do allow displaying the legend [...]

>> The problem is that the strings are in the Czech language and the

>> implicit font uses "Western" charset. [...]

>> How can I do the same programmatically?


>> I tried to use PutFonts(), but it uses only combination of the

>> family, weight, and size [...]


>> I do use Windows NT 4.0 English version with Czech regional setting.


Frank answered...


> Instead of using the Fonts property, you need to set the font using an OLE

> Font object (IFont). The IFont interface has a property called CharSet


> allows you to change the Character set.


> The LegendBoxObj object has a property called Font that receives an OLE


> object.


> There are also properties in the Chart object of this type (Axis(i).Font,

> TopFont, etc.).


So, instead of PutFonts(), I have tried:

try {




ATLASSERT(pFont != 0);

HRESULT hr = pFont->put_Charset(EASTEUROPE_CHARSET);




It seems to work, but is this O.K.? I do know the basic principles

of COM (I hope :(, but I do not know well the related details,

e.g. the ATL templates for COM.

Could you confirm correctness of the following description

of what I think is behind the scene.

The GetFont() returns (IFontDisp *). The interface is derived from

IUnknown, i.e. it supports QueryInterface(). The CComQIPtr<> uses

the QueryInterface() and the IID_IFont to get the interface IFont

(from whatever other interface, i.e. also from IFontDisp) and wrap

the pointer into the smart-pointer object. Then I did use the


Is there any other more efficient, more understandable, or simply

better way to do the same?

Thanks for comments,



Petr Prikryl, Skil s.r.o., e-mail: prikrylp at skil dot cz

Please, don't reply via e-mail.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...