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

📄 ctrcommand.ctl

📁 this code helps u to understand the basic thing to connect visual basic with sqlserver. this ll be v
💻 CTL
📖 第 1 页 / 共 3 页
字号:
Else
 Sub_DrawBorder [Raised]
 Sub_DrawBorder None, True
End If

End Sub


Public Property Get MousePointer() As MousePointerConstants

 MousePointer = UserControl.MousePointer

End Property

Public Property Let MousePointer(ByVal New_MousePointer As MousePointerConstants)

On Error Resume Next
 
UserControl.MousePointer() = New_MousePointer
PropertyChanged "MousePointer"

End Property

Private Function Fun_GetRValue(Color As OLE_COLOR) As Byte

On Error Resume Next

Fun_GetRValue = Color And &HFF

End Function

Private Function Fun_GetGValue(Color As OLE_COLOR) As Byte

On Error Resume Next

Fun_GetGValue = Color \ 256 And &HFF

End Function


Private Function Fun_GetBValue(Color As OLE_COLOR) As Byte

On Error Resume Next

Fun_GetBValue = Color \ 65536

End Function

Private Sub Sub_DrawGradient(FromColor As OLE_COLOR, _
                             ToColor As OLE_COLOR, _
                             Optional boolInverseGradient As Boolean = False)

On Error Resume Next

If propboolUseGradientFill = False Then Exit Sub

 ' Uncomment if .AutoRedraw=False
'UserControl.Cls



Dim X As Integer
Dim R1 As Single
Dim G1 As Single
Dim B1 As Single
Dim R2 As Single
Dim G2 As Single
Dim B2 As Single
Dim RX As Single
Dim GX As Single
Dim BX As Single
Dim RY As Single
Dim GY As Single
Dim BY As Single
Dim SW As Single
Dim SH As Single
Dim lngFromColor As Long
Dim lngToColor As Long
Dim lngTemp As Long

OleTranslateColor FromColor, 0&, lngFromColor
OleTranslateColor ToColor, 0&, lngToColor

If boolInverseGradient = True Then
   lngTemp = lngFromColor
   lngFromColor = lngToColor
   lngToColor = lngTemp
End If

R1 = Fun_GetRValue(lngFromColor)
G1 = Fun_GetGValue(lngFromColor)
B1 = Fun_GetBValue(lngFromColor)
R2 = Fun_GetRValue(lngToColor)
G2 = Fun_GetGValue(lngToColor)
B2 = Fun_GetBValue(lngToColor)
SW = UserControl.ScaleWidth
SH = UserControl.ScaleHeight


If proplngGradientOrientation = GradientOrientation_Horizontal Then
   RY = (R2 - R1) / SW
   GY = (G2 - G1) / SW
   BY = (B2 - B1) / SW
   For X = 0 To SW
       UserControl.Line (X, 0)-(X, UserControl.ScaleHeight), RGB(R1, G1, B1) ', BF
       R1 = R1 + RY
       G1 = G1 + GY
       B1 = B1 + BY
   Next X
End If

If proplngGradientOrientation = GradientOrientation_Vertical Then
   RY = (R2 - R1) / SH
   GY = (G2 - G1) / SH
   BY = (B2 - B1) / SH
   For X = 0 To SH
       UserControl.Line (0, X)-(UserControl.ScaleWidth, X), RGB(R1, G1, B1) ', BF
       R1 = R1 + RY
       G1 = G1 + GY
       B1 = B1 + BY
   Next X
End If


End Sub


Private Sub UserControl_KeyPress(KeyAscii As Integer)

Exit Sub

If KeyAscii = 13 Then
 RaiseEvent Click
End If

End Sub


Private Sub UserControl_LostFocus()

Sub_PrintCaption
Sub_DrawBorder [None]

End Sub
Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim lngTemp As Long
Dim boolTemp As Boolean
Dim boolTempGradient As Boolean

 ' Saobshtavame na sabitieto "GotFocus"
 ' che fokysa e vzet sled natiskane s mishkata
 ' a ne s "TAB" klavisha
boolMouseFocus = True
boolMouseWasDown = True

 ' Parvo predizvikvam sabitieto
RaiseEvent MouseDown(Button, Shift, X, Y)

 ' Ako bytona e levia togava se chertae bordera
 ' I otnovo se vzima "Capture" zashtoto pri MouseDown toi se gybi
If Button = 1 Then
 lngTemp = UserControl.ForeColor
 boolTemp = UserControl.Font.Bold
 UserControl.ForeColor = plngFontColorOnHover
 UserControl.Font.Bold = pboolFontBoldOnHover
 If propboolUseGradientFill = True Then
    If propboolGradientInverseOnPress = True Then
       boolTempGradient = True
    End If
 End If
 Sub_CalculateAlignment
 Sub_PrintCaption 1, boolTempGradient
 UserControl.ForeColor = lngTemp
 UserControl.Font.Bold = boolTemp
 Sub_CalculateAlignment
 Sub_DrawBorder [Inset]
End If
SetCapture UserControl.hWnd
boolCaptured = True

End Sub

Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim lngTemp As Long
Dim boolTemp As Boolean
Dim lngWindowFromPoint As Long
Dim tpPointApi As POINTAPI

tpPointApi.X = CLng(X)
tpPointApi.Y = CLng(Y)

ClientToScreen UserControl.hWnd, tpPointApi
lngWindowFromPoint = WindowFromPoint(tpPointApi.X, tpPointApi.Y)

If lngWindowFromPoint = UserControl.hWnd And X >= 0 And Y >= 0 And X <= UserControl.ScaleWidth And Y <= UserControl.ScaleHeight Then
 If boolCaptured = False Then

  If pstrToolTip <> "" Then
   Call ToolTipCreate
'   clsMyToolTip.TipText = pstrToolTip
'   clsMyToolTip.Style = TTBalloon
'   clsMyToolTip.Centered = True
'   clsMyToolTip.Title = "45yvw45y "
'   clsMyToolTip.ParentControl = Me.hwnd
'   clsMyToolTip.Create
  End If
  
  RaiseEvent MouseEnter
  SetCapture UserControl.hWnd
  If pboolUseHoverProperties = True Then
   lngTemp = UserControl.ForeColor
   boolTemp = UserControl.Font.Bold
   UserControl.ForeColor = plngFontColorOnHover
   UserControl.Font.Bold = pboolFontBoldOnHover
   Sub_CalculateAlignment
   Sub_PrintCaption byteOffset
   UserControl.Font.Bold = boolTemp
   UserControl.ForeColor = lngTemp
  End If
  Sub_DrawBorder [Raised]
  boolCaptured = True
 End If
Else
 If propboolDontReleaseCapture = False Then
    RaiseEvent MouseExit
    
    Call ToolTipDestroy
    
    boolMouseWasDown = False
    ReleaseCapture
    lngTemp = UserControl.ForeColor
    boolTemp = UserControl.Font.Bold
    UserControl.Font.Bold = pboolFontBoldOnHover
    UserControl.Font.Bold = boolTemp
    Sub_CalculateAlignment
    Sub_PrintCaption
    boolCaptured = False
    Sub_DrawBorder [None]
 End If
End If

RaiseEvent MouseMove(Button, Shift, X, Y)

End Sub


'Initialize Properties for User Control
Private Sub UserControl_InitProperties()

pstrCaption = UserControl.Extender.Name
penumCaptionAlignment = [Center_Middle]
penumPictureAlignment = [Left_Middle]
plngFontColorOnHover = vbBlue
pboolUseHoverProperties = True

plngToolTipBackColor = vbInfoBackground
plngToolTipForeColor = vbInfoText

proplngGradientOrientation = [GradientOrientation_Vertical]
propboolUseGradientFill = True
proplngGradientFromColor = vb3DHighlight
proplngGradientToColor = vb3DShadow
propboolGradientInverseOnPress = True

Set UserControl.Font = Ambient.Font

Set ppicPicture = LoadPicture("")

End Sub

Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim lngTemp As Long
Dim boolTemp As Boolean

 ' Pri MouseUp ne se vzema focusa
boolMouseFocus = False

If Button = 1 And boolMouseWasDown = True Then
 RaiseEvent Click
End If
 
boolMouseWasDown = False
 
RaiseEvent MouseUp(Button, Shift, X, Y)

If Button = 1 Then
 lngTemp = UserControl.ForeColor
 boolTemp = UserControl.Font.Bold
 UserControl.ForeColor = plngFontColorOnHover
 UserControl.Font.Bold = pboolFontBoldOnHover
 Sub_CalculateAlignment
 Sub_PrintCaption
 UserControl.ForeColor = lngTemp
 UserControl.Font.Bold = boolTemp
 Sub_CalculateAlignment
 Sub_DrawBorder [Raised]
End If

SetCapture UserControl.hWnd
boolCaptured = True

End Sub

Private Sub UserControl_Paint()

'Sub_PrintCaption byteOffset

If enumBorderState <> [None] Then
 Sub_DrawBorder enumBorderState
End If

End Sub

'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)

pstrCaption = PropBag.ReadProperty("Caption", UserControl.Extender.Name)
penumCaptionAlignment = PropBag.ReadProperty("CaptionAlignment", [Center_Middle])
plngCaptionXOffset = PropBag.ReadProperty("CaptionXOffset", 0)
plngCaptionYOffset = PropBag.ReadProperty("CaptionYOffset", 0)

pboolUseHoverProperties = PropBag.ReadProperty("UseHoverProperties", True)
pboolFontBoldOnHover = PropBag.ReadProperty("FontBoldOnHover", False)
plngFontColorOnHover = PropBag.ReadProperty("FontColorOnHover", vbBlue)

UserControl.BackColor = PropBag.ReadProperty("BackColor", vb3DFace)
UserControl.ForeColor = PropBag.ReadProperty("ForeColor", vbButtonText)

Set UserControl.Font = PropBag.ReadProperty("Font", Ambient.Font)

Set ppicPicture = PropBag.ReadProperty("Picture", Nothing)
penumPictureAlignment = PropBag.ReadProperty("PictureAlignment", [Left_Middle])
plngPictureXOffset = PropBag.ReadProperty("PictureXOffset", 0)
plngPictureYOffset = PropBag.ReadProperty("PictureYOffset", 0)

pboolAlwaysShowBorder = PropBag.ReadProperty("AlwaysShowBorder", False)

pstrToolTip = PropBag.ReadProperty("ToolTip", "")
pstrToolTipTitle = PropBag.ReadProperty("ToolTipTitle", "")
plngToolTipBackColor = PropBag.ReadProperty("ToolTipBackColor", vbInfoBackground)
plngToolTipForeColor = PropBag.ReadProperty("ToolTipForeColor", vbInfoText)
plngToolTipIcon = PropBag.ReadProperty("ToolTipIcon", ToolTipIcon_None)
plngToolTipStyle = PropBag.ReadProperty("ToolTipStyle", ToolTipStyle_Standart)
'pboolToolTipCentered = PropBag.ReadProperty("ToolTipCentered", False)

plngBorder3DStyle = PropBag.ReadProperty("Border3DStyle", Border3DStyle_None)

proplngGradientOrientation = PropBag.ReadProperty("GradientOrientation", [GradientOrientation_Vertical])
propboolUseGradientFill = PropBag.ReadProperty("UseGradientFill", True)
proplngGradientFromColor = PropBag.ReadProperty("GradientFromColor", vb3DHighlight)
proplngGradientToColor = PropBag.ReadProperty("GradientToColor", vb3DShadow)
propboolGradientInverseOnPress = PropBag.ReadProperty("GradientInverseOnPress", True)

UserControl.MousePointer = PropBag.ReadProperty("MousePointer", 0)

UserControl.Enabled = PropBag.ReadProperty("Enabled", True)

End Sub

Private Sub UserControl_Resize()

Sub_CalculateAlignment
Sub_PrintCaption

End Sub


Private Sub UserControl_Show()

Sub_CalculateAlignment
Sub_PrintCaption

End Sub


Private Sub UserControl_Terminate()

Call ToolTipDestroy

End Sub

'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)

Call PropBag.WriteProperty("Caption", pstrCaption, UserControl.Extender.Name)
Call PropBag.WriteProperty("CaptionAlignment", penumCaptionAlignment, [Center_Middle])
Call PropBag.WriteProperty("CaptionXOffset", plngCaptionXOffset, 0)
Call PropBag.WriteProperty("CaptionYOffset", plngCaptionYOffset, 0)

Call PropBag.WriteProperty("UseHoverProperties", pboolUseHoverProperties, True)
Call PropBag.WriteProperty("FontBoldOnHover", pboolFontBoldOnHover, False)
Call PropBag.WriteProperty("FontColorOnHover", plngFontColorOnHover, vbBlue)

Call PropBag.WriteProperty("BackColor", UserControl.BackColor, vb3DFace)
Call PropBag.WriteProperty("ForeColor", UserControl.ForeColor, vbButtonText)

Call PropBag.WriteProperty("Font", UserControl.Font, Ambient.Font)

Call PropBag.WriteProperty("Picture", ppicPicture, Nothing)
Call PropBag.WriteProperty("PictureAlignment", penumPictureAlignment, [Left_Middle])
Call PropBag.WriteProperty("PictureXOffset", plngPictureXOffset, 0)
Call PropBag.WriteProperty("PictureYOffset", plngPictureYOffset, 0)

Call PropBag.WriteProperty("AlwaysShowBorder", pboolAlwaysShowBorder, False)

Call PropBag.WriteProperty("ToolTip", pstrToolTip, "")
Call PropBag.WriteProperty("ToolTipTitle", pstrToolTipTitle, "")
Call PropBag.WriteProperty("ToolTipBackColor", plngToolTipBackColor, vbInfoBackground)
Call PropBag.WriteProperty("ToolTipForeColor", plngToolTipForeColor, vbInfoText)
Call PropBag.WriteProperty("ToolTipIcon", plngToolTipIcon, ToolTipIcon_None)
Call PropBag.WriteProperty("ToolTipStyle", plngToolTipStyle, ToolTipStyle_Standart)
'Call PropBag.WriteProperty("ToolTipCentered", pboolToolTipCentered, False)
Call PropBag.WriteProperty("Border3DStyle", plngBorder3DStyle, Border3DStyle_None)


Call PropBag.WriteProperty("GradientOrientation", proplngGradientOrientation, [GradientOrientation_Vertical])
Call PropBag.WriteProperty("UseGradientFill", propboolUseGradientFill, True)
Call PropBag.WriteProperty("GradientFromColor", proplngGradientFromColor, vb3DHighlight)
Call PropBag.WriteProperty("GradientToColor", proplngGradientToColor, vb3DShadow)
Call PropBag.WriteProperty("GradientInverseOnPress", propboolGradientInverseOnPress, True)

Call PropBag.WriteProperty("MousePointer", UserControl.MousePointer, 0)

Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)

End Sub

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,BackColor
Public Property Get BackColor() As OLE_COLOR
Attribute BackColor.VB_Description = "Returns/sets the background color used to display text and graphics in an object."
 
 BackColor = UserControl.BackColor

End Property

Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
 
UserControl.BackColor() = New_BackColor
Sub_PrintCaption
Sub_DrawBorder enumBorderState
PropertyChanged "BackColor"

End Property


Public Property Get Font() As Font
Attribute Font.VB_Description = "Returns a Font object."
Attribute Font.VB_UserMemId = -512
 Set Font = UserControl.Font
End Property

Public Property Set Font(ByVal New_Font As Font)
 
Set UserControl.Font = New_Font
Sub_CalculateAlignment
Sub_PrintCaption
PropertyChanged "Font"

End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=11,0,0,0
Public Property Get Picture() As Picture
 
Set Picture = ppicPicture
 
End Property

Public Property Set Picture(ByVal New_Picture As Picture)

On Error Resume Next

Set ppicPicture = New_Picture

Sub_CalculateAlignment
Sub_PrintCaption

PropertyChanged "Picture"

End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,Enabled
Public Property Get Enabled() As Boolean
Attribute Enabled.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events."
 Enabled = UserControl.Enabled
End Property

Public Property Let Enabled(ByVal New_Enabled As Boolean)
 UserControl.Enabled() = New_Enabled
 PropertyChanged "Enabled"
End Property

⌨️ 快捷键说明

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