I try to create unicode tooltip.

My code :


.DATA
ToolTipsClassName db 'T', 0, 'o', 0, 'o', 0, 'l', 0, 't', 0, 'i', 0, 'p', 0, 's', 0, '_', 0, 'c', 0, 'l', 0, 'a', 0, 's', 0, 's', 0 ,'3', 0, '2', 0, 0, 0

.CODE
...
invoke CreateWindowExW, 0, addr ToolTipsClassName, 0, TTS_ALWAYSTIP, 0, 0, 0, 0, hwnd, 0, hInstance, 0
cmp eax,0
jz @Err
mov hwndTool,eax
mov ti.cbSize,sizeof TOOLINFO
mov ti.uFlags,TTF_SUBCLASS or 100h
push hwnd
pop ti.hWnd
or ti.uFlags, TTF_IDISHWND

push hButton
pop ti.uId
lea eax, szRU ; Some Russian text
mov ti.lpszText, eax
invoke SendMessageW, hwndTool, TTM_ADDTOOL, 0, addr ti


The result is a totally unreadable tooltip.
I've put the szRU in hex to be sure.
Is it possible to have unicode tooltip?
I work on win2k fr with comctl32 version : 5.81.2920.0
Posted on 2002-01-22 10:00:49 by gael
Your zeros are on the wrong side!

You've declared your string as a series of bytes, but unicode is a series of words, and as you'll be aware words are byte swapped on Intel systems!

Add a zero to the start of the string to sort it out, if that doesn't work post again...
Prefereably the whole code (or a cut down thing that will compile), so we can test it ourselves!

Mirno
Posted on 2002-01-22 11:02:08 by Mirno
The string is not wrong, the zeros are ordered correct.

The question is, how does your russian text look like?

Second question - does your tooltip font support russian chars?
Posted on 2002-01-23 03:45:10 by beaster
My russian text look like good in Button title but not in tooltip (square, etc...).
What do you mean by does my tooltip font support russian char?
i must to set particular font to my tooltip?
With which message?

my code (probably russian must be installed)


.686p
.Model flat, StdCall

WinMain PROTO hInst : DWORD, hPrevInst : DWORD, CmdLine : DWORD, CmdShow : DWORD

option casemap:none

include ..\INC\perso01.inc ; API with W
include ..\INC\windows.inc


includelib advapi32.lib
includelib kernel32.lib
includelib comctl32.lib
includelib comdlg32.lib
includelib shell32.lib
includelib user32.lib
includelib gdi32.lib
includelib wsock32.lib
includelib imm32.lib
includelib winmm.lib



.DATA

hInstance dd ?
hbutton dd ?
hSoft dd ?
myclass db 'm', 0, 'y', 0, 'c', 0, 'l', 0, 'a', 0, 's', 0, 's', 0, 0, 0
hwndTool dd ?

szRusse db 20h, 04, 43h, 04, 41h, 04h, 41h, 04, 3Ah, 04, 38h, 04, 0, 0, 0
ToolTipsClassName db 'T', 0, 'o', 0, 'o', 0, 'l', 0, 't', 0, 'i', 0, 'p', 0, 's', 0, '_', 0, 'c', 0, 'l', 0, 'a', 0, 's', 0, 's', 0 ,'3', 0, '2', 0, 0, 0
Button db 'b', 0, 'u', 0, 't', 0, 't', 0, 'o', 0, 'n', 0, 0, 0

.CODE

Main :
invoke GetModuleHandleW, 0
mov hInstance,eax
invoke WinMain, hInstance, 0, 0, SW_SHOWDEFAULT
invoke ExitProcess, eax
;=============================================================================================================
WinMain proc hInst : DWORD, hPrevInst : DWORD, CmdLine : DWORD, CmdShow : DWORD
LOCAL wc : WNDCLASSEX
LOCAL msg : MSG
LOCAL hwnd : DWORD
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInstance
pop wc.hInstance
mov wc.hbrBackground, BLACK_PEN
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET myclass
invoke LoadIconA, hInstance, 0
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursorA, hInstance, 0
mov wc.hCursor,eax
invoke RegisterClassExW, addr wc
invoke CreateWindowExW, WS_EX_TOPMOST, addr myclass, addr myclass, WS_VISIBLE+WS_CAPTION+\
WS_MINIMIZEBOX+WS_SYSMENU , 100,\
100, 372, 242, 0, 0, hInst, 0
mov hSoft,eax
invoke ShowWindow, hSoft, SW_SHOWNORMAL
invoke UpdateWindow, hSoft
.WHILE TRUE
invoke GetMessageW, addr msg, 0, 0, 0
.BREAK .IF (!eax)
invoke TranslateMessage, addr msg
invoke DispatchMessageW, addr msg
.ENDW
mov eax,msg.wParam
ret

WinMain endp
;=============================================================================================================
WndProc proc uses ecx esi hwnd : DWORD, uMsg : DWORD, wParam : DWORD, lParam : DWORD
LOCAL ti : TOOLINFO
mov eax,uMsg
cmp eax, WM_CREATE
jz @ini
cmp eax, WM_DESTROY
jz @ferme
invoke DefWindowProcW, hwnd, uMsg, wParam, lParam
ret
@ferme :
invoke PostQuitMessage, 0
xor eax,eax
ret
@ini :

invoke CreateWindowExW, WS_EX_STATICEDGE, addr Button, addr szRusse, WS_VISIBLE+WS_CHILD+BS_VCENTER+\
BS_TEXT+BS_CENTER, 195, 105, 166, 18, hwnd, 112, hInstance, 0
mov hbutton,eax
invoke InitCommonControls
invoke CreateWindowExW, 0, addr ToolTipsClassName, 0, TTS_ALWAYSTIP, 0, 0, 0, 0, hwnd, 0, hInstance, 0
cmp eax,0
jz @Err
mov hwndTool,eax
mov ti.cbSize,sizeof TOOLINFO
mov ti.uFlags,TTF_SUBCLASS or 100h
push hwnd
pop ti.hWnd
or ti.uFlags, TTF_IDISHWND

push hbutton
pop ti.uId
lea eax, szRusse
mov ti.lpszText, eax
invoke SendMessageW, hwndTool, TTM_ADDTOOL, 0, addr ti
ret

@Err :
invoke MessageBoxA, 0, 0, 0, 0
ret
WndProc endp
end Main
Posted on 2002-01-23 04:31:59 by gael
it seems, that the assembler uses the A defines instead of the W.

Try these:
TOOLINFOW instead of TOOLINFO
TTM_ADDTOOLW instead of TTM_ADDTOOL

maybe you must define UNICODE or something for the correct assembling of the include files.

Tooltips use the systems default font, change it with WM_SETFONT
Posted on 2002-01-23 07:24:20 by beaster
you're right
it work fine now.
except for TOOLINFO
no need to uses TOOLINFOW, TOOLINFO is the one to use.

?????? ??????? !:alright:
Posted on 2002-01-23 13:40:26 by gael
yep, TOOLINFOA and TOOLINFOW is equal.

here I understand only egyt ;)
Posted on 2002-01-23 14:22:27 by beaster