GadgetToolTip and Unicode characters (Windows)

Windows specific forum
User avatar
Michael Vogel
Addict
Addict
Posts: 2806
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

GadgetToolTip and Unicode characters (Windows)

Post by Michael Vogel »

Tried to include some unicode characters within tooltips but the results are not as expected (tested with PB5.73 86/64).
Here the full text will only be displayed when the string doesn't contain any unicode chars (Case 3), for Case 2 only some chars at the end are truncated, Case 1 only show 'Look here - > '.

Code: Select all


Enumeration
	#Win
	#Col1Name
EndEnumeration

#ChrCtrl=		Chr($2318)
#ChrAlt=		Chr($25c8)
#ChrShift=	Chr($21D1)
#ChrShiftCtrl=	Chr($21D1)+Chr($2318)
#ChrShiftAlt=	Chr($2b06)

OpenWindow(#Win,10,10,300,200,"*")
StringGadget(#Col1Name,10,10,200,30,"Hover me...")

SetActiveGadget(#Col1Name)

s.s="Look here "

Select 1
Case 1
	s=s+" - > "+Str(i)+#ChrCtrl+"*"+#ChrAlt+Str(i)
Case 2
	s=s+" - >>> "+#ChrCtrl+"*"+#ChrAlt+" <<<"
Case 3
	s=s+" - >>> A * B <<<"
EndSelect

Debug "Set "+Str(#Col1Name)+" = '"+s+"'"
GadgetToolTip(#Col1Name,s)

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow



User avatar
mk-soft
Always Here
Always Here
Posts: 6242
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: GadgetToolTip and Unicode characters (Windows)

Post by mk-soft »

Its window features ?!

Code: Select all


Enumeration
	#Win
	#Col1Name
EndEnumeration

#ChrCtrl=		Chr($2318)
#ChrAlt=		Chr($25c8)
#ChrShift=	Chr($21D1)
#ChrShiftCtrl=	Chr($21D1)+Chr($2318)
#ChrShiftAlt=	Chr($2b06)

OpenWindow(#Win,10,10,300,200,"*")
StringGadget(#Col1Name,10,10,200,30,"Hover me...")

SetActiveGadget(#Col1Name)

s.s="Look here "

;s=s+" - >>> "+Str(i)+#ChrCtrl+"*"+#ChrAlt+Str(i); + " <<<"
s=s+" - >>> 0"+#ChrCtrl+"*"+#ChrAlt+"0"
;s=s+" - >>> A * B <<<"

ShowMemoryViewer(@s, 64)
Debug "Set "+Str(#Col1Name)+" = '"+s+"'"
GadgetToolTip(#Col1Name,s)

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow



My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Michael Vogel
Addict
Addict
Posts: 2806
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: GadgetToolTip and Unicode characters (Windows)

Post by Michael Vogel »

Windows shouldn't be the problem...

Code: Select all

Enumeration
	#Win
	#Col1Name
EndEnumeration

#ChrCtrl=		Chr($2318)
#ChrAlt=		Chr($25c8)
#ChrShift=	Chr($21D1)
#ChrShiftCtrl=	Chr($21D1)+Chr($2318)
#ChrShiftAlt=	Chr($2b06)

Procedure GadgetToolTipx(Gadget,Text.s)

	Protected hWndToolTip = CreateWindowEx_(0, "ToolTips_Class32", "", #WS_POPUP | #TTS_NOPREFIX, 0, 0, 0, 0, WindowID(#Win), 0, GetModuleHandle_(0), 0)

	SendMessage_(hWndToolTip, #TTM_SETTIPTEXTCOLOR, GetSysColor_(#COLOR_INFOTEXT), 0)
	SendMessage_(hWndToolTip, #TTM_SETTIPBKCOLOR, GetSysColor_(#COLOR_INFOBK), 0)
	SendMessage_(hWndToolTip, #TTM_SETMAXTIPWIDTH,0,15*Len(Text))

	Tip.TOOLINFO\cbSize = SizeOf(TOOLINFO)
	Tip\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS
	Tip\hWnd = GadgetID(Gadget)
	Tip\uId = GadgetID(Gadget)
	Tip\lpszText = @Text
	SendMessage_(hWndToolTip, #TTM_ADDTOOL, 0, Tip)

EndProcedure

OpenWindow(#Win,10,10,300,200,"*")
StringGadget(#Col1Name,10,10,200,30,"Hover me...")

SetActiveGadget(#Col1Name)

s.s="Look here "

;s=s+" - >>> "+Str(i)+#ChrCtrl+"*"+#ChrAlt+Str(i); + " <<<"
s=s+" - >>> 0"+#ChrCtrl+"*"+#ChrAlt+"0"
;s=s+" - >>> A * B <<<"

GadgetToolTipX(#Col1Name,s)

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
User avatar
Michael Vogel
Addict
Addict
Posts: 2806
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: GadgetToolTip and Unicode characters (Windows)

Post by Michael Vogel »

Still lost...

As seen in the latest post, Windows can handle all chars with no problem. But when calling GadgetTooltip, certain characters (like Chr($25c8)) corrupting the tooltip text.

The following code does show the full tooltip text, when PokeW(?char3,Asc(#ChrCtrl)) overwrites the #ChrAlt which is located in the datasection at position char3. With this line missing or the line PokeW(?char2,Asc(#ChrAlt)) active, the tooltip text gets truncated.

I tendend to say this is a bug, because the Windows tooltip function does work correctly and the command SysTrayIconTooltip does also.

Code: Select all

Enumeration
	#Win
	#Col1Name
EndEnumeration

#ChrCtrl=		Chr($2318)
#ChrAlt=		Chr($25c8)
#ChrShift=	Chr($21D1)
#ChrShiftCtrl=	Chr($21D1)+Chr($2318)
#ChrShiftAlt=	Chr($2b06)

DataSection
	string:
	Data.a $4C,$00,$6F,$00,$6F,$00,$6B,$00,$20,$00,$68,$00,$65,$00,$72,$00
	Data.a $65,$00,$20,$00,$20,$00,$2D,$00,$20,$00,$3E,$00,$3E,$00,$3E,$00
	Data.a $20,$00,$28,$00
	char1:
	Data.a $D1,$21
	char2:
	Data.a $18,$23
	char3:
	Data.a $C8,$25
	Data.a $58,$00,$29,$00,$00,$00
EndDataSection

OpenWindow(#Win,10,10,300,200,"*")
StringGadget(#Col1Name,10,10,200,30,"Hover me...")
SetActiveGadget(#Col1Name)

PokeW(?char3,Asc(#ChrCtrl));	okay
PokeW(?char2,Asc(#ChrAlt)) ;	not okay

s.s=PeekS(?String,-1,#PB_Unicode)
GadgetToolTip(#Col1Name,PeekS(@s,-1,#PB_Unicode))

CreateImage(0,20,20,32,#Red)
AddSysTrayIcon(0,WindowID(#win),ImageID(0))
SysTrayIconToolTip(0,s)


Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
User avatar
Michael Vogel
Addict
Addict
Posts: 2806
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: GadgetToolTip and Unicode characters (Windows)

Post by Michael Vogel »

Maybe anyone is able to find a logic which character combinations do work for GadgetToolTip...

Code: Select all

Enumeration
	#Win
	#Col1Name
EndEnumeration

#ChrCtrl=		Chr($2318)
#ChrAlt=		Chr($25c8)
#ChrShift=	Chr($21D1)
#ChrShiftCtrl=	Chr($21D1)+Chr($2318)
#ChrShiftAlt=	Chr($2b06)
#ChrBackspace=	Chr($2190)
#ChrArrow=	Chr($21E2)
#ChrRight=	Chr($2192)
#ChrDirectory=	Chr($1D30)+Chr($1D35)+Chr($1D3F)
#ChrDelete=	Chr($2715)
#ChrBar=		Chr($2503)
#ChrMouse=	Chr(9974)
#ChrNull=		#ChrDelete

DataSection
	string:
	Data.a $4C,$00,$6F,$00,$6F,$00,$6B,$00,$20,$00,$68,$00,$65,$00,$72,$00
	Data.a $65,$00,$20,$00,$20,$00,$2D,$00,$20,$00,$3E,$00,$3E,$00,$3E,$00
	Data.a $20,$00
	char:
	Data.a $18,$23
	errorchar:
	Data.a $C8,$25; Alt !
	Data.a $20,$00,$3c,$00,$3c,$00,$3c,$00,$00,$00
EndDataSection

OpenWindow(#Win,10,10,220,520,"*")

c=$2500

For i=0 To 19
	; GadgetToolTip works truncates text for certain character combinations...
	StringGadget(i,10,10+i*25,200,24,"Hover me... ("+Chr(c+i)+" $"+Hex(c+i)+") "+ReplaceString(Mid("....        .   .  .",i+1,1),"."," <- WORKS"))
	PokeW(?char,c+i)
	s.s=PeekS(?String,-1,#PB_Unicode)
	GadgetToolTip(i,s)
	
	; SysTrayIconToolTip works in all cases...
	CreateImage(i,16,16,32,#Gray)
	StartDrawing(ImageOutput(i))
	DrawText(0,0,Chr(c+i),#Black,#White)
	StopDrawing()
	AddSysTrayIcon(i,WindowID(#win),ImageID(i))
	SysTrayIconToolTip(i,s)
Next i

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow



Fred
Administrator
Administrator
Posts: 18199
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: GadgetToolTip and Unicode characters (Windows)

Post by Fred »

It seems like the characters you used are somehow interpreted by Windows. It works in your method because you force the tooltip width with #TTM_SETMAXTIPWIDTH but it should not be necessary according to MSDN: https://learn.microsoft.com/en-us/windo ... axtipwidth . A -1 value should handle any width. I don't want to force the width, as it can impact other things. If you use standard unicode char like:

Code: Select all

s=s+" - >>> 0汉"
Post Reply