How do I assign a tooltip to a pushbutton?
Would be great if there was a simple FF wrapper function for this FF_CONTROL_SETTOOLTIP().
TIA
Art
Type DLLVERSIONINFO ' For ToolTips
cbSize As Dword
dwMajorVersion As Dword ' Major version
dwMinorVersion As Dword ' Minor version
dwBuildNumber As Dword ' Build number
dwPlatformID As Dword ' %DLLVER_PLATFORM_*
End Type
Declare Function TTver(DLLver As DLLVERSIONINFO) As Long ' For ToolTip
'------------------------------------------------------------------------------------------------------------------------
FUNCTION ToolTipSet(BYVAL hWnd AS DWORD, BYVAL hCtrl AS DWORD, BYVAL sText AS STRING, OPTIONAL BYVAL BalloonStyle AS DWORD, OPTIONAL Title AS ASCIIZ * 100, OPTIONAL IconPic AS DWORD) AS LONG
Static hWnd_PreXPToolTip As Dword
Static hWnd_XPToolTip As Dword
Static TTversion As DLLVERSIONINFO
Local hWnd_ToolTip As Dword
Local TI As TOOLINFO
Local hDLL As Dword
Local hVerProc As Dword
Local returnVal As Long
' Icons= 1 for Info, 2 for Warning, 3 for Error, SP2 can also be HICON handle...but docs are weird saying you have to clean up the copy it makes???
' Title and IconPic are global to the ToolWindow, so only need set on first call to a Balloon Type.
IF BalloonStyle THEN
IF IsWindow(hWnd_XPToolTip)= 0 THEN ' If no XP Tooltip Window.
IF TTversion.CbSize= 0 THEN ' If haven't checked Version already.
TTversion.CbSize= SIZEOF(TTversion)
hDLL= GetModuleHandle("COMCTL32.DLL")
IF hDLL THEN
hVerProc= GetProcAddress(hDLL, "DllGetVersion")
IF hVerProc THEN CALL DWORD hVerProc USING TTver(TTversion) TO returnVal
END IF
END IF
IF TTversion.dwMajorVersion > 5 OR (TTversion.dwMajorVersion= 5 AND TTversion.dwMinorVersion >= 80) THEN ' XP Version Available.
hWnd_XPToolTip= CreateWindowEx(0, "tooltips_class32", "", %TTS_BALLOON OR %TTS_NOPREFIX OR %TTS_ALWAYSTIP, 0,0,0,0,0, BYVAL 0, GetModuleHandle(BYVAL %Null), BYVAL 0)
IF IsWindow(hWnd_XPToolTip) THEN
SendMessage(hWnd_XPToolTip, %TTM_SETMAXTIPWIDTH, 0, 300)
SendMessage(hWnd_XPToolTip, %TTM_SETTITLE, IconPic, BYVAL VARPTR(Title))
END IF
END IF
END IF
hWnd_ToolTip= hWnd_XPToolTip
END IF
IF IsWindow(hWnd_ToolTip)= 0 THEN ' No Selected Tooltip Window yet or error making Ballon/XP Style Tooltip.
IF IsWindow(hWnd_PreXPToolTip)= 0 THEN ' If no PreXP Tooltip Window.
hWnd_PreXPToolTip= CreateWindowEx(0, "tooltips_class32", "", %TTS_NOPREFIX OR %TTS_ALWAYSTIP, 0,0,0,0,0, BYVAL 0, GetModuleHandle(BYVAL %Null), BYVAL 0)
IF IsWindow(hWnd_PreXPToolTip) THEN SendMessage(hWnd_PreXPToolTip, %TTM_SETMAXTIPWIDTH, 0, 300)
END IF
hWnd_ToolTip= hWnd_PreXPToolTip
END IF
IF IsWindow(hWnd_ToolTip)= 0 THEN EXIT FUNCTION
TI.cbSize= SIZEOF(TI)
TI.hWnd= hWnd
IF hCtrl= 0 THEN TI.uId= hWnd ELSE TI.uId = hCtrl ' If 0 set to Window else set to Control. hCtrl is Handle, not ID of control.
FUNCTION= SendMessage(hWnd_ToolTip, %TTM_DELTOOL, 0, BYVAL VARPTR(TI))
IF LEN(sText) > 0 THEN
TI.uFlags= %TTF_SUBCLASS OR %TTF_IDISHWND
TI.lpszText= STRPTR(sText)
FUNCTION= SendMessage(hWnd_ToolTip, %TTM_ADDTOOL, 0, BYVAL VARPTR(TI))
END IF
End Function
'------------------------------------------------------------------------------------------------------------------------
Wow! Works great. Thanks so much. When I grow up in FF, I want to code just like you.
;>)
Paul - might want to turn this into a FF_Control_SetTooltip wrapper with Roger's permission.
Already gave it to him in a couple other posts. How to implement it is probably what is holding it up. One glitch right now is if you have no Common Controls in your form it gives an error cause the inc file is needed, so perhaps it could be something like the menu editors, statusbar editors, and the like where you open up the dialog and get a list of controls and can set the tooltips and if some are declared then it includes the common control inc file. Then the same function can be used as a FF Wrapper to modify/remove the tip. (Specifying no text removes the tip)