www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dwt - Problem with tooltips on Windows

reply Bill Baxter <dnewsgroup billbaxter.com> writes:
snippets\tooltips\Snippet41 does not work properly for me.  Instead of 
the intended tooltip text I see random strings of Japanese characters.
It could be related to the fact that my default codepage is set to 932 
(Japanese).  Probably for someone else it would just look like random 
garbage instead of random Japanese garbage.

--bb
May 20 2008
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Bill Baxter wrote:
 snippets\tooltips\Snippet41 does not work properly for me.  Instead of 
 the intended tooltip text I see random strings of Japanese characters.
 It could be related to the fact that my default codepage is set to 932 
 (Japanese).  Probably for someone else it would just look like random 
 garbage instead of random Japanese garbage.
 
 --bb
I think the problem may be in Shell.d:1690, this function: void setToolTipText (NMTTDISPINFO* lpnmtdi, char [] buffer) { ... if (!hasCursor ()) return; auto hHeap = OS.GetProcessHeap (); if (lpstrTip !is null) OS.HeapFree (hHeap, 0, lpstrTip); int byteCount = buffer.length; lpstrTip = cast(TCHAR*)OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); OS.MoveMemory (lpstrTip, buffer.ptr, byteCount); lpnmtdi.lpszText = lpstrTip; } It's taking a utf8 string and pointing to it with a TCHAR* which is actually a wide char string type. This fixes it for me: void setToolTipText (NMTTDISPINFO* lpnmtdi, char [] buffer) { /* * Ensure that the current position of the mouse * is inside the client area of the shell. This * prevents tool tips from popping up over the * shell trimmings. */ if (!hasCursor ()) return; auto hHeap = OS.GetProcessHeap (); if (lpstrTip !is null) OS.HeapFree (hHeap, 0, lpstrTip); TCHAR[] tbuffer = StrToTCHARs(buffer); int byteCount = tbuffer.length * TCHAR.sizeof; lpstrTip = cast(TCHAR*)OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); OS.MoveMemory (lpstrTip, tbuffer.ptr, byteCount); lpnmtdi.lpszText = lpstrTip; } --bb
May 20 2008
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Bill Baxter wrote:
 Bill Baxter wrote:
 snippets\tooltips\Snippet41 does not work properly for me.  Instead of 
 the intended tooltip text I see random strings of Japanese characters.
 ...
Doh! Looks like you just fixed this one on May 19! So... nevermind. --bb
May 20 2008