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
Last edited by luca90; May 14th, 2018 at 12:19 AM.
Reason: changed OS i'm on vba for excel, sorry
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
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
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
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