Unicode Controls & Classes for VB6 - Version 4

Pre-Requisites


The UNICODE is supported starting from Windows 2000 and in order to display some Unicode characters you need Unicode fonts like "Arial Unicode MS" in your machine.
These fonts must be assigned to your controls if needed (use the Font property) or the ctlUniStyler control

This library is compatible with all Windows versions supporting GDI+ (Win98+)

See >> Configure "Regional Settings" <<

You may experience problems when using this library in VB6 Environment if you press the VB6 stop button; don't worry because when your program will be compiled all will work ok; these controls has been tested for a lot of time and in many commercial applications.

Use the sample project in UNICODE platforms (Windows 2000+) or you cannot see many pieces of texts because I've used a .ini UNICODE file (not compatible with old Windows platforms).

You need a working copy of the Microsoft Visual Basic 6 Environment with the latest Service Pack available (actually version 6b). Every version of VB6 is compatible.

Windowless usercontrols

A windowless control doesn't have a Window handle so it is ligher than a windowed control; it doesn't provide also a hWnd property.
These usercontrols are drawn on the parent window and are always below windowed controls; so for example a ctlUniImageWL control (windowless) cannot be over a ctlUniTextBoxXP control (windowed)

Managing .ini files

use the clsFileIni and clsFileIniEx classes.
In Non UNICODE systems like Windows 95/98/Me/NT4 where using the clsFileIni class with UNICODE files you'll obtain empty strings because UNICODE APIs fail (The ANSI API used on Unicode files fails). Old Windows systems only support ANSI .ini files; you can use Unicode .ini files in old system using the clsFileIniEx class.

32bpp alpha images

At design-time use the "Custom..." property panel from the VB6 properties list of the selected control
At run-time set the Picture property of the control using a StdPicture object obtained using the clsCommonWrapper.LoadPicture method

Unicode Caption, Text, Tooltip at design-time

You can set-up Unicode properties at design-time (Text, Caption, Tip) only using the Custom Property Panel, because the VB6 property panel is Ansi.
In order to make the tooltip work correctly check the next topic

UNICODE Tooltip

In order to use Unicode Tooltips you need to:
1- Draw a ctlUniToolTipManager control on the first form of your application (this enables tooltips and manages the tooltip form instances)
2- Set the "Tip" property of controls, don't use the ToolTipText property because is ANSI only.

clsMultiLngSupport

Multi Language Helper Class that permits you to translate your forms with only one row of code; see details

KeyDown, KeyPress, KeyUp events

VB6 uses Signed integers for KeyDown, KeyPress and KeyUp events; Unicode also uses two bytes (like a VB6 integer) but Unsigned, so the VB6 definition is OK for the event but the KeyAscii / KeyCode value may arrive negative as this Unicode library passes the two bytes value directly to the VB6 standard event.

You can manage the KeyAscii / KeyCode value simply by using the clsCommonWrapper.ChrW or ASCW functions.
It's also possible to obtain the real Unsigned Integer (in a VB6 long) from the negative value simply by converting the KeyAscii / KeyCode value to a Long using the clsCommonWrapper.MakeDWord (KeyAscii, 0) function

KeyPreview

Unfortunately, the KeyPreview MUST not be used as the VB6 form container is not Unicode and may filter chars in some systems. I tried it using Italian and English locales and it works as these locales supports the full ANSI charset.
By setting the locale to chinese the KeyPreview property causes controls to run incorrectly.
If you need the KeyPreview property, do it by hands managing KeyDown, KeyPress and KeyUp events of controls.

Mouse Events

VB6 controls return mouse coordinates in Twips, Hexagora Unicode Library uses and expects coordinates in Pixels
This can be a problem only in the DragOver and DragDrop events (they returns coordinates in Twips as VB6 manages them directly); just convert the coordinates in Pixels before passing them to our methods

Private Sub ctlUniListView1_DragDrop(Source As Control, X As Single, Y As Single)
    If Source Is ctlUniListView1 Then
       
        Dim liIns As clsUniLV_ListItem
        Set liIns = ctlUniListView1.SelectedItem
        ctlUniListView1.ListItems.Remove liIns.Index
       
        Dim li As clsUniLV_ListItem
        Set li = ctlUniListView1.HitTest(scaleX(X, vbTwips, vbPixels), scaleY(Y, vbTwips, vbPixels))
       
        If Not li Is Nothing Then
            ctlUniListView1.ListItems.Add li.Index, liIns.Key, liIns.Text, liIns.Icon, liIns.SmallIcon
        Else
            ctlUniListView1.ListItems.Add , liIns.Key, liIns.Text, liIns.Icon, liIns.SmallIcon
        End If
    End If

End Sub

OLE Drag&Drop

If you need to drag Unicode files to a control, implement the OLEDrag&Drop events and use the GetUnicodeDroppedFiles to get the list of dragged files (in Unicode) from the OleDragDrop DataObject object.

If you need to drag Unicode text from a control or another app to yours act as follows:

1- define a const like this:

Const vbCFUnicode = 13&

2- if you start the OleDrag from a control of your application save data in Unicode format (OLEStartDrag event):

Dim b() As Byte

b = Text1.SelText
data.SetData b, vbCFUnicode

3- read the text in Unicode format (if available, OLEDragDrop event):

If data.GetFormat(vbCFUnicode) Then
    Text2.SelText = data.GetData(vbCFUnicode)
ElseIf data.GetFormat(vbCFText) Then
    Text2.SelText = data.GetData(vbCFText)
End If

IME Input

TextBox, RichTextBox, ComboBox, ListBox, Canvas support Input Method Editors

See documentation here

FONT

These controls have the Font property. If you set the font in this way:

Set Usercontrol.Font = MyFont

the control will change the font immediately

If you use a construct like this:

Usercontrol.Font.Name = "Verdana"

the control will not understand the changes made to the font object.

In VB6 usercontrols there is a method that will permit UserControls to know if a property of the font has changed but this method is quite expensive (in terms of memory used) so we preferred not to add it.
We added a new method to all controls called "ApplyFontChanges" that you can call when you need to notify the control the change of the Font.

so you have to write:

Usercontrol.Font.Name = "Verdana"
Usercontrol.ApplyFontChanges

Creating custom VB6 usercontrols

Some controls contained into this package may have bad iterations when used into Usercontrols.
This because VB6 cannot detect, in some cases, that the usercontrol is in Design or User mode so the control may appear running at design time (so you cannot move it in many cases).
You can create your usercontrols using a simple tip described here

RTL VB6 Forms

Execute the SetWindowLayout function in the form load event of your forms; note that child controls need to have the RTL property set manually (they don't inherit this property)

Controls Style

You can change the predefined controls style by setting the property DefaultButtonStyle of the clsCommonWrapper class before your program starts (or in the initialize event of your first form).
This value is global for every control in your application.
You can change the style and colors of your controls using the ctlUniStyler control.

Load and use 32bpp alpha images

It is possible to load and assign 32bpp alpha images to controls at design time only by using this specific custom panel.
At runtime simply use the clsCommonWrapper.LoadPicture function instead of the VB6 LoadPicture.
If you need to render a 32bpp image use the clsCommonWrapper.RenderPicture method.

Right To Left Support

Every control in version 4 supports RTL reading; just select RightToLeft on the control properties or set it to the various AddPanel, AddItem, AddTab methods in complex controls (StatusBar, ListView, ToolBar, Tabulator)
The RightToLeft flag influences the appearance of the Unicode Tip so it has been created also for controls like the ctlUniImageWL that have no text (but can contain a RTL Tooltip).

External references needed:

(The Microsoft Visual Basic 6 Runtime)
STDOLE2.TLB, ASYCFILT.DLL, COMCAT.DLL,
msvbvm60.dll, OLEAUT32.DLL, OLEPRO32.DLL
These libraries contain functions that permit VB6 programs to run.
Refer to file "Sample Install.iss" (The Inno Setup Script used to make the setup for this library) if you need to create a new setup for your application.
The Latest VB6 runtime can be downloaded from our site at this address: http://www.hexagora.com/download/support/VB6RunTime.exe

These libraries MUST be distributed with your compiled application.
Note that starting from Windows 2000 these components are already distributed by Microsoft.
(The Microsoft Layer for Unicode)
Unicows.dll
This library wraps every Unicode function (exported by GDI32.dll and USER32.dll) and chooses if call the Ansi or Unicode one basing on the current Windows version.

This library MUST be distributed with your compiled application.

You can put this file into the Windows\System32 directory or in your installation path; you don't need to register this component.
richupd.exe Only if you are using the ctlUniRichTextBoxXP control in your application with an old Windows version.

This is the Microsoft RichEdit control update for version 3.0 (the latest available). I suggest you to install this upgrade on your customers if they are using your application under Windows 95 - 98 - Me - NT4.

Without the update the ctlUniRichTextBoxXP will continue work but with less capabilities.
You can check the RichEdit library version using the ctlUniRichTextBoxXP.RichEditVersion method.

Download the package from here
HexOle21.tlb Contains all interface declarations and definitions for our library

Needed only at design time, just copy it in the same folder of your project