Jump to content
Software FX Community
Sign in to follow this  
User (Legacy)

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

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 4.0.16.0) 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

that

> allows you to change the Character set.

>

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

Font

> 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 {

...

CComQIPtr<IFont,&IID_IFont>

pFont(spChartFX->GetSerLegBoxObj()->GetFont());

ATLASSERT(pFont != 0);

HRESULT hr = pFont->put_Charset(EASTEUROPE_CHARSET);

ATLASSERT(SUCCEEDED(hr));

...

}

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

put_Charset().

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

better way to do the same?

Thanks for comments,

Petr

--

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

Please, don't reply via e-mail.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...