View Full Version : Setting psTitle on cToolTipController does not work

Allan Greis Eriksen
5-Nov-2022, 11:56 AM
It gives some scrambled text as it is not send as UTF-16 text but UTF-8 text.

Create a new test project and add this view as an example:

Use Windows.pkg
Use DFClient.pkg

Deferred_View Activate_oTestToolTip for ;
Object oTestToolTip is a dbView

Set Border_Style to Border_Thick
Set Size to 200 300
Set Location to 2 2
Set Label to "TestToolTip"

Set psTitle of ghoToolTipController to "Test title"

Object oForm1 is a Form
Set Size to 13 100
Set Location to 13 101
Set psToolTip to "Test tool tip text"


The error shows like this:

To fix for now you can subclass the cToolTipController and fix the method your self:

// Replace the standard oToolTipController in your src file with an object of this class.

Class cToolTipControllerFix is a cToolTipController

// Eksample of a corrected method that takes a native utf-8 string and send as UTF-16 text message.
Procedure Set psTitle String sTitle
Integer iVoid iIcon
Pointer lpsTitle
Handle hToolTip
String sIcon
WString wsTitle

Set psTitle_private to sTitle
Move sTitle to wsTitle

// Icon & title must be set together. Determine what the icon is so we can set it.
// It will be either an icon ID for a standard icon, or an icon filename....
Get piIcon to iIcon
If (iIcon <> TTI_NONE) Begin
Set piIcon to iIcon // this will set the icon & title.

// Test if an icon filename is set....
Get psIcon_private to sIcon
If (sIcon <> "") Begin
Send LoadIcon sIcon // this will set icon & title.

// If we got here then there is no icon, just set the title then....
Get phToolTip to hToolTip
Move (SendMessage(hToolTip, TTM_SETTITLE, TTI_NONE, AddressOf(wsTitle))) to iVoid


Object oToolTipControllerFix is a cToolTipControllerFix
Move Self to ghoToolTipController

The result:

Vincent Oorsprong
7-Nov-2022, 03:54 AM

Thanks for reporting. I've duplicated it and it will be logged.