Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Form Captions with Unicode characters in VB6

Posted on 2007-10-08
8
Medium Priority
?
2,102 Views
Last Modified: 2013-12-26
I want to display Unicode characters in a VB6 Form caption.
All attempts with SetWindowsTextW are failing and the string gets converted to ANSI.

Any code snippets available anywhere?

0
Comment
Question by:ToFri
7 Comments
 
LVL 28

Expert Comment

by:peakpeak
ID: 20033323
0
 

Author Comment

by:ToFri
ID: 20035651
Thank you,

Nice, but not really a solution for the problem.
I need to show arbitrary Unicode in the caption under every Windows locale setting.

We have customers all over the world using different Windows XP versions, like Russion, Greek, Hebrew, Arabic and so on. And I just want to call SetWindowTextW.

I know (think I know) this does not work because the VB6 Form is not a Unicode-Window and so a conversion from Unicode to ANSI takes place behind the scenes.
I read somewhere, that one needs to install a hook (CBT?) and send the SetWindowTextW from inside the Hook in order to achieve the desired result&

Some code snippets for that would be very apprechiated.

Thank You anyway

Thomas
0
 
LVL 22

Expert Comment

by:danaseaman
ID: 20043815
Vb Command button has a hWnd so you can use HCBT_ACTIVATE and SetWindowTextW however Vb Label does not (class is "ThunderFormDC") so you cannot hook it.

Here is a Unilabel control that works but requires that the Unicode caption be set at run-time:

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=56259&lngWId=1&txtForceRefresh=109200715241953471

To do this correctly though you need at least the following:
   1. Render Unicode using API DrawTextW
   2. Implement AutoSize using GetTextExtentPoint32W so that it gets correct metrics for Unicode strings.
   3. Vb IDE Properties window does not support Unicode strings. You can cheat by pasting UTF-8 here and converting it inside your control to UTF-16, otherwise to do it right you need a Property Page with a Unicode aware TextBox to input the Unicode caption.
   4. Modify PropertyBag persiststance of caption to use a byte array so that it does not automatically change the caption to ANSI when writing.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ToFri
ID: 20044516
Yes Thank you !
I understand this works for controls inside the Form.
My question is regarding the Form Caption!
Not regarding any control inside. We did solve these problems already.
The "only" problem remaining is the Title of the application Window itself.
I mean the text between the Icon of the application and the Minimize, Restore, Close boxes.

Thank you anyway

Thomas
0
 
LVL 22

Accepted Solution

by:
danaseaman earned 1000 total points
ID: 20044765
Sorry I misread your question.
To manipulate the Form Caption aka "TitleBar" for Unicode support here are a couple links to get you started:
1. http://www.vbaccelerator.com/home/vb/code/Libraries/Subclassing/SSubTimer/VB6_Graduated_Title_Bar_Sample.asp
   You need to change from DrawTextA to DrawTextW as well as account for XP Themes.
2. http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=62038&lngWId=1
   This one apperas to be better than "VB6_Graduated_Title_Bar_Sample" and is buried in ThunderVb and can be found at folder "C:\ThunderVB_v_1_0_0_31_7_2005\ThunVBCC\V1\ThunderVB Controls\uniCaption"
   You will probably want to change the subclassing to either Paul Caton (latest version http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=68737&lngWId=1 ) or VbAccelerator( http://www.vbaccelerator.com/home/vb/Code/Libraries/Subclassing/SSubTimer/article.asp ).
   
0
 

Author Comment

by:ToFri
ID: 20046551
Thank you very much.
This will help.
I did not think of this obvious way.
Good to have some sourcecode to start with.

Thomas
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20228789
Forced accept.

Computer101
EE Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question