ToolTips

Started by Douglas McDonald, June 26, 2010, 11:07:12 AM

Previous topic - Next topic

Douglas McDonald

I searched on tooltips and found a few threads and some cool code samples from 2009. Before I try and add the code samples to my project I wonder if FF3 supports or is going to add tooltips to buttons,lables, textboxes ect...

I see that some, very few controls have a tooltips but I have not been able to make it work. There is nothing I can find in the manual on the subject.
My current version is 3.09
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

José Roca

If you use my include files, add #INCLUDE "WinCtrl.inc" to your program and call a function named Window_AddTooltip.

Usage:


' ========================================================================================
' Adds a tooltip control to the window
' Parameters:
' - hParent = Parent window handle
' - hwnd = Handle of the window
' - strTooltipText = Tooltip text
' - dwStyle = Tooltip window style(s) [pass -1 for default styles]
' - dwExStyle = Tooltip window extended style(s) [pass -1 for default styles]
' - bCentered = Centered (TRUE or FALSE)
' Note: If you want balloon tooltips, pass the following values in the dwStyle parameter:
' %WS_POPUP OR %WS_BORDER OR %WS_CLIPSIBLINGS OR %TTS_BALLOON
' Return Value:
'   The handle of the tooltip control
' ========================================================================================


hParent is the handle of the form and hwnd the handle of the control.

Douglas McDonald

Jose,

Once again you wrote the tool make things look easy. I'm grateful.

Thank you
Doug
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

José Roca

One of the biggest advantages of using the Windows API instead of DDT is that you don't have to wait for years to see if Mr. Zale will add CONTROL ADD TOOLTIP to the language. You simply write your wrapper function or use an existing one. There are so many in my include files that even I have a hard time to remember them.

Douglas McDonald

#4
Jose,

I've used your Window_AddTooltip and it works well in XP but it doesn't work in win7 x64. I get a handle returned but no tool tip shows up.


Function MAIN_BUTTON_WM_MOUSEMOVE ( _
                                  ControlIndex  As Long,  _  ' index in Control Array
                                  hWndForm      As Dword, _  ' handle of Form
                                  hWndControl   As Dword, _  ' handle of Control
                                  MouseFlags    As Long,  _  ' virtual keys that are pressed
                                  xPos          As Long,  _  ' x-coordinate of cursor
                                  yPos          As Long   _  ' y-coordinate of cursor
                                  ) As Long
Local retval As Dword
'ztrace Str$(MouseFlags)
retval = Window_AddTooltip(HWND_MAIN,HWND_MAIN_BUTTON(0),"TIP",-1,-1)',%false,%TTS_BALLOON)
'ztrace Str$(retval)
End Function




Thank you
Doug
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

Douglas McDonald

It works in win7 x64. At least a program compiled on XP shows tooltips when run on a win7 x64 PC.

now i can't get it to compile on the win7 x64 Pc do to a resource file error

Thanks
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

José Roca

Works fine in Windows 7 32 bit. Don't have the 64 bit version.

Martin Francom

Does anyone have a FF3 example program that demonstrates the use of Jose'  AddToolTip  control   that they would be willing to post?

José Roca

It is not a control, just a function.

Robert Eaton

The simple statement in the code below seems to work. (Of course you need to use the include files from Jose.)

However, I haven't had any luck getting the balloon style to work so far.

Function FRMMAIN_WM_CREATE ( _
                           hWndForm As Dword, _      ' handle of Form
                           ByVal UserData As Long _  ' optional user defined Long value
                           ) As Long
                           

Window_AddTooltip (HWND_FRMMAIN, HWND_FRMMAIN_XPBUTTON1, "This is a tool tip.",-1,-1)


End Function

José Roca

#10
For the balloon style you need a manifest.

Edit: Sorry for this misinformation. Ballon tooltips are available since version 5.80 of COMCTL32.DLL. Therefore a manifest isn't needed.

Douglas McDonald

Here's how I used the tool tips. It seems to work well but there may be a better way to do it. I catch the mouse entering and leaving a control where I want the tool tip. For some reason I only get %WM_mousefirst and %WM_mouseleave. I do not get any other mouse messages. I set a flag so I do not get 1000's of messages.


Function MAIN_BUTTON_CUSTOM ( _
                            ControlIndex  As Long,  _  ' index in Control Array
                            hWndForm      As Dword, _  ' handle of Form
                            hWndControl   As Dword, _  ' handle of Control
                            wMsg          As Long,  _  ' type of message
                            wParam        As Dword, _  ' first message parameter
                            lParam        As Long   _  ' second message parameter
                            ) As Long
Static mFlag As Word                           
Local msg As String
Local retval As Word
Select Case wMsg
  Case %WM_mousefirst
        If  mFlag = 0  Then
            mFlag = 1
           Select Case ControlIndex
            Case 0
               msg = "Add selected program from right to action list"
            Case 1
               msg = "Remove program from action list"
            Case 2
               msg = "Refresh running programs list"
            Case 3
               msg = "Ping / get status of motion sensor"
            Case 4
               msg = "Actavate settings, motion sensor and minimize program "
            Case 5
               msg = "Exit, no futher action taken if motion sensor trips "
           End Select
           retval = Window_AddTooltip(hWndForm,hWndControl,msg,%TTS_BALLOON,-1)',0)
        End If
  Case %WM_mouseleave
        If mFlag = 1  Then
            mFlag = 0
        End If
       
End Select


End Function



Doug

Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

Robert Eaton

Doug,
When I try that, it seems to cause a small memory leak.

Bob

José Roca

The function is to create a tooltip control and associate it win  a windows and control. Creating a new tooltip control each time you want to show it or change the text will drain your resources. Update it sending the TTM_UPDATETIPTEXT message ( http://msdn.microsoft.com/en-us/library/bb760427%28VS.85%29.aspx ) or delete it first before recreate it by sending the TTM_DELTOOL message ( http://msdn.microsoft.com/en-us/library/bb760365%28VS.85%29.aspx ).

Robert Eaton

Here is an example of balloon tooltips using an include file by William Burns over on the PB forum. http://www.powerbasic.com/support/pbforums/showthread.php?t=24645