Forums

Welcome Guest Search | Active Topics | Members

HOWTO: Use international languages with Graphics Processor in VB6 Options
Fedor
Posted: Wednesday, August 20, 2003 2:00:00 PM

Rank: Advanced Member
Groups: Administration , Member

Joined: 7/28/2003
Posts: 1,140
Points: -396
Location: WA, US
This article may be useful if you encounter internalization problems in your application written on VB6, for example you cannot load image from file with name, containing unicode characters or incorrect symbols are drawn when you draw text.

Description

As Microsoft claims, Visual Basic 6 supports Unicode characters (which are used to represent languages which has a lot of symbols, as Chinese and so on). Moreover, it stores strings in Unicode internally. But in practice you can encounter serious problems when you try to internationalize your application. For example you try to open some file which contains Chinese characters, but Graphics Processor returns error that file ???.jpg could not be loaded. Or when you want to draw Chinese text, but question-marks are appeared instead.

Reason

The problem is that Visual Basic 6 uses a lot of outside components. For example text box is not written on VB6, it is an ActiveX control which uses WinAPI. That's why there is no guarantee that these controls handles Unicode correctly. As usual they convert string to ANSI format. Each Unicode symbol takes 2 bytes, ANSI symbols takes 1 byte. Thus when we convert from Unicode to ANSI, some information can be lost, not all the Unicode characters may be represented as ANSI character.

Solution

This problem was described by Microsoft and it can be found in MSDN (http://support.microsoft.com/default.aspx?scid=kb;en-us;193540). In short, they recommend to use special set of controls, which is compatible with Unicode. These controls (Microsoft Forms 2.0) are shipped with Microsoft Office, so if you have Office installed, you can use it. Read the article, mentioned above for more details.

Let's try to implement simple Unicode-compatible application. Follow these steps:

  • Create new project.
  • Add Microsoft Forms2.0(Project->Components->Microsoft Forms 2.0).
  • Drag and drop text box control, picture box and a button.
  • Add this code into button click handler:
    Code:
    Private Sub Command1_Click()
        Dim objRaster As New GraphicsProcessor2002.RasterObject
        On Error GoTo e
        objRaster.LoadFile TextBox1.Text
        objRaster.Resize Picture1.Width, Picture1.Height
        Picture1.AutoRedraw = True
        objRaster.DrawOnHDC Picture1.hDC, 0, 0, Picture1.Width, Picture1.Height, rqtBicubicMode
        Picture1.Refresh
        Exit Sub
        e:
        MsgBox Err.Description
        Err = 0
    End Sub

  • Run application and choose some file which contains Unicode characters. 6. A result should be looking like this screenshot:





Best regards,
Fedor Skvortsov
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net version 1.9.1.6 running under Cuyahoga.
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.