Создай класс и в нем пропиши вот это:
Option Explicit
' ToolTip Styles
Private Const TTS_ALWAYSTIP As Byte = &H1
Private Const TTS_NOPREFIX As Byte = &H2
Private Const TTS_BALLOON As Byte = &H40 ' comctl32.dll v5.8 require
Private Const CW_USEDEFAULT As Long = &H80000000
Private Const WS_POPUP As Long = &H80000000
' ToolTip Messages
Private Const TTM_SETDELAYTIME = (WM_USER + 3)
Private Const TTM_ADDTOOL = (WM_USER + 4)
Private Const TTM_DELTOOL = (WM_USER + 5)
Private Const TTM_NEWTOOLRECT = (WM_USER + 6)
Private Const TTM_GETTOOLINFO = (WM_USER + 8)
Private Const TTM_SETTIPBKCOLOR = (WM_USER + 19)
Private Const TTM_SETTIPTEXTCOLOR = (WM_USER + 20)
Private Const TTM_SETMAXTIPWIDTH = (WM_USER + 24)
Private Const TTDT_AUTOPOP As Byte = 2
Private Const TTDT_INITIAL As Byte = 3
Private Const TTF_IDISHWND As Byte = &H1
Private Const TTF_CENTERTIP As Byte = &H2
Private Const TTF_SUBCLASS As Byte = &H10
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 Const GWL_STYLE As Integer = (-16)
Private hTT As Long
Private Const ICC_BAR_CLASSES As Byte = &H4 'toolbar, statusbar, trackbar, tooltips
Private Declare Sub InitCommonControls Lib "comctl32.dll" ()
Private Declare Function InitCommonControlsEx Lib "comctl32.dll" (lpInitCtrls As tagInitCommonControlsEx) As Boolean
Private Type tagInitCommonControlsEx
dwSize As Long ' size of this structure
dwICC As Long ' flags indicating which classes to be initialized.
End Type
Public Sub SetToolTipObj(ByVal objHwnd As Long, ByRef bDel As Boolean, Optional ByRef sTipText As String, Optional ByRef bCenter As Boolean = True)
Dim TI As TOOLINFO
With TI
.cbSize = Len(TI)
.hwnd = objHwnd
.uId = objHwnd
If bDel Then
If hTT Then
SendMessage hTT, TTM_DELTOOL, 0, TI
DestroyWindow (hTT)
hTT = 0
End If
Else
InitComctl32
hTT = CreateWindowEx(0, "tooltips_class32", 0&, TTS_BALLOON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0&, 0&, App.hInstance, 0&
.uFlags = TTF_IDISHWND Or TTF_SUBCLASS
If bCenter Then .uFlags = .uFlags Or TTF_CENTERTIP
.lpszText = sTipText
SendMessage hTT, TTM_ADDTOOL, 0, TI
End If
End With
End Sub
Private Sub Class_Terminate()
If hTT Then DestroyWindow (hTT)
End Sub
Private Sub InitComctl32()
Dim icc As tagInitCommonControlsEx
On Error GoTo Err_OldVersion
icc.dwSize = Len(icc)
icc.dwICC = ICC_BAR_CLASSES
InitCommonControlsEx icc
On Error GoTo 0
init = True
Exit Sub
Err_OldVersion:
InitCommonControls
init = True
End Sub
Для создания многострочного тултипа, делаешь так:
Dim TTip As cToolTip
Set TTip = New cToolTip
SetToolTipObj UserControl.hwnd, False, "Привет!" & vbCRLF & "Как делища?", False
Сан Саныч
mailto:apexsun@narod.ru -=•=- http://apexsun.narod.ru -=•=- ICQ:273825121
> Жизнь похожа на лестницу в курятнике - короткая и вся в дерьме.
Ответить
|