Announcement

Collapse
No announcement yet.

DDT and Tooltips common control

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

  • DDT and Tooltips common control

    Greetings from the frozen tundra of southeastern Michigan, can anyone point me to an example of using the tooltips common control with buttons created via DDT. Something similar to Lance Edmonds' DDT updown example.
    I have created a toolbar using DDT and I just want to add tooltips to the buttons.

    Thanks,
    Adam Ritchie



  • #2
    The standard toolbar control supports tooltips natively. Add the %TBSTYLE_TOOLTIPS style to the style flags list:
    Code:
    CONTROL ADD "TOOLBARWINDOW32", hDlg, %ID_TOOLBAR, "", 0, 0, 1, 32, %WS_CHILD OR %WS_BORDER OR %WS_VISIBLE OR %CCS_TOP OR %TBSTYLE_TOOLTIPS OR %TB_AUTOSIZE
    Next, in your dialog callback, capture the %WM_NOTIFY message, ie:
    Code:
        IF ...
        ELSEIF CBMSG = %WM_NOTIFY THEN
            LOCAL lpNmh   AS NMHDR PTR
            ' Init NMH pointer.
            lpNmh = CBLPARAM
    
            ' Examine .Code member.
            SELECT CASE @lpNmh.Code
                ' ToolTips notifications.
                CASE %TTN_NEEDTEXT
                    LOCAL lpToolTip AS TOOLTIPTEXT PTR
                    LOCAL TipText   AS ASCIIZ * 64       ' ToolTips text buffer.
                    LOCAL TipStrID  AS DWORD             ' Tip string resource ID.
                    ' Init pointer value.
                    lpToolTip = CBLPARAM
                    ' Adjust toolbar item ID to string resource ID.
                    TipStrID = @lpToolTip.hdr.idFrom
                    ' Load the string if the button is enabled (I could use CONTROL SEND here, but I was too lazy to convert my original SDK-style code!  
                    IF SendMessage(GetDlgItem(CBHNDL, %ID_ToolBar), %TB_GETSTATE, BYVAL @lpToolTip.hdr.idFrom, 0) THEN
                        LoadString GetModuleHandle(BYVAL %NULL), TipStrID, TipText, SIZEOF(TipText)
    '                   SetWindowText ghStatusBar, TipText
                        ' Show tool-tips help.
                        @lpToolTip.lpszText = VARPTR(TipText)
                    END IF
    
                    FUNCTION = 1
            END SELECT
        END IF
    In this example, i have a string table in my resource file and I simply made the tooltip text ID value the same as the ID for each button on my toolbar. If a button is disabled, I don't provide a tooltip.

    I hope this helps!


    -------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Hi Lance, thanks for the code. I should have mentioned(oops!)that I wasn't using CONTROL ADD "TOOLBARWINDOW32" to create my toolbar in the first place, I was just placing buttons underneath my menu and drawing lines above and below(lame I know). The CONTROL ADD "TOOLBARWINDOW32" statement creates the toolbar just fine but the CONTROL ADD IMAGE statements I am using seem to be having a problem with the toolbar, I am not able to get a button press or the tooltips are not working. I experimented with the CONTROL ADD "TOOLBARWIDOW32" statement by remming it out and then the ddt image buttons worked just fine;I could depress the buttons and my callback functions were being called - unrem the statement and recreate the toolbar and POOF! BUTTON LOCK-UP. One interesting thing that raised my eyebrow though,I could tab through the buttons even though I could not depress them. Hmmmmm.....Looking at examples that came with the compiler(Yep, I'm a rookie - but learning!), do I need to create a UDT array to hold the buttons' info and then pass that info to the toolbar somehow. If so, the UDT I can handle creating, but then how would I pass that UDT to the toolbar since there is no parameter in the CONTROL ADD "TOOLBARWINDOW32" statement for this? I will continue to look at some examples and see if something doesn't pop into place for me.

      Thanks,
      Adam

      [This message has been edited by Adam Ritchie (edited February 02, 2000).]

      Comment


      • #4
        It's certainly much easer to use the built-in Windows toolbar control than doing it "by hand"!

        The CONTROL ADD statement I posted simply creates the toolbar control. From there you must fill an array of UDT structures with the information necessary for the toolbar buttons to be added and displayed by Windows. If you need, I'll post some more of the code necessary to create a working toolbar.

        As far as your DDT problems go, it is impossible to suggest a solution without being able to view your code.




        -------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment


        • #5
          Ok, I posted a DDT Toolbar exmple into the Source Code forum... add in the the %WM_NOTIFY code I posted above (with minor modifications as necessary), and you'll have most of a working toolbar app with tooltips!

          -------------
          Lance
          PowerBASIC Support
          mailto:[email protected][email protected]</A>
          Lance
          mailto:[email protected]

          Comment


          • #6
            Lance,

            I downloaded the ddt example you posted and plugged it into my code along with the %WM_NOTIFY code you posted, made some minor modifications to suit my needs and WHAM - VIVA LAS VEGAS!!!!(Or something to that effect) I had no problems getting it to work. It's now doing exactly what I want it do. It also was helpful in that I am beginning to understand DDT more and also(and this is a scary thought)WinAPI calls. Life is good! The universe has returned to normal- well, at least here where I am it has. Thanks so much for the help.

            Adam

            Comment

            Working...
            X