Announcement

Collapse
No announcement yet.

multiline tooltips on a listview

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • multiline tooltips on a listview

    The standard tooltips are too long to fit the dialog! Hours of searching have got me nowhere. Can anyone advise on how this is done please?

  • #2
    Send this message to the Tooltip window: (Length can be adjusted, is now 200)
    Code:
    SendMessage hTTip, %TTM_SETMAXTIPWIDTH, 0, 200
    Regards,
    Peter

    "Simplicity is a prerequisite for reliability"

    Comment


    • #3
      Thanks Peter, I fear I may have expressed myself poorly, I am using default behaviour by giving my Listview the %LVS_EX_LABELTIP OR %LVS_EX_INFOTIP styles. Does your answer imply that I should do it another way?

      Comment


      • #4
        I tried it with those styles and the result is the same. I don't know what the styles suppose to do but I don't see any difference... With a long text its just cut up in multiple lines if it gets too long...
        Regards,
        Peter

        "Simplicity is a prerequisite for reliability"

        Comment


        • #5
          Yes, but the difference is that you have a handle to the tooltip (hTTIP) and I don't, how did you get it?

          Comment


          • #6
            I add the tooltips to all controls with CreateWindowEx...
            Code:
            '======================================================================================================================
            ' AddToolTips + EnumChildProc:    Adds tooltips to a window
            '----------------------------------------------------------------------------------------------------------------------
            Function EnumChildProc(ByVal CtrlDlg As Long, param As Long) As Long
              Local lTI As TOOLINFO, lZStr As Asciiz * 128, lRect As RECT
                GetClassName CtrlDlg, lzStr, SizeOf(lzStr)
                lTI.cbSize  = SizeOf(lTI)
                lTI.uFlags  = %TTF_IDISHWND Or %TTF_SUBCLASS
                lTI.hwnd    = hDlg
                lTI.uID     = CtrlDlg
                lTI.hInst   = SI.dwInst
                lTI.lpszText= %LPSTR_TEXTCALLBACK
                SetRect lRect, 5,5,100,50
                lTI.rec = lrect
                SendMessage hTTip, %TTM_ADDTOOL, 0, VarPtr(lTI)
              Function = 1
            End Function
            
            '----------------------------------------------------------------------------------------------------------------------
            Function AddToolTips (ByVal hDlg As Long) As Long
              hTTip = CreateWindowEx (0, _
                                      "tooltips_class32", _
                                      ByVal %NULL, _
                                      %WS_POPUP Or %TTS_ALWAYSTIP, _
                                      %CW_USEDEFAULT, _
                                      %CW_USEDEFAULT, _
                                      %CW_USEDEFAULT, _
                                      %CW_USEDEFAULT, _
                                      ByVal hDlg, _
                                      ByVal %NULL, _
                                      GetWindowLong (hDlg, %GWL_HINSTANCE), _
                                      ByVal %NULL)
              If hTTip = %FALSE Then Function = 0 : Exit Function
              Function = EnumChildWindows (hDlg, CodePtr(EnumChildProc), 0)
              SendMessage hTTip, %TTM_SETMAXTIPWIDTH, 0, 200
            End Function
            In EnumChildProc you can exclude some controls that don't need tooltips, like static controls (labels)
            Regards,
            Peter

            "Simplicity is a prerequisite for reliability"

            Comment

            Working...
            X