refer to http://www.codeguru.com/vb/articles/1944.shtml http://www.thescarms.com/VBasic/tooltip.asp
这样吧,我给你转篇文章吧! Option Explicit Private Declare Function DestroyWindow Lib "user32" Alias "DestroyWindow" (ByVal hwnd As Long) As Long 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 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 GetClientRect Lib "user32" Alias "GetClientRect" (ByVal hwnd As Long, lpRect As RECT) As Long Private Const WM_USER = &H400 Private Const CW_USEDEFAULT = &H80000000 Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Const TTS_NOPREFIX=&H2 Private Const TTF_TRANSPARENT=&H100 Private Const TTF_CENTERTIP=&H2 Private Const TTM_ADDTOOLA=(WM_USER+4) Private Const TTM_ACTIVE=WM_USER+1 Private Const TTM_UPDATETIPTEXTA=(WM_USER+12) Private Const TTM_SETMAXTIPWIDTH=(WM_USER+24) Private Const TTM_SETTITLE=(WM_USER+32) Private Const TTS_BALLOON=&H40 Private Const TTF_SUBCLASSA="tooltips_class32" Private Type TOOLINFO lsize as long lflags as long lhwnd as long lid as long lprect as rect hinstance as long lpstr as string lparam as long End Type Private TTTitle as string Private TTParentcontrol as object Private TTStyle as TTStyleEnum Public Enum TTStyleEnum TTStandard TTBalloon End Enum Private hToolTipHwnd as long private TI a TOOLINFOPublic Function Create() as boolean Dim lpRect as Rect DestroyWindow hTooltiphwndhtooltiphwnd=createwindowex(0, Tooltip_classa,vbnullstring,tts_balloon,cw_usedefault, cw_usedefault,cw_usedefault,cw_usedefault,TTParentControl.hwnd,0, app.hinstance,0) GetClientRect TTParentControl.hwnd,lprect With ti .flags=TTf_subclass .lhwnd=ttparentcontrol.hwnd .lid=0 .hinstance=app.hinstance .lprect=lprect end with sendmessage htooltiphwnd,ttm_addtoola,0,ti sendmessage htooltiphwnd,ttm_settitle,0,ByVal TTTitle End Function '还有一部分今晚给你,如果你有什么不明白,可以在贴自上贴出来! 我要先出去一下! 还有,我已经没分了,你能不能尽快结贴! 多谢! 以上需要夹在类模块中! 记得晚上再来!
ToolTipText="行1" & chr(13) & chr(10) & "行2"
ToolTipText="行1" & chr(13) & chr(10) & "行2"
http://www.codeguru.com/vb/articles/1944.shtml
http://www.thescarms.com/VBasic/tooltip.asp
Option Explicit
Private Declare Function DestroyWindow Lib "user32" Alias "DestroyWindow" (ByVal hwnd As Long) As Long
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 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 GetClientRect Lib "user32" Alias "GetClientRect" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Const WM_USER = &H400
Private Const CW_USEDEFAULT = &H80000000
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const TTS_NOPREFIX=&H2
Private Const TTF_TRANSPARENT=&H100
Private Const TTF_CENTERTIP=&H2
Private Const TTM_ADDTOOLA=(WM_USER+4)
Private Const TTM_ACTIVE=WM_USER+1
Private Const TTM_UPDATETIPTEXTA=(WM_USER+12)
Private Const TTM_SETMAXTIPWIDTH=(WM_USER+24)
Private Const TTM_SETTITLE=(WM_USER+32)
Private Const TTS_BALLOON=&H40
Private Const TTF_SUBCLASSA="tooltips_class32"
Private Type TOOLINFO
lsize as long
lflags as long
lhwnd as long
lid as long
lprect as rect
hinstance as long
lpstr as string
lparam as long
End Type
Private TTTitle as string
Private TTParentcontrol as object
Private TTStyle as TTStyleEnum
Public Enum TTStyleEnum
TTStandard
TTBalloon
End Enum
Private hToolTipHwnd as long
private TI a TOOLINFOPublic Function Create() as boolean
Dim lpRect as Rect
DestroyWindow hTooltiphwndhtooltiphwnd=createwindowex(0,
Tooltip_classa,vbnullstring,tts_balloon,cw_usedefault,
cw_usedefault,cw_usedefault,cw_usedefault,TTParentControl.hwnd,0,
app.hinstance,0)
GetClientRect TTParentControl.hwnd,lprect
With ti
.flags=TTf_subclass
.lhwnd=ttparentcontrol.hwnd
.lid=0
.hinstance=app.hinstance
.lprect=lprect
end with
sendmessage htooltiphwnd,ttm_addtoola,0,ti
sendmessage htooltiphwnd,ttm_settitle,0,ByVal TTTitle
End Function
'还有一部分今晚给你,如果你有什么不明白,可以在贴自上贴出来!
我要先出去一下!
还有,我已经没分了,你能不能尽快结贴!
多谢!
以上需要夹在类模块中!
记得晚上再来!