|
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type TOOLINFO
cbSize As Long
uFlags As Long
hwnd As Long
uId As Long
cRect As RECT
hinst As Long
lpszText As String
End Type
Private Declare Function CreateWindowEx Lib "user32" Alias _
"CreateWindowExA" (ByVal dwExStyle As Long, _
ByVal lpClassName As String, ByVal lpWindowName As String, _
ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hWndParent As Long, ByVal hMenu As Long, _
ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Sub InitCommonControls Lib "comctl32.dll" ()
Private Declare Function SendMessage Lib "user32.dll" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Private Const WM_USER = &H400
Private Const TTM_ADDTOOL = WM_USER + 4
Private Const TTM_SETMAXTIPWIDTH = WM_USER + 24
Private Const TTF_IDISHWND = &H1
Private Const TTF_SUBCLASS = &H10
Private hToolTip As Long
Private Sub Form_Load()
InitCommonControls
hToolTip = CreateWindowEx( _
0, "tooltips_class32", "", 0, 0, 0, 0, 0, 0, 0, 0, 0)
SendMessage hToolTip, TTM_SETMAXTIPWIDTH, 0, 300
SetMultiLineToolTip Command1.hwnd, _
"Das ist ein" & vbNewLine & "Test !"
SetMultiLineToolTip Command2.hwnd, "Bei Klick auf diesen" & _
vbNewLine & "Button wird das" & vbNewLine & _
"Programm beendet ;-)"
End Sub
Private Sub Command1_Click()
SetMultiLineToolTip Text1.hwnd, Text1.Text
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, _
UnloadMode As Integer)
DestroyWindow hToolTip
End Sub
Private Sub SetMultiLineToolTip(ByVal hwnd As Long, _
ByVal sToolTip As String)
Dim udtTool As TOOLINFO
With udtTool
.cbSize = Len(udtTool)
.hwnd = hwnd
.uFlags = TTF_IDISHWND Or TTF_SUBCLASS
.uId = hwnd
.lpszText = sToolTip
End With
SendMessage hToolTip, TTM_ADDTOOL, 0, udtTool
End Sub
|
|