VB一个可以改变箭头方向的气泡提示

这篇博客介绍了一个VB类——clsTip,用于创建能够改变箭头方向的气泡提示。通过类代码的实现,开发者可以为应用程序添加具有动态箭头功能的提示窗口,提升用户体验。
摘要由CSDN通过智能技术生成
       用VB实现一个气泡提示并不难,即使是实现在任意地方显示的气泡提示。难的是,如果是采用TTF_TRACK方式允许在任意地方显示时,气泡的箭头总是向上,而且还不能自动消失。为此,我写了一个增强的气泡提示类,希望对有此需要的朋友一些参考。

一、新建一个类,类名为clsTip,类代码如下:

代码如下:

Option Explicit
'* ******************************************** *
'*  模块名称:clsTip.cls
'*  功能:一个可以改变箭头方向的气泡提示类
'*  作者:lyserver
'*  联系方式:http://blog.csdn.net/lyserver
'* ******************************************** *
Private Type TOOLINFO
    cbSize As Long
    dwFlags As Long
    hwnd As Long
    dwID As Long
    rtRect(3) As Long
    hInst As Long
    lpszText As String
    lParam  As Long
End Type
Private Declare Sub InitCommonControls Lib " comctl32" ()
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 Const TOOLTIPS_CLASS As String = " tooltips_class32"
Private Declare Function DestroyWindow Lib " user32" ( ByVal hwnd As Long) As Long
' ToolTips Style
Public Enum StyleConstants
    TTS_COMMON = &H0
    TTS_BALLOON = &H40
End Enum
Private Const TTS_ALWAYSTIP As Long = &H1
Private Const TTS_NOANIMATE As Long = &H10
Private Const TTS_NOFADE As Long = &H20
Private Const TTS_NOPREFIX As Long = &H2
Private Const TTDT_AUTOPOP = 2
Private Const TTDT_INITIAL = 3
' ToolTips Flags
Private Const TTF_ABSOLUTE As Long = &H80
Private Const TTF_CENTERTIP As Long = &H2
Private Const TTF_DI_SETITEM As Long = &H8000
Private Const TTF_IDISHWND As Long = &H1
Private Const TTF_RTLREADING As Long = &H4
Private Const TTF_SUBCLASS As Long = &H10
Private Const TTF_TRACK As Long = &H20
Private Const TTF_TRANSPARENT As Long = &H100
' ToolTips Icon
Public Enum IconConstants
    TTI_NONE = 0
    TTI_INFO = 1
    TTI_WARNING = 2
    TTI_ERROR = 3
End Enum
'ToolTips Arrow Orientation
Public Enum OrientationConstants
    Down = 0
    Up = 1
End Enum
' ToolTips Message
Private Const WM_USER As Long = &H400
Private Const TTM_SETDELAYTIME As Long = (WM_USER + 3)
Private Const TTM_ADDTOOL As Long = (WM_USER + 4)
Private
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值