RE: Russian Text in VB6.0

2002-04-02 Thread Barry James

Thanks for your reply Marco.

Unfortunately your suggestions bring me no closer to a solution. I already change the 
character set for all controls to 204 in a function that is called each time a form is 
loaded or if the language is changed.

The issue was that the Russian Text displayed perfectly when I used Access 97, but did 
not display on DataGrids or the Active reports.  When I converted the database to 
Access 2000, the ActiveReports and Datagrids displayed Russian, but the controls on 
the forms displayed "" even though the Character set for each had been changed 
to 204.

Cheers

Barry



-Original Message-
From: Marco Cimarosti [mailto:[EMAIL PROTECTED]]
Sent: 28 March 2002 02:04
To: '[EMAIL PROTECTED]'; Unicode (E-mail)
Subject: RE: Russian Text in VB6.0


Barry James wrote:
> I have created a VB6.0 database application for WWF (World 
> Wide Fund for Nature not World Wrestling Federation!).

Oh, well, if it is for the whales, I'll try to be helpful. :-)

> [...]
> My gut feeling is that I should stick with the Access 2000 
> version and try to convert the strings within VB as I have
> more control over the VB forms than over the Active
> Reports.

It seems a sound choice. I think that the important question is now: what
does the "garbage" look like?

I know these two possibilities:

1) It looks like empty squares;

2) It looks like question marks.

In case 1, you just have a font problem: the Cyrillic characters are there
but the font you use doesn't have glyphs for them. Although I don't expect
that this is the problem, you could fix it by setting each control's font
face to a proper font. E.g.:

cmdMyButton.Caption = "Чао а тутто ил мондо!"
cmdMyButton.Font.Name = "MyCyrillicFont"

In case 2 (which is what I would expect), you have a conversion problem.
Unfortunately, VB controls up to 6.x do not support Unicode. Unicode is
supported internally (you can have Unicode strings), and it is supported the
conversion from Unicode to Windows' character set and vice versa, but the
controls themselves must be in one Windows character set. In this case, you
have to change each control's encoding *before* you set its text/caption
with Cyrillic text:

Const charsetCyrillic   As Integer = 204
cmdMyButton.Font.Charset = charsetCyrillic
cmdMyButton.Font.Name = ""
cmdMyButton.Caption = "Чао а тутто ил мондо!"

Setting the font name to an empty strings causes the Font object to choose
the default font for the control's code page. Of course, you can also
explicitly set a font name that you know supports that code page.

I found value 204 by experimentation; unfortunately, I don't know where to
find a complete list of supported character sets, but here are the ones I
found out:

Const charsetWestEurope As Integer = 0
Const charsetDefaultAs Integer = 1
Const charsetSymbol As Integer = 2
Const charsetJapanese   As Integer = 128
Const charsetKorean As Integer = 129
Const charsetChineseS   As Integer = 134
Const charsetChienseT   As Integer = 136
Const charsetGreek  As Integer = 161
Const charsetTurkishAs Integer = 162
Const charsetHebrew As Integer = 177
Const charsetArabic As Integer = 178
Const charsetBaltic As Integer = 186
Const charsetCyrillic   As Integer = 204
Const charsetEastEurope As Integer = 238
Const charsetDosBox As Integer = 255

Note that this approach implies that you keep the charset information
together with each language choice, and that you change each control's
charset each time that the language changes.

If it was my task, I'd prefer to have centralized code which loops through
all the forms and controls in the application to set their charset. E.g.:

Sub setCharset(ByVal iCharset As Integer)
On Error Resume Next
Dim iFrm As Integer
For iFrm = 0 To Forms.Count
Dim iCtl As Integer
Forms(iFrm).Font.Charset = iCharset
Forms(iFrm).Font.Name = ""
For iCtl = 0 To Forms(iFrm).Controls.Count - 1
Select Case
TypeName(Forms(iFrm).Controls(iCtl))
Case "ActiveReport"
' (Or whatever the actual
type name is...)
' DO NOTHING
Case Else

Forms(iFrm).Controls(iCtl).Font.Charset = iCharset

Forms(iFrm).Controls(iCtl).Font.Name = ""
End Select
Next iCtl
Next iFrm

Re: Russian Text in VB6.0

2002-03-28 Thread Michael \(michka\) Kaplan

From: "Marco Cimarosti" <[EMAIL PROTECTED]>

> > The add-in assumes you will add an init call to each form's
> > load event.
>
> But, with this approach, you cannot change the language *after* the form
is
> loaded. So you can't, for instance, implement a "Language" menu, or link a
> language to a user id.

Well, you just call a function; you can always call it again with loaded
forms to change the language


MichKa

Michael Kaplan
Trigeminal Software, Inc.  -- http://www.trigeminal.com/





RE: Russian Text in VB6.0

2002-03-28 Thread Marco Cimarosti

Michael (michka) Kaplan wrote:
> > cmdMyButton.Caption = "Чао а тутто ил мондо!"
> > cmdMyButton.Font.Name = "MyCyrillicFont"
> 
> Well, this will be work if you are on compiling a Cyrillic system --
> otherwise you cannot have Cyrillic strings in the code.

Yes, correct. My real code actually called a function to load the string
from a database: I adapted it for the example without thinking twice.

> > Note that this approach implies that all forms are loaded 
> (although not
> > necessarily shown) at start up, because the object  
> only contains
> > loaded forms. The form's menu should be just one more 
> control, thus it
> > should be handled by the loop as well.
> 
> The add-in assumes you will add an init call to each form's 
> load event.

But, with this approach, you cannot change the language *after* the form is
loaded. So you can't, for instance, implement a "Language" menu, or link a
language to a user id.

_ Marco




Re: Russian Text in VB6.0

2002-03-28 Thread Michael \(michka\) Kaplan

From: "Marco Cimarosti" <[EMAIL PROTECTED]>

> In case 1, you just have a font problem: the Cyrillic characters are there
> but the font you use doesn't have glyphs for them. Although I don't expect
> that this is the problem, you could fix it by setting each control's font
> face to a proper font. E.g.:
>
> cmdMyButton.Caption = "Чао а тутто ил мондо!"
> cmdMyButton.Font.Name = "MyCyrillicFont"

Well, this will be work if you are on compiling a Cyrillic system --
otherwise you cannot have Cyrillic strings in the code.

> In case 2 (which is what I would expect), you have a conversion problem.
> Unfortunately, VB controls up to 6.x do not support Unicode. Unicode is
> supported internally (you can have Unicode strings), and it is supported
the
> conversion from Unicode to Windows' character set and vice versa, but the
> controls themselves must be in one Windows character set. In this case,
you
> have to change each control's encoding *before* you set its text/caption
> with Cyrillic text:
>
> Const charsetCyrillic As Integer = 204
> cmdMyButton.Font.Charset = charsetCyrillic
> cmdMyButton.Font.Name = ""
> cmdMyButton.Caption = "Чао а тутто ил мондо!"

>
> Setting the font name to an empty strings causes the Font object to choose
> the default font for the control's code page. Of course, you can also
> explicitly set a font name that you know supports that code page.

You do not have to set the name; changing the charset will cause COM to enum
for a font that supports it.

> I found value 204 by experimentation; unfortunately, I don't know where to
> find a complete list of supported character sets,

There is one in my book (http://www.i18nwithvb.com/) ? 

> If it was my task, I'd prefer to have centralized code which loops through
> all the forms and controls in the application to set their charset.

Ah, there is also an add-in that helps you do this for localization
purposes

> Note that this approach implies that all forms are loaded (although not
> necessarily shown) at start up, because the object  only contains
> loaded forms. The form's menu should be just one more control, thus it
> should be handled by the loop as well.

The add-in assumes you will add an init call to each form's load event.

> Hopefully, one version of VB will arrive one day whose controls are fully
> enabled to Unicode and smart fonts. So, all this code could be put inside
> <#If>'s so that it can be disabled when porting to newer Visual Basic.

That is mostly true on VB.Net (the only caveat is that on Win9x some
controls are still not Unicode as they use standard EDIT controls for
textboxes, etc. They use the Unicode ones on WinNT/2K/XP though. :-)


MichKa

Michael Kaplan
Trigeminal Software, Inc.  -- http://www.trigeminal.com/





RE: Russian Text in VB6.0

2002-03-28 Thread Marco Cimarosti

Barry James wrote:
> I have created a VB6.0 database application for WWF (World 
> Wide Fund for Nature not World Wrestling Federation!).

Oh, well, if it is for the whales, I'll try to be helpful. :-)

> [...]
> My gut feeling is that I should stick with the Access 2000 
> version and try to convert the strings within VB as I have
> more control over the VB forms than over the Active
> Reports.

It seems a sound choice. I think that the important question is now: what
does the "garbage" look like?

I know these two possibilities:

1) It looks like empty squares;

2) It looks like question marks.

In case 1, you just have a font problem: the Cyrillic characters are there
but the font you use doesn't have glyphs for them. Although I don't expect
that this is the problem, you could fix it by setting each control's font
face to a proper font. E.g.:

cmdMyButton.Caption = "Чао а тутто ил мондо!"
cmdMyButton.Font.Name = "MyCyrillicFont"

In case 2 (which is what I would expect), you have a conversion problem.
Unfortunately, VB controls up to 6.x do not support Unicode. Unicode is
supported internally (you can have Unicode strings), and it is supported the
conversion from Unicode to Windows' character set and vice versa, but the
controls themselves must be in one Windows character set. In this case, you
have to change each control's encoding *before* you set its text/caption
with Cyrillic text:

Const charsetCyrillic   As Integer = 204
cmdMyButton.Font.Charset = charsetCyrillic
cmdMyButton.Font.Name = ""
cmdMyButton.Caption = "Чао а тутто ил мондо!"

Setting the font name to an empty strings causes the Font object to choose
the default font for the control's code page. Of course, you can also
explicitly set a font name that you know supports that code page.

I found value 204 by experimentation; unfortunately, I don't know where to
find a complete list of supported character sets, but here are the ones I
found out:

Const charsetWestEurope As Integer = 0
Const charsetDefaultAs Integer = 1
Const charsetSymbol As Integer = 2
Const charsetJapanese   As Integer = 128
Const charsetKorean As Integer = 129
Const charsetChineseS   As Integer = 134
Const charsetChienseT   As Integer = 136
Const charsetGreek  As Integer = 161
Const charsetTurkishAs Integer = 162
Const charsetHebrew As Integer = 177
Const charsetArabic As Integer = 178
Const charsetBaltic As Integer = 186
Const charsetCyrillic   As Integer = 204
Const charsetEastEurope As Integer = 238
Const charsetDosBox As Integer = 255

Note that this approach implies that you keep the charset information
together with each language choice, and that you change each control's
charset each time that the language changes.

If it was my task, I'd prefer to have centralized code which loops through
all the forms and controls in the application to set their charset. E.g.:

Sub setCharset(ByVal iCharset As Integer)
On Error Resume Next
Dim iFrm As Integer
For iFrm = 0 To Forms.Count
Dim iCtl As Integer
Forms(iFrm).Font.Charset = iCharset
Forms(iFrm).Font.Name = ""
For iCtl = 0 To Forms(iFrm).Controls.Count - 1
Select Case
TypeName(Forms(iFrm).Controls(iCtl))
Case "ActiveReport"
' (Or whatever the actual
type name is...)
' DO NOTHING
Case Else

Forms(iFrm).Controls(iCtl).Font.Charset = iCharset

Forms(iFrm).Controls(iCtl).Font.Name = ""
End Select
Next iCtl
Next iFrm
End Sub

But perhaps you already a similar loop to set each control's caption with
localized strings. In this case, you can set the charset within the existing
code. Remember to set the charset before you set the caption!

Note that this approach implies that all forms are loaded (although not
necessarily shown) at start up, because the object  only contains
loaded forms. The form's menu should be just one more control, thus it
should be handled by the loop as well.

Hopefully, one version of VB will arrive one day whose controls are fully
enabled to Unicode and smart fonts. So, all this code could be put inside
<#If>'s so that it can be disabled when porting to newer Visual Basic.

I hope this helps.

_ Marco




Russian Text in VB6.0

2002-03-28 Thread Barry James

I have created a VB6.0 database application for WWF (World Wide Fund for
Nature not World Wrestling Federation!). The program is used to record
assessments of management effectiveness in Protected Areas. It is designed
to run in 5 languages, English, French, Spanish, Russian and Chinese. All of
the strings are stored in a separate table in the Access database and
whenever a form is loaded strings are allocated to controls depending on the
number allocated to the control tag and depending on the language chosen for
that session.  To do the reporting I am using Data Dynamics Active Reports.
The idea is that the Russians (or whoever) can capture their results in
their own language and somebody on the other side of the world can view the
results in another language.

So far I have not tried the Chinese option as I do not yet have their
translations of the strings.

The Russian option works perfectly on all forms when I am using an Access 97
database. All of the textboxes, labels, etc change to Cyrillic on demand and
all of the Title Bars, Message boxes and Tolltips are also working. However
DataGirds and Active Reports do not show the Russian text, they just show
garbage. But if I click on a cell in the DataGrid, suddenly the Russian text
is there and when the cell loses focus, the Russian text disappears again.

My next trick was to try to convert the database to Access 2000. The result:
Active reports and the DataGrid could display Russian text, but neither the
forms, nor the tooltips, title bars and message boxes could.

My gut feeling is that I should stick with the Access 2000 version and try
to convert the strings within VB as I have more control over the VB forms
than over the Active Reports. I have been told that I should try the Forms
2.0 library, but that would only solve part of my problem, as it would not
sort out the Title Bars, etc.

I have been fighting with this problem for 3 months and am getting quite
desperate as I am way over my deadline.

Anybody have any ideas?

Barry James

Barry and Danielle James
Brousse-James & Associates
Ecological and Environmental Services
PO Box 13885, Cascades, 3202
Ph +27(0)33-3470322
Fx +27(0)33-3470323
Email [EMAIL PROTECTED]