Results 1 to 12 of 12

Thread: CTOOLTIP Class DONT Work on label and on commandbutton

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    CTOOLTIP Class DONT Work on label and on commandbutton

    Why?
    In thiS case dont work on label and on command button...

    Code:
    Option Explicit
    
    Dim TT As CTooltip
    Dim m_bInLable As Boolean
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    'Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    'Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        
        If Not m_bInLable Then
            m_bInLable = True
            TT.Title = "Multiline tooltip"
            TT.TipText = Me.CommandButton1.Caption
            TT.Create Me.hwnd
        End If
    
    End Sub
    Private Sub Form_Activate()
    
        Me.Text1.SetFocus
    
    End Sub
    Private Sub UserForm_Initialize()
    
        Set TT = New CTooltip
        TT.Style = TTBalloon
        TT.Icon = TTIconInfo
    
    End Sub
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
        If m_bInLable Then
            m_bInLable = False
            TT.Destroy
        End If
    
    End Sub
    Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    
        If Not m_bInLable Then
            m_bInLable = True
            TT.Title = "Multiline tooltip"
            TT.TipText = "Label1"
            TT.Create Me.hwnd
        End If
    
    End Sub
    for all controll have error in:TT.Create Me.hwnd
    Attached Files Attached Files
    Last edited by luca90; May 14th, 2018 at 12:19 AM. Reason: changed OS i'm on vba for excel, sorry

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: CTOOLTIP Class Work only on label and not on commandbutton

    You are going to have to give us more info. How are you using it? Need to see some code
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: CTOOLTIP Class Work only on label and not on commandbutton

    Quote Originally Posted by LaVolpe View Post
    You are going to have to give us more info. How are you using it? Need to see some code
    sorry bro but really i'm on vba for excel.

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: CTOOLTIP Class Work only on label and not on commandbutton

    Quote Originally Posted by luca90 View Post
    sorry bro but really i'm on vba for excel.
    If that's the case then is there some reason that you did not post it in the office section where VBA questions should go?

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: CTOOLTIP Class Work only on label and not on commandbutton

    Quote Originally Posted by DataMiser View Post
    If that's the case then is there some reason that you did not post it in the office section where VBA questions should go?
    simply distraction, sorry.

    I ask an administrator to move in the right section.
    Tks
    Last edited by luca90; May 14th, 2018 at 03:21 PM.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: CTOOLTIP Class DONT Work on label and on commandbutton

    Thread Moved From VB6 Forum to Office Dev Forum
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,417

    Re: CTOOLTIP Class DONT Work on label and on commandbutton

    Eh? DO i remember correctly that the UserForms in Office/VBA don't have a hWnd-Property?
    Use FindWindow/FindWindowEx to get the handle
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: CTOOLTIP Class DONT Work on label and on commandbutton

    Quote Originally Posted by Zvoni View Post
    Eh? DO i remember correctly that the UserForms in Office/VBA don't have a hWnd-Property?
    Use FindWindow/FindWindowEx to get the handle
    Correct
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: CTOOLTIP Class DONT Work on label and on commandbutton

    Quote Originally Posted by Zvoni View Post
    Eh? DO i remember correctly that the UserForms in Office/VBA don't have a hWnd-Property?
    Use FindWindow/FindWindowEx to get the handle
    FindWindow/FindWindowEx??¿
    Can you explicit on my code?
    Tks

  10. #10
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,417

    Re: CTOOLTIP Class DONT Work on label and on commandbutton

    https://msdn.microsoft.com/de-de/lib...(v=vs.85).aspx

    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: CTOOLTIP Class DONT Work on label and on commandbutton

    Quote Originally Posted by Zvoni View Post
    https://msdn.microsoft.com/de-de/lib...(v=vs.85).aspx

    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    tks for code and sorry for delay...

    based your code, what should i change here: TT.Create Me.hwnd? now..

  12. #12
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: CTOOLTIP Class DONT Work on label and on commandbutton

    i modified your attachment and was able to fix all the code issues, get an hwnd and hinstance as required, the tooltip window was created and destroyed where applicable and ran without error, but it did not display above the userform, so some other feature or code must be required for it to work with vba, you may need to muck around with setwindowlong or settopmost

    there is a simple work around here https://www.mrexcel.com/forum/excel-...ml#post1037341 see if it suits your needs
    Last edited by westconn1; May 27th, 2018 at 01:18 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width