Announcement

Collapse
No announcement yet.

Tooltips DDT

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

  • Peter Lameijn
    replied
    Chris,

    Thanks, you're right in that point, but something else was wrong; I even didn't get
    a WM_NOTIFY message. In the enumeration function, the line
    If lZStr = "STATIC" should be If lZStr <> "STATIC"
    (No need to add tips to static controls...)


    ------------------
    Peter.
    mailto[email protected][email protected]</A>

    [This message has been edited by Peter Lameijn (edited April 01, 2001).]

    Leave a comment:


  • Chris Boss
    replied
    Peter ;

    Your code won't work !

    The TYPE defined in the common control inc file is :

    Code:
    TYPE TOOLTIPTEXT
      hdr          AS NMHDR
      lpszText     AS ASCIIZ PTR
      szText       AS ASCIIZ * 80
      hInst        AS LONG
      uFlags       AS DWORD
    END TYPE
    Your have defined the sztext member as lpszText (a pointer) and
    you are trying to change the pointer to a pointer towards your
    asciiz string in your function. When the message returns control
    to windows (function ends), your asciiz string which is local will
    disappear before Windows can process the string.

    The tooltip control is passing a valid ascii string buffer in the
    type described above, so you don't need to define your own asciiz
    string. You must put data into the asciiz buffer passed to your
    dialog procedure, not change it to another buffer.




    ------------------

    Leave a comment:


  • Semen Matusovski
    replied
    Peter --
    Very doubt that a class name for buttons is "STATIC"

    ------------------
    E-MAIL: [email protected]

    Leave a comment:


  • Peter Lameijn
    replied
    What's wrong (or missing here)? I don't get tooptips on the buttons
    The enumeration function seems to work OK. (Adds all controls to the tooptip)
    Code:
    #Compile Exe
    #Include "win32api.inc"
    #Include "commctrl.inc
    
    Global hDlg      As Long
    Global hTTip     As Long
    Global hInstance As Long
    
    '=====================/ Enumeration callback /=================================
    
    Function EnumChildProc(ByVal CtrlDlg As Long, param As Long) As Long
      Local lTI As TOOLINFO, lZStr As Asciiz * 128
      GetClassName CtrlDlg, lzStr, SizeOf(lzStr)
      If lzStr = "STATIC" Then
        lTI.cbSize  = SizeOf(lTI)
        lTI.uFlags  = %TTF_IDISHWND Or %TTF_SUBCLASS
        lTI.hwnd    = hDlg
        lTI.uID     = CtrlDlg
        lTI.hInst   = hInstance
        lTI.lpszText= %LPSTR_TEXTCALLBACK
        SendMessage hTTip, %TTM_ADDTOOL, 0, VarPtr(lTI)
      End If
      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
    
      If (EnumChildWindows (hDlg, CodePtr(EnumChildProc), 0)) = 0 Then
        Function = %FALSE
      Else
        Function = %TRUE
      End If
    End Function
    
    '==============================================================================
    CallBack Function MainCb() As Long
      Local lTTptr As TOOLTIPTEXT Ptr, lZStr As Asciiz * 64
      Select Case CbMsg
        Case %WM_NOTIFY
          lTTPtr = CbLparam
          If @lTTPtr.Hdr.Code = %TTN_NEEDTEXT Then
             lZStr = Time$
             @lTTPtr.lpszText = VarPtr(lZStr)
          End If
      End Select
    End Function
    '==============================================================================
    Function WinMain (ByVal CurInst&, ByVal PrvInst&, CmdLine As Asciiz Ptr, _
                      ByVal CmdShow&) Export As Long
      Local lRet As Long
      hInstance = CurInst&
      InitCommonControls
      Dialog New 0, "ToolTip",,,100,100,%WS_OVERLAPPED Or %WS_SYSMENU To hDlg
      Control Add Button, hDlg,101,"Button #1",30,10,40,14,%WS_TABSTOP
      Control Add Button, hDlg,102,"Button #2",30,30,40,14,%WS_TABSTOP
      Control Add Button, hDlg,103,"Button #3",30,50,40,14,%WS_TABSTOP
      Control Handle hDlg,101 To lRet
      AddToolTips hDlg
      Dialog Show Modal hDlg Call MainCb
    End Function
    ------------------
    Peter.
    mailto[email protected][email protected]</A>

    [This message has been edited by Peter Lameijn (edited April 01, 2001).]

    Leave a comment:


  • Chris Boss
    replied
    I tried this myself and I couldn't use CONTROL ADD for some reason.
    I had to resort to using CreateWindowEx !

    CreateWindowEx should work fine !



    ------------------

    Leave a comment:


  • Peter Lameijn
    started a topic Tooltips DDT

    Tooltips DDT

    Has anybody used 'Control Add ""tooltips_class32".....' instead of
    CreateWindowEx to produce tooltips? I've not seen any examples and cannot
    get it to work.


    ------------------
    Peter.
    mailto[email protected][email protected]</A>
Working...
X