ToolTips plug-in

From NSIS Wiki
(Redirected from ToolTips)
Jump to navigationJump to search
Author: Joel (talk, contrib)


Links


Older version (does not support color/font changes) Tooltips.zip (2 KB) (Mirror)

Newer version (supports color/font changes) Main


Description

Plugin that will display a custom tooltip (modern or classic) in the user selected control.

The older version will use the system default colors and font settings.

For the newer version you -must- specify the colors and font to use.

Limitations and known issues

Custom color and font settings (newer version feature) do not work on Windows 7.

On Windows Vista and Windows 7, the width required for the very first line of your tooltip is used for the entire tooltip. This can cause 2nd, 3rd, etc. lines to be cut off if they are wider than the first line. A workaround is to pad the first line to fit the width of your widest line. ( on Windows XP, the width of the widest line is used for the entire tooltip by default )

If the user has disabled balloon tooltips, the Modern tooltip type will not be displayed. If you wish to use modern tooltips you may wish to add a fallback to the Classic tooltip if this is the case:

StrCpy $0 1
ReadRegDWORD $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\" "EnableBalloonTips"
${If} $0 == 1
${OrIf} $0 == ""
  ToolTips::Modern
${Else}
  ToolTips::Classic
${EndIf}

Below is a mini header that can be used to take the issues above into account. You must still manually pad the first line. The script removes this padding when the classic tooltip is used as a fallback.

; Usage:
; ${ToolTip} hwnd icon "title" "text"
;   hwnd: the handle to the window/control for which to create a tooltip
;   icon: the icon ID to use with Modernbubble tooltips, not used by Classic
;   title: the title to use on Modern/bubble tooltips, not used by Classic
;   text: the main text to use on the tooltip
!include "LogicLib.nsh"
!include "StrFunc.nsh"
${StrRep}
!macro ToolTip hwnd icon title text
  Push $0
  Push $1
  StrCpy $1 ${hwnd}
  StrCpy $0 1
  ReadRegDWORD $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\" "EnableBalloonTips"
  StrCpy $0 ""
  ${If} $0 == 1
  ${OrIf} $0 == ""
    ToolTips::Modern $1 ${icon} "${title}" "${text}"
  ${Else}
    ${StrRep} $0 "${text}" "  " ""
    ToolTips::Classic $1 "$0"
  ${EndIf}
  Pop $1
  Pop $0
!macroend
!define ToolTip `!insertmacro ToolTip`