Welcome Guest! You need to login or register to make posts.



Go to last post Go to first unread
#1 Posted : Wednesday, August 20, 2003 6:00:00 AM(UTC)

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,657

Thanks: 5 times
Was thanked: 75 time(s) in 73 post(s)
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.


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.


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.


This problem was described by Microsoft and it can be found in MSDN (http://support.microsoft...spx?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:
    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
        Exit Sub
        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:

Edited by user Wednesday, January 2, 2008 3:00:54 AM(UTC)  | Reason: Not specified

Best regards,
Fedor Skvortsov
Users browsing this topic
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.