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

📄 clsodcontrol.cls

📁 一款Grid表格控件源代码,非常棒.不下你一定会后悔
💻 CLS
📖 第 1 页 / 共 5 页
字号:
Private Declare Function SetWindowLongW Lib "USER32" (ByVal hWnd As Long, _
                                                      ByVal nIndex As Long, _
                                                      ByVal dwNewLong As Long) As Long


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

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

Private Declare Function GetComboBoxInfo Lib "USER32" (ByVal hwndCombo As Long, _
                                                       CBInfo As COMBOBOXINFO) As Long

Private Declare Function GetDC Lib "user32.dll" (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 GetClientRect Lib "USER32" (ByVal hWnd As Long, _
                                                     lpRect As RECT) As Long

Private Declare Function InflateRect Lib "USER32" (lpRect As RECT, _
                                                   ByVal x As Long, _
                                                   ByVal y 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 CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long

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

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

Private Declare Function GetWindow Lib "USER32" (ByVal hWnd As Long, _
                                                 ByVal wCmd 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_Create Lib "COMCTL32" (ByVal MinCx As Long, _
                                                          ByVal MinCy As Long, _
                                                          ByVal flags As Long, _
                                                          ByVal cInitial As Long, _
                                                          ByVal cGrow As Long) As Long

Private Declare Function ImageList_Add Lib "COMCTL32" (ByVal hImageList As Long, _
                                                       ByVal hBitmap As Long, _
                                                       ByVal hBitmapMask As Long) As Long

Private Declare Function ImageList_AddMasked Lib "COMCTL32" (ByVal hImageList As Long, _
                                                             ByVal hbmImage As Long, _
                                                             ByVal crMask 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 ImageList_AddIcon Lib "COMCTL32" (ByVal hImageList As Long, _
                                                           ByVal hIcon As Long) As Long

Private Declare Function ImageList_Remove Lib "comctl32.dll" (ByVal himl As Long, _
                                                              ByVal i As Long) As Long

Private Declare Function ImageList_Destroy Lib "COMCTL32" (ByVal hImageList As Long) As Long

Private Declare Function IsWindowEnabled Lib "USER32" (ByVal hWnd As Long) 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 SetBkMode Lib "gdi32" (ByVal hdc As Long, _
                                                ByVal nBkMode As Long) As Long

Private Declare Function GetObjectA Lib "gdi32" (ByVal hObject As Long, _
                                                 ByVal nCount As Long, _
                                                 lpObject As Any) As Long

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

Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, _
                                                             ByVal nWidth As Long, _
                                                             ByVal nHeight As Long) As Long

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

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

Private Declare Sub InitCommonControls Lib "comctl32.dll" ()

Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, _
                                                    ByVal nIndex As Long) 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 CreateFontIndirectA Lib "gdi32" (lpLogFont As LOGFONT) As Long

Private Declare Function CreateFontIndirectW Lib "gdi32" (lpLogFont As LOGFONT) 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 GetWindowTextA Lib "USER32" (ByVal hWnd As Long, _
                                                      ByVal lpString As String, _
                                                      ByVal cch As Long) As Long

Private Declare Function GetWindowTextW Lib "USER32" (ByVal hWnd As Long, _
                                                      ByVal lpString As Long, _
                                                      ByVal cch As Long) As Long

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

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

Private Declare Function SetWindowTextA Lib "user32.dll" (ByVal hWnd As Long, _
                                                          ByVal lpString As String) As Long

Private Declare Function SetWindowTextW Lib "user32.dll" (ByVal hWnd As Long, _
                                                          ByVal lpString As Long) As Long

Private Declare Function EraseRect Lib "USER32" Alias "InvalidateRect" (ByVal hWnd As Long, _
                                                                        lpRect As RECT, _
                                                                        ByVal bErase As Long) 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 MoveToEx Lib "gdi32" (ByVal hdc As Long, _
                                               ByVal x As Long, _
                                               ByVal y As Long, _
                                               lpPoint As POINTAPI) 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 CopyRect Lib "USER32" (lpDestRect As RECT, _
                                                lpSourceRect As RECT) As Long

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

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

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


Public Event Click()
Public Event ItemChange(ByVal lItem As Long)

Private m_bTrackUser32                          As Boolean
Private m_bPainting                             As Boolean
Private m_bIsNt                                 As Boolean
Private m_bAutoBackColor                        As Boolean
Private m_bLocked                               As Boolean
Private m_bChecked                              As Boolean
Private m_bMouseOver                            As Boolean
Private m_bAutoSize                             As Boolean
Private m_bLabelTransparent                     As Boolean
Private m_bCommandPushButton                    As Boolean
Private m_bCommandPushed                        As Boolean
Private m_bEnabled                              As Boolean
Private m_bVisible                              As Boolean
Private m_ImlCommandHnd                         As Long
Private m_lItemIndex                            As Long
Private m_ImlListBoxHnd                         As Long
Private m_lhButtonBrush                         As Long
Private m_lParentHwnd                           As Long
Private m_lCntlHwnd                             As Long
Private m_lEditHwnd                             As Long
Private m_ImlChkBoxHnd                          As Long
Private m_lHFont                                As Long
Private m_lCmdHeight                            As Long
Private m_lCmdWidth                             As Long
Private m_lHdc()                                As Long
Private m_lBmp()                                As Long
Private m_lBmpOld()                             As Long
Private m_lBackColor                            As Long
Private m_lForeColor                            As Long
Private m_lThemeColor                           As Long
Private m_lBorderStyle                          As Long
Private m_lHiliteColor                          As Long
Private m_lListHwnd                             As Long
Private m_sName                                 As String
Private m_eImageType                            As EITImageType
Private m_lImgHnd                               As Long
Private m_lItemImage()                          As Long
Private m_lBoxColor()                           As Long
Private m_tRect                                 As RECT
Private m_oFont                                 As StdFont
Private m_pControlImg                           As StdPicture
Private m_eControlStyle                         As ECSControlStyle
Private m_eBorderStyle                          As ECBSBorderStyle
Private m_eThemeStyle                           As ECCThemeStyle
Private m_cRender                               As clsRender
Private m_cCntrlDc                              As clsStoreDc
Private m_cCntlSubclass                         As GXMSubclass


Private Sub Class_Initialize()

    InitCommonControls
    VersionCheck
    m_bTrackUser32 = FunctionExported("TrackMouseEvent", "User32")
    Set m_cCntlSubclass = New GXMSubclass
    m_lBackColor = &HFEFEFE
    m_lThemeColor = -1
    m_lHiliteColor = -1
    
End Sub

Private Function VersionCheck() As Boolean
'/* nt version chck

Dim tVer    As OSVERSIONINFO

    tVer.dwVersionInfoSize = LenB(tVer)
    GetVersionEx tVer
    m_bIsNt = ((tVer.dwPlatformId And VER_PLATFORM_WIN32_NT) = VER_PLATFORM_WIN32_NT)
    VersionCheck = m_bIsNt

End Function


'> Properties
'>>>>>>>>>>>>>>>>>>>>>>
Public Property Get AutoBackColor() As Boolean
    AutoBackColor = m_bAutoBackColor
End Property

Public Property Let AutoBackColor(ByVal PropVal As Boolean)

Dim lColor As Long

    If Not (m_lCntlHwnd = 0) Then
        If PropVal Then
            lColor = GetBackColor
            If Not (lColor < 0) Then
                m_lBackColor = lColor
            End If
        End If
    End If
    m_bAutoBackColor = PropVal
    
End Property

Public Property Get AutoSize() As Boolean
    AutoSize = m_bAutoSize
End Property

Public Property Let AutoSize(ByVal PropVal As Boolean)

    If Not (m_lCntlHwnd = 0) Then
        If PropVal Then
            LabelSize Text
        End If
    End If
    m_bAutoSize = PropVal
    
End Property

Public Property Get BackColor() As Long
    BackColor = m_lBackColor
End Property

Public Property Let BackColor(ByVal PropVal As Long)
    m_lBackColor = PropVal
End Property

Public Property Get Checked() As Boolean
    Checked = m_bChecked
End Property

Public Property Let Checked(ByVal PropVal As Boolean)
    m_bChecked = PropVal
    If Not (m_lCntlHwnd = 0) Then
        UpdateWindow m_lCntlHwnd
    End If
End Property

⌨️ 快捷键说明

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