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

📄 ctrcommand.ctl

📁 this code helps u to understand the basic thing to connect visual basic with sqlserver. this ll be v
💻 CTL
📖 第 1 页 / 共 3 页
字号:
VERSION 5.00
Begin VB.UserControl ctrCommand 
   Alignable       =   -1  'True
   AutoRedraw      =   -1  'True
   BackColor       =   &H00FFFFFF&
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   510
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   1230
   EditAtDesignTime=   -1  'True
   MousePointer    =   99  'Custom
   ScaleHeight     =   34
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   82
   Begin VB.Image imgPicture 
      Height          =   330
      Left            =   45
      Top             =   90
      Width           =   330
   End
End
Attribute VB_Name = "ctrCommand"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

 ' Enum Sastoiania na ramkata
Public Enum enum_ggcmd_BorderState
            [None] ' niama ramka
            [Raised] ' "povdignata" ramka
            [Inset] ' "natisnata" ramka
End Enum

 ' Enum Border3DStyle
Public Enum enum_ggcmd_Border3DStyle
            [Border3DStyle_None]
            [Border3DStyle_ClientEdge]
            [Border3DStyle_DlgModalFrame]
            [Border3DStyle_StaticEdge]
            [Border3DStyle_Frame]
End Enum

 ' Enum Podravniavane
Public Enum enum_ggcmd_Alignment
            [Left_Top]
            [Left_Middle]
            [Left_Bottom]
            [Center_Top]
            [Center_Middle]
            [Center_Bottom]
            [Right_Top]
            [Right_Middle]
            [Right_Bottom]
End Enum

 ' Enum ToolTip Icon
Public Enum enum_ggcmd_ToolTipIcon
    [ToolTipIcon_None]
    [ToolTipIcon_Info]
    [ToolTipIcon_Warning]
    [ToolTipIcon_Error]
End Enum

 ' Enum ToolTip Style
Public Enum enum_ggcmd_ToolTipStyle
    [ToolTipStyle_Standart]
    [ToolTipStyle_Balloon]
End Enum

Public Enum enum_ggcmd_GradientOrientation
       [GradientOrientation_Vertical]
       [GradientOrientation_Horizontal]
End Enum

'Property Variables:
Private pstrCaption As String
Private plngCaptionXOffset As Long
Private plngCaptionYOffset As Long

Private penumCaptionAlignment As enum_ggcmd_Alignment
Private penumPictureAlignment As enum_ggcmd_Alignment

Private pboolUseHoverProperties As Boolean
Private pboolFontBoldOnHover As Boolean
Private plngFontColorOnHover As OLE_COLOR

Private ppicPicture As Picture
Private plngPictureXOffset As Long
Private plngPictureYOffset As Long

Private pboolAlwaysShowBorder As Boolean

Private plngBorder3DStyle As enum_ggcmd_Border3DStyle

Private proplngGradientOrientation As Long
Private propboolUseGradientFill As Boolean
Private proplngGradientFromColor As OLE_COLOR
Private proplngGradientToColor As OLE_COLOR
Private propboolGradientInverseOnPress As Boolean

Private propboolDontReleaseCapture As Boolean

 ' ToolTip properties
Private pstrToolTip As String
Private pstrToolTipTitle As String
Private pboolToolTipCentered As Boolean
Private plngToolTipBackColor As OLE_COLOR
Private plngToolTipForeColor As OLE_COLOR
Private plngToolTipIcon As enum_ggcmd_ToolTipIcon
Private plngToolTipStyle As enum_ggcmd_ToolTipStyle
Private plngToolTipHwnd As Long

'Local variables
Private boolCaptured As Boolean
Private enumBorderState As enum_ggcmd_BorderState
Private boolMouseFocus As Boolean
Private sngCaptionXPos As Single
Private sngCaptionYPos As Single
Private sngPictureXPos As Single
Private sngPictureYPos As Single
Private byteOffset As Byte
Private boolMouseWasDown As Boolean

'Public events
Public Event Click()
Public Event DblClick()
Public Event MouseEnter()
Public Event MouseExit()
Public Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Public Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

'API functions
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long

Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Type POINTAPI
        X As Long
        Y As Long
End Type
Private Declare Function ClientToScreen Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long


Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type
Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long

Private Const WM_USER = &H400
Private Const CW_USEDEFAULT = &H80000000
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_NOMOVE = &H2
Private Const SWP_FRAMECHANGED = &H20
Private Const HWND_TOPMOST = -1

''Tooltip Window Constants
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_ACTIVATE = WM_USER + 1
Private Const TTM_UPDATETIPTEXTA = (WM_USER + 12)
Private Const TTM_SETDELAYTIME = (WM_USER + 28)
Private Const TTM_SETMAXTIPWIDTH = (WM_USER + 24)
Private Const TTM_SETTIPBKCOLOR = (WM_USER + 19)
Private Const TTM_SETTIPTEXTCOLOR = (WM_USER + 20)
Private Const TTM_SETTITLE = (WM_USER + 32)
Private Const TTS_BALLOON = &H40
Private Const TTS_ALWAYSTIP = &H1
Private Const TTF_SUBCLASS = &H10
Private Const TOOLTIPS_CLASSA = "tooltips_class32"
''Tooltip Window Types
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 tpToolInfo As TOOLINFO

Private Declare Function OleTranslateColor Lib "oleaut32.dll" (ByVal lOleColor As Long, ByVal lHPalette As Long, lColorRef 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 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) 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 DestroyWindow Lib "user32" (ByVal hWnd As Long) As Long

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long


Public Property Let Border3DStyle(New_Border3DStyle As enum_ggcmd_Border3DStyle)

plngBorder3DStyle = New_Border3DStyle

Call Sub_CalculateAlignment
Call Sub_PrintCaption

PropertyChanged "Border3DStyle"

End Property

Public Property Get Border3DStyle() As enum_ggcmd_Border3DStyle

Border3DStyle = plngBorder3DStyle

End Property


Public Property Let DontReleaseCapture(boolNewDontReleaseCapture As Boolean)

propboolDontReleaseCapture = boolNewDontReleaseCapture

End Property

Public Property Let GradientFromColor(lngNewGradientFromColor As OLE_COLOR)

If proplngGradientFromColor <> lngNewGradientFromColor Then
   proplngGradientFromColor = lngNewGradientFromColor
   Sub_PrintCaption
   PropertyChanged "GradientFromColor"
End If

End Property

Public Property Get GradientFromColor() As OLE_COLOR

GradientFromColor = proplngGradientFromColor

End Property


Public Property Let GradientInverseOnPress(boolNewGradientInverseOnPress As Boolean)

propboolGradientInverseOnPress = boolNewGradientInverseOnPress
Sub_PrintCaption
PropertyChanged "GradientInverseOnPress"

End Property

Public Property Get GradientInverseOnPress() As Boolean

GradientInverseOnPress = propboolGradientInverseOnPress

End Property

Public Property Let GradientOrientation(lngNewOrientation As enum_ggcmd_GradientOrientation)

If lngNewOrientation <> proplngGradientOrientation Then
   proplngGradientOrientation = lngNewOrientation
   GradientOrientation = lngNewOrientation
   Sub_CalculateAlignment
   Call Sub_PrintCaption
   PropertyChanged "GradientOrientation"
End If

End Property

Public Property Get GradientOrientation() As enum_ggcmd_GradientOrientation

GradientOrientation = proplngGradientOrientation

End Property

Public Property Get GradientToColor() As OLE_COLOR

GradientToColor = proplngGradientToColor

End Property

Public Property Let GradientToColor(lngNewGradientToColor As OLE_COLOR)

If proplngGradientToColor <> lngNewGradientToColor Then
   proplngGradientToColor = lngNewGradientToColor
   Sub_PrintCaption
   PropertyChanged "GradientToColor"
End If

End Property

Private Sub Sub_SetBorder3DStyle(lngBorderStyle As enum_ggcmd_Border3DStyle)

Select Case lngBorderStyle
       Case Border3DStyle_None
            SetWindowLong UserControl.hWnd, -20, 0
       Case Border3DStyle_ClientEdge
             'WS_EX_CLIENTEDGE=&h200
            SetWindowLong UserControl.hWnd, -20, &H200
       Case Border3DStyle_DlgModalFrame
             'WS_EX_DLGMODALFRAME=&h1
            SetWindowLong UserControl.hWnd, -20, &H1
       Case Border3DStyle_StaticEdge
             'WS_EX_STATICEDGE=&h20000
            SetWindowLong UserControl.hWnd, -20, &H20000
       Case Border3DStyle_Frame
             'WS_EX_CLIENTEDGE=&H200 Or WS_EX_DLGMODALFRAME=&H1
            SetWindowLong UserControl.hWnd, -20, &H201
End Select

SetWindowPos UserControl.hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_FRAMECHANGED

End Sub

Public Property Let ToolTipBackColor(New_ToolTipBackColor As OLE_COLOR)

plngToolTipBackColor = New_ToolTipBackColor

PropertyChanged "ToolTipBackColor"

End Property

Public Property Let ToolTipForeColor(New_ToolTipForeColor As OLE_COLOR)

plngToolTipForeColor = New_ToolTipForeColor

PropertyChanged "ToolTipForeColor"

End Property


Public Property Get ToolTipBackColor() As OLE_COLOR

ToolTipBackColor = plngToolTipBackColor

End Property

Public Property Get ToolTipForeColor() As OLE_COLOR

ToolTipForeColor = plngToolTipForeColor

End Property


Public Property Get ToolTipCentered() As Boolean

ToolTipCentered = pboolToolTipCentered

End Property

Public Property Let ToolTipCentered(New_ToolTipCentered As Boolean)

pboolToolTipCentered = New_ToolTipCentered

PropertyChanged "ToolTipCentered"

End Property

Private Function ToolTipCreate() As Boolean
    
 ' This code is downloaded from www.planet-source-code.com
 ' File name is(was in 2001) - Awesome To3117410252001.zip
    
Dim lpRect As RECT
Dim lngToolTipStyle As Long
Dim lngOleColor As Long
    
If plngToolTipHwnd <> 0 Then
 Call ToolTipDestroy
End If
    
lngToolTipStyle = TTS_ALWAYSTIP Or TTS_NOPREFIX
    
 ''create baloon style if desired
If plngToolTipStyle = ToolTipStyle_Balloon Then lngToolTipStyle = lngToolTipStyle Or TTS_BALLOON
    
plngToolTipHwnd = CreateWindowEx(0&, _
                                 TOOLTIPS_CLASSA, _
                                 vbNullString, _
                                 lngToolTipStyle, _
                                 CW_USEDEFAULT, _
                                 CW_USEDEFAULT, _
                                 CW_USEDEFAULT, _
                                 CW_USEDEFAULT, _
                                 UserControl.hWnd, _
                                 0&, _
                                 App.hInstance, _
                                 0&)
 ''make our tooltip window a topmost window
SetWindowPos plngToolTipHwnd, _
             HWND_TOPMOST, _
             0&, _
             0&, _
             0&, _
             0&, _
             SWP_NOACTIVATE Or SWP_NOSIZE Or SWP_NOMOVE
                    
 ''get the rect of the parent control
GetClientRect plngToolTipHwnd, lpRect
        
 ''now set our tooltip info structure
With tpToolInfo
  ''if we want it centered, then set that flag
 If pboolToolTipCentered = True Then
  .lFlags = TTF_SUBCLASS Or TTF_CENTERTIP
 Else
  .lFlags = TTF_SUBCLASS
 End If
 ''set the hwnd prop to our parent control's hwnd
 .lHwnd = UserControl.hWnd
 .lId = 0
 .hInstance = App.hInstance
 .lpStr = pstrToolTip
 .lpRect = lpRect
End With
        
 ''add the tooltip structure
SendMessage plngToolTipHwnd, TTM_ADDTOOLA, 0&, tpToolInfo
        
'If plngToolTipHwnd <> 0 Then
' SendMessage plngToolTipHwnd, TTM_UPDATETIPTEXTA, 0&, tpToolInfo
'End If
        
 ''if we want a title or we want an icon
If pstrToolTipTitle <> vbNullString Or plngToolTipIcon <> ToolTipIcon_None Then
 SendMessage plngToolTipHwnd, TTM_SETTITLE, CLng(plngToolTipIcon), ByVal pstrToolTipTitle
End If

OleTranslateColor plngToolTipForeColor, 0&, lngOleColor
SendMessage plngToolTipHwnd, TTM_SETTIPTEXTCOLOR, lngOleColor, 0&

OleTranslateColor plngToolTipBackColor, 0&, lngOleColor
SendMessage plngToolTipHwnd, TTM_SETTIPBKCOLOR, lngOleColor, 0&
    
End Function
Public Property Let AlwaysShowBorder(New_AlwaysShowBorder As Boolean)

pboolAlwaysShowBorder = New_AlwaysShowBorder
If pboolAlwaysShowBorder = True Then
 Sub_DrawBorder [Raised]
Else
 Sub_DrawBorder [None]
End If
PropertyChanged "AlwaysShowBorder"

End Property

Public Property Get AlwaysShowBorder() As Boolean

AlwaysShowBorder = pboolAlwaysShowBorder

End Property


Public Property Let Caption(New_Caption As String)

pstrCaption = New_Caption
Sub_CalculateAlignment
Sub_PrintCaption

PropertyChanged "Caption"

End Property

Public Property Let CaptionAlignment(New_CaptionAlignment As enum_ggcmd_Alignment)

penumCaptionAlignment = New_CaptionAlignment
Sub_CalculateAlignment
Sub_PrintCaption
PropertyChanged "CaptionAlignment"

End Property

Public Property Get CaptionAlignment() As enum_ggcmd_Alignment

CaptionAlignment = penumCaptionAlignment

End Property

Public Property Let CaptionXOffset(New_CaptionXOffset As Long)

plngCaptionXOffset = New_CaptionXOffset
Sub_CalculateAlignment
Sub_PrintCaption
PropertyChanged "CaptionXOffset"

End Property

Public Property Get CaptionXOffset() As Long

CaptionXOffset = plngCaptionXOffset

End Property


Public Property Let CaptionYOffset(New_CaptionYOffset As Long)

plngCaptionYOffset = New_CaptionYOffset

⌨️ 快捷键说明

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