⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clstooltip.cls

📁 一款Grid表格控件源代码,非常棒.不下你一定会后悔
💻 CLS
📖 第 1 页 / 共 3 页
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsToolTip"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Implements GXISubclass

Private Const BM_TRANSPARENT                    As Long = &H1

Private Const DT_TOP                            As Long = &H0&
Private Const DT_LEFT                           As Long = &H0&
Private Const DT_CENTER                         As Long = &H1&
Private Const DT_RIGHT                          As Long = &H2&
Private Const DT_VCENTER                        As Long = &H4&
Private Const DT_BOTTOM                         As Long = &H8&
Private Const DT_WORDBREAK                      As Long = &H10&
Private Const DT_SINGLELINE                     As Long = &H20&
Private Const DT_EXPANDTABS                     As Long = &H40&
Private Const DT_TABSTOP                        As Long = &H80&
Private Const DT_NOCLIP                         As Long = &H100&
Private Const DT_EXTERNALLEADING                As Long = &H200&
Private Const DT_CALCRECT                       As Long = &H400&
Private Const DT_NOPREFIX                       As Long = &H800&
Private Const DT_INTERNAL                       As Long = &H1000&
Private Const DT_EDITCONTROL                    As Long = &H2000&
Private Const DT_PATH_ELLIPSIS                  As Long = &H4000&
Private Const DT_END_ELLIPSIS                   As Long = &H8000&
Private Const DT_MODIFYSTRING                   As Long = &H10000
Private Const DT_RTLREADING                     As Long = &H20000
Private Const DT_WORD_ELLIPSIS                  As Long = &H40000

Private Const FW_NORMAL                         As Long = 400
Private Const FW_BOLD                           As Long = 700

Private Const ILD_NORMAL                        As Long = &H0
Private Const ILD_TRANSPARENT                   As Long = &H1
Private Const ILD_BLEND25                       As Long = &H2
Private Const ILD_FOCUS                         As Long = &H4
Private Const ILD_SELECTED                      As Long = &H8

Private Const IMAGE_BITMAP                      As Long = 0
Private Const IMAGE_ICON                        As Long = 1
Private Const IMAGE_CURSOR                      As Long = 2
Private Const IMAGE_ENHMETAFILE                 As Long = 3

Private Const LF_DEFAULT_QUALITY                As Long = 0
Private Const LF_DRAFT_QUALITY                  As Long = 1
Private Const LF_PROOF_QUALITY                  As Long = 2
Private Const LF_NONANTIALIASED_QUALITY         As Long = 3
Private Const LF_ANTIALIASED_QUALITY            As Long = 4
Private Const LF_CLEARTYPE_QUALITY              As Long = 5

Private Const LOGPIXELSY                        As Long = 90

Private Const SS_LEFT                           As Long = &H0
Private Const SS_CENTER                         As Long = &H1
Private Const SS_RIGHT                          As Long = &H2
Private Const SS_ICON                           As Long = &H3
Private Const SS_BLACKRECT                      As Long = &H4
Private Const SS_GRAYRECT                       As Long = &H5
Private Const SS_WHITERECT                      As Long = &H6
Private Const SS_BLACKFRAME                     As Long = &H7
Private Const SS_GRAYFRAME                      As Long = &H8
Private Const SS_WHITEFRAME                     As Long = &H9
Private Const SS_USERITEM                       As Long = &HA
Private Const SS_SIMPLE                         As Long = &HB
Private Const SS_LEFTNOWORDWRAP                 As Long = &HC
Private Const SS_OWNERDRAW                      As Long = &HD
Private Const SS_BITMAP                         As Long = &HE
Private Const SS_ENHMETAFILE                    As Long = &HF
Private Const SS_ETCHEDHORZ                     As Long = &H10
Private Const SS_ETCHEDVERT                     As Long = &H11
Private Const SS_ETCHEDFRAME                    As Long = &H12
Private Const SS_TYPEMASK                       As Long = &H1F
Private Const SS_NOPREFIX                       As Long = &H80
Private Const SS_NOTIFY                         As Long = &H100
Private Const SS_CENTERIMAGE                    As Long = &H200
Private Const SS_RIGHTJUST                      As Long = &H400
Private Const SS_REALSIZEIMAGE                  As Long = &H800
Private Const SS_SUNKEN                         As Long = &H1000
Private Const SS_ENDELLIPSIS                    As Long = &H4000
Private Const SS_PATHELLIPSIS                   As Long = &H8000
Private Const SS_WORDELLIPSIS                   As Long = &HC000
Private Const SS_ELLIPSISMASK                   As Long = &HC000

Private Const STN_CLICKED                       As Long = &H0
Private Const STN_DBLCLK                        As Long = &H1
Private Const STN_ENABLE                        As Long = &H2
Private Const STN_DISABLE                       As Long = &H3
Private Const STM_SETICON                       As Long = &H170
Private Const STM_GETICON                       As Long = &H171
Private Const STM_SETIMAGE                      As Long = &H172
Private Const STM_GETIMAGE                      As Long = &H173

Private Const SWP_NOSIZE                        As Long = &H1
Private Const SWP_NOZORDER                      As Long = &H4
Private Const SWP_SHOWWINDOW                    As Long = &H40
Private Const SWP_FRAMECHANGED                  As Long = &H20
Private Const SWP_NOACTIVATE                    As Long = &H10
Private Const SWP_NOMOVE                        As Long = &H2

Private Const SW_HIDE                           As Long = &H0
Private Const SW_NORMAL                         As Long = &H1

Private Const WM_TIMER                          As Long = &H113&

Private Const WS_OVERLAPPED                     As Long = &H0
Private Const WS_POPUP                          As Long = &H80000000
Private Const WS_CHILD                          As Long = &H40000000
Private Const WS_MINIMIZE                       As Long = &H20000000
Private Const WS_VISIBLE                        As Long = &H10000000
Private Const WS_DISABLED                       As Long = &H8000000
Private Const WS_CLIPSIBLINGS                   As Long = &H4000000
Private Const WS_CLIPCHILDREN                   As Long = &H2000000
Private Const WS_MAXIMIZE                       As Long = &H1000000
Private Const WS_CAPTION                        As Long = &HC00000
Private Const WS_BORDER                         As Long = &H800000
Private Const WS_DLGFRAME                       As Long = &H400000
Private Const WS_VSCROLL                        As Long = &H200000
Private Const WS_HSCROLL                        As Long = &H100000
Private Const WS_SYSMENU                        As Long = &H80000
Private Const WS_THICKFRAME                     As Long = &H40000
Private Const WS_GROUP                          As Long = &H20000
Private Const WS_TABSTOP                        As Long = &H10000
Private Const WS_MINIMIZEBOX                    As Long = &H20000
Private Const WS_MAXIMIZEBOX                    As Long = &H10000
Private Const WS_POPUPWINDOW                    As Long = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)
Private Const WS_OVERLAPPEDWINDOW               As Long = _
(WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)
Private Const WS_TILED                          As Long = WS_OVERLAPPED
Private Const WS_ICONIC                         As Long = WS_MINIMIZE
Private Const WS_SIZEBOX                        As Long = WS_THICKFRAME
Private Const WS_TILEDWINDOW                    As Long = WS_OVERLAPPEDWINDOW

Private Const WS_EX_LEFT                        As Long = &H0
Private Const WS_EX_LTRREADING                  As Long = &H0
Private Const WS_EX_RIGHTSCROLLBAR              As Long = &H0
Private Const WS_EX_DLGMODALFRAME               As Long = &H1
Private Const WS_EX_NOPARENTNOTIFY              As Long = &H4
Private Const WS_EX_TOPMOST                     As Long = &H8
Private Const WS_EX_ACCEPTFILES                 As Long = &H10
Private Const WS_EX_TRANSPARENT                 As Long = &H20
Private Const WS_EX_MDICHILD                    As Long = &H40
Private Const WS_EX_TOOLWINDOW                  As Long = &H80
Private Const WS_EX_WINDOWEDGE                  As Long = &H100
Private Const WS_EX_CLIENTEDGE                  As Long = &H200
Private Const WS_EX_CONTEXTHELP                 As Long = &H400
Private Const WS_EX_RIGHT                       As Long = &H1000
Private Const WS_EX_RTLREADING                  As Long = &H2000
Private Const WS_EX_LEFTSCROLLBAR               As Long = &H4000
Private Const WS_EX_CONTROLPARENT               As Long = &H10000
Private Const WS_EX_STATICEDGE                  As Long = &H20000
Private Const WS_EX_APPWINDOW                   As Long = &H40000


Private Enum TRACKMOUSEEVENT_FLAGS
    TME_HOVER = &H1&
    TME_LEAVE = &H2&
    TME_QUERY = &H40000000
    TME_CANCEL = &H80000000
End Enum


Public Enum ETPToolTipPosition
    RightBottom = 0&
    RightCenter = 1&
    RightTop = 2&
    LeftBottom = 3&
    LeftCenter = 4&
    LeftTop = 5&
End Enum

Private Type RECT
    Left                                        As Long
    Top                                         As Long
    Right                                       As Long
    bottom                                      As Long
End Type

Private Type POINTAPI
    x                                           As Long
    y                                           As Long
End Type

Private Type TRACKMOUSEEVENT_STRUCT
    cbSize                                      As Long
    dwFlags                                     As TRACKMOUSEEVENT_FLAGS
    hwndTrack                                   As Long
    dwHoverTime                                 As Long
End Type

Private Type VERSIONINFO
    dwOSVersionInfoSize                         As Long
    dwMajorVersion                              As Long
    dwMinorVersion                              As Long
    dwBuildNumber                               As Long
    dwPlatformId                                As Long
    szCSDVersion                                As String * 128
End Type

Private Type LOGFONT
    lfHeight                                    As Long
    lfWidth                                     As Long
    lfEscapement                                As Long
    lfOrientation                               As Long
    lfWeight                                    As Long
    lfItalic                                    As Byte
    lfUnderline                                 As Byte
    lfStrikeOut                                 As Byte
    lfCharSet                                   As Byte
    lfOutPrecision                              As Byte
    lfClipPrecision                             As Byte
    lfQuality                                   As Byte
    lfPitchAndFamily                            As Byte
    lfFaceName(32)                              As Byte
End Type


Private Declare Function GetModuleHandleA Lib "kernel32" (ByVal lpModuleName As String) As Long

Private Declare Function GetModuleHandleW Lib "kernel32" (ByVal lpModuleName As String) As Long

Private Declare Function LoadLibraryA Lib "kernel32" (ByVal lpLibFileName As String) As Long

Private Declare Function LoadLibraryW Lib "kernel32" (ByVal lpLibFileName As String) As Long

Private Declare Function TrackMouseEvent Lib "USER32" (lpEventTrack As TRACKMOUSEEVENT_STRUCT) As Long

Private Declare Function TrackMouseEventComCtl Lib "COMCTL32" Alias "_TrackMouseEvent" (lpEventTrack As TRACKMOUSEEVENT_STRUCT) As Long

Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, _
                                                        ByVal lpProcName As Long) As Long

Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersion As VERSIONINFO) As Long

Private Declare Function CreateWindowExA Lib "USER32" (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 CreateWindowExW Lib "USER32" (ByVal dwExStyle As Long, _
                                                       ByVal lpClassName As Long, _
                                                       ByVal lpWindowName As Long, _
                                                       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 Function ReleaseDC Lib "USER32" (ByVal hWnd As Long, _
                                                 ByVal hdc As Long) As Long

Private Declare Function GetDC Lib "user32.dll" (ByVal hWnd As Long) As Long

Private Declare Sub SetWindowPos Lib "USER32" (ByVal hWnd As Long, _
                                               ByVal hWndInsertAfter As Long, _
                                               ByVal x As Long, _
                                               ByVal y As Long, _
                                               ByVal cx As Long, _
                                               ByVal cy As Long, _
                                               ByVal wFlags As Long)

Private Declare Function GetParent Lib "USER32" (ByVal hWnd As Long) As Long

Private Declare Function GetDesktopWindow Lib "USER32" () As Long

Private Declare Function ScreenToClient Lib "USER32" (ByVal hWnd As Long, _
                                                      lpPoint As POINTAPI) As Long

Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, _
                                                   ByVal hObject As Long) As Long

Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long

Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long

Private Declare Function GetCursorPos Lib "USER32" (lpPoint As POINTAPI) As Long

Private Declare Function GetSysColor Lib "USER32" (ByVal nIndex As Long) As Long

Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long

Private Declare Function FrameRect Lib "USER32" (ByVal hdc As Long, _
                                                 lpRect As RECT, _
                                                 ByVal hBrush As Long) As Long

Private Declare Function CopyRect Lib "USER32" (lpDestRect As RECT, _
                                                lpSourceRect As RECT) As Long

Private Declare Function DrawTextA Lib "USER32" (ByVal hdc As Long, _
                                                 ByVal lpStr As String, _
                                                 ByVal nCount As Long, _
                                                 lpRect As RECT, _
                                                 ByVal wFormat As Long) As Long

Private Declare Function DrawTextW Lib "USER32" (ByVal hdc As Long, _
                                                 ByVal lpStr As Long, _
                                                 ByVal nCount As Long, _
                                                 lpRect As RECT, _
                                                 ByVal wFormat As Long) As Long

Private Declare Function FillRect Lib "USER32" (ByVal hdc As Long, _
                                                lpRect As RECT, _
                                                ByVal hBrush As Long) As Long

Private Declare Function ImageList_GetIconSize Lib "COMCTL32" (ByVal himl As Long, _
                                                               cx As Long, _
                                                               cy As Long) As Long

Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, _
                                                ByVal nBkMode As Long) As Long

Private Declare Function GetClientRect Lib "USER32" (ByVal hWnd As Long, _
                                                     lpRect As RECT) As Long

Private Declare Function CreateDc Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, _
                                                                 lpDeviceName As Any, _
                                                                 lpOutput As Any, _
                                                                 lpInitData As Any) As Long

Private Declare Function CreateFontIndirectA Lib "gdi32" (lpLogFont As LOGFONT) As Long

Private Declare Function CreateFontIndirectW Lib "gdi32" (lpLogFont As LOGFONT) As Long

Private Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, _
                                                ByVal nNumerator As Long, _
                                                ByVal nDenominator As Long) As Long

Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, _
                                                    ByVal nIndex As Long) As Long

Private Declare Function ImageList_Draw Lib "comctl32.dll" (ByVal himl As Long, _
                                                            ByVal i As Long, _
                                                            ByVal hdcDst As Long, _
                                                            ByVal x As Long, _
                                                            ByVal y As Long, _
                                                            ByVal fStyle As Long) As Long

Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, _
                                                ByVal nWidth As Long, _
                                                ByVal crColor As Long) As Long

Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, _
                                               ByVal x As Long, _
                                               ByVal y As Long, _
                                               lpPoint As POINTAPI) As Long

Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, _
                                             ByVal x As Long, _
                                             ByVal y As Long) As Long

Private Declare Function SetTimer Lib "USER32" (ByVal hWnd As Long, _
                                                ByVal nIDEvent As Long, _
                                                ByVal uElapse As Long, _
                                                ByVal lpTimerFunc As Long) As Long

Private Declare Function KillTimer Lib "USER32" (ByVal hWnd As Long, _
                                                 ByVal nIDEvent As Long) As Long

Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, _
                                                   ByVal crColor As Long) As Long

Private Declare Function ExcludeClipRect Lib "gdi32" (ByVal hdc As Long, _
                                                      ByVal X1 As Long, _
                                                      ByVal Y1 As Long, _
                                                      ByVal X2 As Long, _
                                                      ByVal Y2 As Long) As Long


Private m_bIsNt                                 As Boolean
Private m_bRestrictToClient                     As Boolean
Private m_bIsActive                             As Boolean
Private m_bMultiline                            As Boolean
Private m_bGradient                             As Boolean
Private m_bXPColors                             As Boolean
Private m_bAutoTips                             As Boolean
Private m_bTimerActive                          As Boolean
Private m_bTrackUser32                          As Boolean
Private m_bShowing                              As Boolean
Private m_bVisiting                             As Boolean
Private m_lLastX                                As Long
Private m_lLastY                                As Long
Private m_lSafeTimer                            As Long
Private m_lColorOffset                          As Long
Private m_lTransparency                         As Long
Private m_lhTitleFnt                            As Long
Private m_lhTextFnt                             As Long
Private m_lToolTipPosition                      As Long
Private m_lToolHwnd                             As Long
Private m_lBackColor                            As Long
Private m_lDelayTime                            As Long
Private m_lForeColor                            As Long
Private m_lIcon                                 As Long
Private m_lVisibleTime                          As Long
Private m_lParentHwnd                           As Long
Private m_lCtrlHwnd                             As Long
Private m_lWidth                                As Long
Private m_lHeight                               As Long
Private m_lImlHwnd                              As Long
Private m_sText                                 As String
Private m_sTitle                                As String
Private m_tRWnd                                 As RECT
Private m_tRTxt                                 As RECT
Private m_tRTtl                                 As RECT
Private m_tRIcn                                 As RECT
Private m_oFont                                 As StdFont
Private m_oTitleFont                            As StdFont
Private m_oTextFont                             As StdFont

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -