1 Attachment(s)
[RESOLVED] UNICODE in Form1 Title (VB6+WinXP)
See also Discussion : UNICODE Title in VB6
Hi.
My OS is Windows-XP. If I run IE and load the japanese website
http://live.nicovideo.jp/recent
and moving the mouse cursor to the IE title bar
my VB6 project (see attachement 2,7kB) shows japanese chars
in the (forms 2.0)TextBox control on Form1.
-But it's not possible to populate
the Form1.Caption with japanese characters
The Form1 titlebar only shows "???" instead of the
japanese UNICODE characters.
-How can I show Unicode chars in a titlebar of a VB6 Form?
Annotation:
Please run my project and load the japanese website
http://live.nicovideo.jp/recent
-If you move the mouse cursor to the IE browser's title bar,
you'll see japanese chars in the (forms 2.0)TextBox (TextBox1).
Re: UNICODE in Form1 Title (VB6+WinXP)
Strings from VB control properties will be ANSI. Suggest the following changes
Code:
Private Sub Timer1_Timer()
Static hw As Long
Dim sUniText As String
GetCursorPos pt
hw = WindowFromPoint(pt.X, pt.Y)
sUniText = Module1.gWTx(hw)
TextBox1.Text = sUniText
' either use this line & then you can completely remove the UniCaption function
DefWindowProcW Me.hWnd, WM_SETTEXT, 0&, ByVal StrPtr(sUniText)
' or use this line instead of the one above
UniCaption(Form1) = sUniText
End Sub
FYI: Regarding my insistence that you start your own thread (from previous thread) is that people may have subscribed to that thread. Each time a new post is added, emails may be sent to those that subscribed. We shouldn't be posting on other's threads for our own questions/problems.
Edited: Does that Forms2.0 textbox have a UnicodeText property (or something similar)? If so, that is property you wanted to return vs the .Text property. The fix above should work regardless
2 Attachment(s)
Re: UNICODE in Form1 Title (VB6+WinXP)
I used your sample and modified my project
(the project is now: 6c.zip). The VB6 Form
titlebar is still unable to show UNICODE chars.
-Instead of UNICODE chars "???" are displayed.
1 Attachment(s)
Re: UNICODE in Form1 Title (VB6+WinXP)
Is this being run on XP? If so, later when I have some time & if not already resolved, I can boot down to XP & see if I can replicate the problem.
But using the code in your zip, works fine on Vista
Re: UNICODE in Form1 Title (VB6+WinXP)
I don't have Forms2.0 on my machine. So I can't test what I'm about to suggest.
Can you rem out the line: TextBox1.Text = sUniText
Now try your project again, does the titlebar display the text correctly? If so, then TextBox is modifying sUniText and the immediate fix would be to swap the order: set the titlebar first, then the TextBox
1 Attachment(s)
Re: UNICODE in Form1 Title (VB6+WinXP)
Yes WinXP. I also went to "Display Properties"/Advanced/Advanced Appearance/Item:[Active Title Bar]
and set the Font to different unicode fonts like "Trebuchet MS"
but it displays still "???" instead of unicode chars.
Re: UNICODE in Form1 Title (VB6+WinXP)
See my last reply? If so, how did the test come out?
Re: UNICODE in Form1 Title (VB6+WinXP)
>>rem out the line: TextBox1.Text = sUniText
I removed the line. The Textbox is blank now and it displays still "???" instead
of unicode chars in the "active title bar" of Form1.
Re: UNICODE in Form1 Title (VB6+WinXP)
Ok, later I"ll boot down to XP and try this too & see if I get the similar results.
But will be much later, currently working on something else.
In the meantime, can you try that sample code I posted in the other thread?
Code:
Private Declare Function DefWindowProcW Lib "user32.dll" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Sub Command1_Click()
Dim bUni(0 To 25) As Byte, sUniText As String ' 13 character unicode string for testing
bUni(0) = 205: bUni(1) = 139: bUni(2) = 120: bUni(3) = 81: bUni(4) = 132: bUni(5) = 118
bUni(6) = 251: bUni(7) = 127: bUni(8) = 209: bUni(9) = 139: bUni(10) = 2: bUni(11) = 48
bUni(12) = 244: bUni(13) = 102: bUni(14) = 26: bUni(15) = 89: bUni(16) = 251: bUni(17) = 127
bUni(18) = 209: bUni(19) = 139: bUni(20) = 40: bUni(21) = 87: bUni(22) = 73: bUni(23) = 108
bUni(24) = 237: bUni(25) = 139
sUniText = bUni()
DefWindowProcW Me.hWnd, &HC, 0&, StrPtr(sUniText) ' &HC = WM_SetText
End Sub
Re: UNICODE in Form1 Title (VB6+WinXP)
Here's an idea. If other languages are displaying in the titlebar ok? Then may you don't have 'far eastern' language support installed. Does this link apply?
1 Attachment(s)
Re: UNICODE in Form1 Title (VB6+WinXP)
I tried your "unicode char generator" and it shows "?????????????" (=13chars)
instead of some unicode chars.
>> If other languages are displaying in the titlebar ok? Then may you don't have 'far eastern' language support
My Windows-XP desktop is able to have desktop textfiles which are named with
japanese characters (see "note 5" in the picture)
I have installed german and japanese.
When I save a word document with a japanese .doc name the
japanese chars are shown in the titlebar of Winword.exe.
This means winword is able to have unicode chars in the title but
my compiled VB6 projects seem to be unable to have unicode chars in title.
Re: UNICODE in Form1 Title (VB6+WinXP)
According to your screenshot you are using Classic Theme (Gradient/pre-XP style).
DefWindowProcW only works if Themes are enabled.
The solution for Classic is to subclass and owner-draw your Titlebar.
The easiest fix is to just turn on Themes.
Re: UNICODE in Form1 Title (VB6+WinXP)
Without themes, there is a hack out there that swaps the form's window procedure with unicode one, sets the title, then restores the original window procedure. Sounds really interesting; don't know if it works or not. Maybe I'll even play with it in the next week or so; just out of curiosity.
But it's on PlanetSourceCode and here's the link
2 Attachment(s)
Re: UNICODE in Form1 Title (VB6+WinXP)
Tried the PSC demo but I get "???" in Titlebar:
Attachment 119783
Looking at the screenshot of PSC demo and that is Themed, not Classic.
Attachment 119787
Re: UNICODE in Form1 Title (VB6+WinXP)
Quote:
Originally Posted by
DrUnicode
Tried the PSC demo but I get "???" in Titlebar:
Well then, as not advertised. So much for doing it without subclassing/hooking, unless themed
1 Attachment(s)
Re: UNICODE in Form1 Title (VB6+WinXP)
I tried the Planetsourcecode hack. It did not work without themes. So
I tried to install Luna.theme but installation failed. A MsgBox appeared
"The theme service must be running"
... I started services.msc (Start/Run...) but there is no service like...
theme service
or
windows theme service
-What service do I have to run?
1 Attachment(s)
Re: UNICODE in Form1 Title (VB6+WinXP)
From control panel, open Services. Find Themes & double click on it. Change the startup type to Automatic & click the Start button.
1 Attachment(s)
Re: UNICODE in Form1 Title (VB6+WinXP)
What service do I need? In WinXP there is no service like
'services' or 'themes'.
Re: UNICODE in Form1 Title (VB6+WinXP)
1 Attachment(s)
Re: UNICODE in Form1 Title (VB6+WinXP)
Thank you.
Unfortunately the HELP-Link is no longer valid. So I had to
find the Help-Page on archive org. Here is the link:
Archive.org/Fix-the-Windows-XP-Theme-Problem
To fix the problem with the missing Themes I had to run a *.reg file (restorethemes.reg)
-See attachement (renum restorethemes.txt to restorethemes.reg and run it).
Then you must restart Windows-XP. After a system restart I run services.msc
and I saw the (previously missed) service named "Themes".
I installed the "Windows XP" Theme (under "Display Properties").
All my windows are with rounded edges now and when running your
"UNICODE char generator" (see posting #9) I see the
UNICODE chars in the title of my VB6 Project.
It worked. Thanks for your help.