PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Rudolf Fürstauer on July 04, 2008, 03:19:24 AM

Title: Problem Tooltip
Post by: Rudolf Fürstauer on July 04, 2008, 03:19:24 AM
Hi @all!

I use in FF and PB the same function for displaying the tooltips,
but in FF i get the tooltip only one time.

After pressing the control or TTM_SETDELAYTIME is over,
the tooltip is not showing again.

PB-Code:
#PBForms Created V1.51
#Compile Exe
#Dim All
'----------------------------------
#PBForms Begin Includes

#Include "WIN32API.INC"
#Include "commctrl.inc"
#Include "PBforms.inc"
#PBForms End Includes
'----------------------------------
#PBForms Begin Constants
%IDD_Dialog =  101
%IDC_BUTTON = 1002
#PBForms End Constants
'----------------------------------
Declare CallBack Function ShowDialog1Proc()
Declare Function ShowDialog1(ByVal hParent As Dword) As Long
Declare Sub ToolTip_SET(ByVal hWND As Dword, ByVal hCtrl As Dword , ByVal sToolTip As String)

#PBForms Declarations

Function PBMain()
    PBFormsInitComCtls (%ICC_WIN95_CLASSES Or %ICC_DATE_CLASSES Or %ICC_INTERNET_CLASSES)

    ShowDialog1 %HWND_DESKTOP
End Function
'----------------------------------
CallBack Function ShowDialog1Proc()
    Select Case As Long CbMsg
        Case %WM_INITDIALOG
        Case %WM_NCACTIVATE
            Static hWndSaveFocus As Dword
            If IsFalse CbWParam Then
                hWndSaveFocus = GetFocus()
            ElseIf hWndSaveFocus Then
                SetFocus(hWndSaveFocus)
                hWndSaveFocus = 0
            End If
        Case %WM_COMMAND
            Select Case As Long CbCtl
                 Case %IDC_BUTTON

            End Select
    End Select
End Function
'----------------------------------
'----------------------------------
Function ShowDialog1(ByVal hParent As Dword) As Long
    Local lRslt As Long

#PBForms Begin Dialog %IDD_Dialog->->
    Local hDlg  As Dword

    Dialog New hParent, "Tool Tips", 78, 74, 154, 60, %WS_POPUP Or _
        %WS_DLGFRAME Or %WS_CAPTION Or %WS_SYSMENU Or %WS_CLIPSIBLINGS Or _
        %WS_VISIBLE Or %DS_CENTER Or %DS_3DLOOK Or %DS_NOFAILCREATE Or _
        %DS_SETFONT, %WS_EX_CONTROLPARENT Or %WS_EX_LEFT Or _
        %WS_EX_LTRREADING Or %WS_EX_RIGHTSCROLLBAR, To hDlg
    Control Add Button, hDlg, %IDC_BUTTON, "Button1", 35, 15, 70, 20
#PBForms End Dialog



    ToolTip_SET(hDlg, 0,"") 'init ToolTip
    ToolTip_SET(hDlg, GetDlgItem(hDlg, %IDC_BUTTON),"I am a Button" & $Crlf & "and i show the TIP")


    Dialog Show Modal hDlg, Call ShowDialog1Proc To lRslt

#PBForms Begin CleanUp %IDD_Dialog
#PBForms End CleanUp

    Function = lRslt
End Function
'----------------------------------



Sub ToolTip_SET(ByVal hWND As Dword, ByVal hCtrl As Dword , ByVal sToolTip As String)
    Local szTText   As Asciiz * 50
    Static ti        As TOOLINFO
    Static hToolTip As Long


    If hToolTip = 0 Then

        hToolTip = CreateWindowEx(ByVal 0, "tooltips_class32", "", %TTS_ALWAYSTIP, 0, 0, 0, 0,  ByVal hWND, ByVal 0&, GetModuleHandle(ByVal %NULL), ByVal 0&)
        Dialog Send hToolTip, %TTM_SETMAXTIPWIDTH, 0, 200
        SendMessage(hToolTip, %TTM_SETTIPTEXTCOLOR, RGB(0,0,0), 0)    'Schriftfarbe
        SendMessage(hToolTip, %TTM_SETTIPBKCOLOR, RGB(255,255,210), 0)  'Hintergrundfarbe
        Dialog Send hToolTip, %TTM_SETDELAYTIME, %TTDT_AUTOPOP, 2000

        ti.cbSize   = SizeOf(ti)
        ti.uFlags   = %TTF_SUBCLASS Or %TTF_IDISHWND
        ti.hWnd     = hWND

    Else
        szTText = sToolTip
        ti.uId      = hCtrl
        ti.lpszText = VarPtr(szTText)
        SendMessage hToolTip, %TTM_ADDTOOL, 0, ByVal VarPtr(ti)
    End If

End Sub


FF-Code:
#FireFly_Form#  Version=2.86
Locked=0
MenuExists=0
RebarExists=0
ToolbarExists=0
StatusBarExists=0
ClientOffset=0
ControlCount=1

[ControlType] Form | PropertyCount=20
name=Form1
classstyles=CS_VREDRAW, CS_HREDRAW, CS_DBLCLKS
windowstyles=WS_POPUP, WS_CAPTION, WS_SYSMENU, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, WS_VISIBLE|WS_EX_WINDOWEDGE, WS_EX_CONTROLPARENT, WS_EX_LEFT, WS_EX_LTRREADING, WS_EX_RIGHTSCROLLBAR
backbitmap=
backbitmapmode=0 - Tiled
backcolor=SYS,15
caption=Form1
export=False
height=121
icon=
left=0
mdichild=False
startupposition=1 - Centered
tabcontrolchild=False
tabcontrolchildautosize=False
tag=
tag2=
top=0
width=171
windowstate=0 - Normal

[ControlType] CommandButton | PropertyCount=12 | zorder=1 | tabindex=2 |
name=Command1
windowstyles=WS_CHILD, WS_VISIBLE, WS_TABSTOP, BS_TEXT, BS_PUSHBUTTON, BS_NOTIFY, BS_CENTER, BS_VCENTER|WS_EX_LEFT, WS_EX_LTRREADING
cancel=False
caption=Command1
controlindex=0
font=Tahoma,-13,0,0,0,400,0,0,0,0,3,2,1,34
height=32
left=24
tag=
tag2=
top=16
width=100

[AllCode]

'------------------------------------------------------------------------------------------------------------------------
Function FORM1_WM_CREATE (hWndForm As Dword, ByVal UserData As Long) As Long

      SetMultiLineToolT(hWndForm, 0, "")
      SetMultiLineToolT(hWndForm, HWND_FORM1_COMMAND1, "I show the ToolTip only one time!")

End Function



'------------------------------------------------------------------------------------------------------------------------
'
'------------------------------------------------------------------------------------------------------------------------
Sub SetMultiLineToolT (ByVal hWND As Dword, ByVal hCtrl As Dword , ByVal sToolTip As String)
    Local szTText       As Asciiz * 50
    Static ti           As TOOLINFO
    Static hToolTip     As Long
'------------------------------------------

    If hToolTip = 0 Then

        hToolTip = CreateWindowEx(ByVal 0, "tooltips_class32", "", %TTS_ALWAYSTIP, 0, 0, 0, 0,  ByVal hWND, ByVal 0&, GetModuleHandle(ByVal %Null), ByVal 0&)
        Dialog Send hToolTip, %TTM_SETMAXTIPWIDTH, 0, 200
        SendMessage(hToolTip, %TTM_SETTIPTEXTCOLOR, RGB(0,0,0), 0)    'Schriftfarbe
        SendMessage(hToolTip, %TTM_SETTIPBKCOLOR, RGB(255,255,210), 0)  'Hintergrundfarbe
        Dialog Send hToolTip, %TTM_SETDELAYTIME, %TTDT_AUTOPOP, 2000

        ti.cbSize   = SizeOf(ti)
        ti.uFlags   = %TTF_SUBCLASS Or %TTF_IDISHWND
        ti.hWnd     = hWND

    Else
        szTText = sToolTip
        ti.uId      = hCtrl
        ti.lpszText = VarPtr(szTText)
        SendMessage hToolTip, %TTM_ADDTOOL, 0, ByVal VarPtr(ti)
    End If

End Sub




To have anyone this problem too?


Fürstauer Rudolf
Title: Re: Problem Tooltip
Post by: TechSupport on July 04, 2008, 07:13:45 PM
I copied your code into a blank project and it does *not* show the problem. It always displays a tooltip whenever I mouse over the command button. If I press the button the tooltip will still show. I don't know why it would not work for you.

Question: Why are you using Dialog Send ?

        Dialog Send hToolTip, %TTM_SETDELAYTIME, %TTDT_AUTOPOP, 2000


Probably no big deal but maybe a simple SendMessage should be used?
Title: Re: Problem Tooltip
Post by: Rudolf Fürstauer on July 06, 2008, 03:39:31 AM
You are right, it's better to use SendMessage, but there is no change.  ???
I will try it on a other computer.

Thank you
Title: Re: Problem Tooltip
Post by: Roger Garstang on July 28, 2008, 10:21:17 AM
I posted some tooltip code over at PB that should help.  Find the most recent though as I had some byval/byref issues on optional params early on.  My code is the most complete for functionality too than the others posted.