?? focustext.ctl
字號:
VERSION 5.00
Begin VB.UserControl GridFocusText
ClientHeight = 315
ClientLeft = 0
ClientTop = 0
ClientWidth = 2340
LockControls = -1 'True
ScaleHeight = 315
ScaleWidth = 2340
ToolboxBitmap = "FocusText.ctx":0000
Begin VB.TextBox MyText
BorderStyle = 0 'None
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 300
Left = 75
TabIndex = 0
Top = 45
Width = 2025
End
Begin VB.Line lBottom
BorderColor = &H00FFFFFF&
Visible = 0 'False
X1 = 90
X2 = 3705
Y1 = 330
Y2 = 330
End
Begin VB.Line lRight
BorderColor = &H00FFFFFF&
Visible = 0 'False
X1 = 3645
X2 = 3645
Y1 = 45
Y2 = 675
End
Begin VB.Line lLeft
BorderColor = &H00808080&
Visible = 0 'False
X1 = 30
X2 = 30
Y1 = 30
Y2 = 690
End
Begin VB.Line lTop
BorderColor = &H00808080&
BorderWidth = 2
Visible = 0 'False
X1 = 45
X2 = 3645
Y1 = 30
Y2 = 30
End
End
Attribute VB_Name = "GridFocusText"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'缺省屬性值:
Const m_def_LineOut = 0
Const m_def_TextType = 0
Const m_def_BackStyle = 1
Const m_def_GotBackColor = &HFF0000
Const m_def_GotForeColor = &H80000005
Const m_def_LostBackColor = &H80000005
Const m_def_LostForeColor = &H80000008
Enum MyType
普通文本類型
無小數點數字
有小數點數字
End Enum
Enum OutType
固定邊框
浮動邊框
End Enum
'屬性變量:
Dim m_LineOut As OutType
Dim m_TextType As MyType
Dim m_PreControl As String
Dim m_NextControl As String
Dim m_BackStyle As Integer
Dim m_GotBackColor As OLE_COLOR
Dim m_GotForeColor As OLE_COLOR
Dim m_LostBackColor As OLE_COLOR
Dim m_LostForeColor As OLE_COLOR
'事件聲明:
Event Change() 'MappingInfo=MyText,MyText,-1,Change
Attribute Change.VB_Description = "當控件內容改變時發生。"
Event Click() 'MappingInfo=MyText,MyText,-1,Click
Attribute Click.VB_Description = "當用戶在一個對象上按下并釋放鼠標按鈕時發生。"
Event DblClick() 'MappingInfo=MyText,MyText,-1,DblClick
Attribute DblClick.VB_Description = "當用戶在一個對象上按下并釋放鼠標按鈕后再次按下并釋放鼠標按鈕時發生。"
Event KeyDown(KeyCode As Integer, Shift As Integer) 'MappingInfo=MyText,MyText,-1,KeyDown
Attribute KeyDown.VB_Description = "當用戶在擁有焦點的對象上按下任意鍵時發生。"
Event KeyPress(KeyAscii As Integer) 'MappingInfo=MyText,MyText,-1,KeyPress
Attribute KeyPress.VB_Description = "當用戶按下和釋放 ANSI 鍵時發生。"
Event KeyUp(KeyCode As Integer, Shift As Integer) 'MappingInfo=MyText,MyText,-1,KeyUp
Attribute KeyUp.VB_Description = "當用戶在擁有焦點的對象上釋放鍵時發生。"
Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=MyText,MyText,-1,MouseDown
Attribute MouseDown.VB_Description = "當用戶在擁有焦點的對象上按下鼠標按鈕時發生。"
Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=MyText,MyText,-1,MouseMove
Attribute MouseMove.VB_Description = "當用戶移動鼠標時發生。"
Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=MyText,MyText,-1,MouseUp
Attribute MouseUp.VB_Description = "當用戶在擁有焦點的對象上釋放鼠標發生。"
Private Sub MyText_GotFocus()
If LineOut = 浮動邊框 Then
LineVisible True
End If
MyText.SelStart = 0
MyText.SelLength = Len(MyText.Text)
MyText.BackColor = GotBackColor
MyText.ForeColor = GotForeColor
End Sub
Private Sub MyText_LostFocus()
If LineOut = 浮動邊框 Then
LineVisible False
End If
MyText.BackColor = LostBackColor
MyText.ForeColor = LostForeColor
End Sub
Private Sub UserControl_Resize()
On Error Resume Next
If UserControl.Height < 300 Then
UserControl.Height = 300
Exit Sub
End If
If UserControl.Width < 300 Then
UserControl.Width = 300
Exit Sub
End If
MyText.Left = 25
MyText.Top = 25
lTop.X1 = 3
lTop.Y1 = 3
lTop.Y2 = 3
lTop.X2 = UserControl.Width - 6
lLeft.X1 = 3
lLeft.X2 = 3
lLeft.Y1 = 3
lLeft.Y2 = UserControl.Height - 4
lBottom.X1 = lTop.X1
lBottom.X2 = lTop.X2 + 8
lBottom.Y1 = UserControl.Height - 10
lBottom.Y2 = UserControl.Height - 10
lTop.Y1 = 3
lTop.Y2 = 3
lBottom.X2 = lTop.X2
lRight.X1 = UserControl.Width - 8
lRight.X2 = UserControl.Width - 8
lRight.Y1 = lLeft.Y1
lRight.Y2 = lLeft.Y2
MyText.Width = UserControl.Width - 60
MyText.Height = UserControl.Height - 60
End Sub
'注意!不要刪除或修改下列被注釋的行!
'MappingInfo=MyText,MyText,-1,BackColor
Public Property Get BackColor() As OLE_COLOR
Attribute BackColor.VB_Description = "返回/設置對象中文本和圖形的背景色。"
BackColor = MyText.BackColor
End Property
Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
MyText.BackColor() = New_BackColor
PropertyChanged "BackColor"
End Property
'注意!不要刪除或修改下列被注釋的行!
'MappingInfo=MyText,MyText,-1,ForeColor
Public Property Get ForeColor() As OLE_COLOR
Attribute ForeColor.VB_Description = "返回/設置對象中文本和圖形的前景色。"
ForeColor = MyText.ForeColor
End Property
Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
MyText.ForeColor() = New_ForeColor
PropertyChanged "ForeColor"
End Property
'注意!不要刪除或修改下列被注釋的行!
'MappingInfo=MyText,MyText,-1,Enabled
Public Property Get Enabled() As Boolean
Attribute Enabled.VB_Description = "返回/設置一個值,決定一個對象是否響應用戶生成事件。"
Enabled = MyText.Enabled
End Property
Public Property Let Enabled(ByVal New_Enabled As Boolean)
MyText.Enabled() = New_Enabled
PropertyChanged "Enabled"
End Property
'注意!不要刪除或修改下列被注釋的行!
'MappingInfo=MyText,MyText,-1,Font
Public Property Get Font() As Font
Attribute Font.VB_Description = "返回一個 Font 對象。"
Attribute Font.VB_UserMemId = -512
Set Font = MyText.Font
End Property
Public Property Set Font(ByVal New_Font As Font)
Set MyText.Font = New_Font
PropertyChanged "Font"
End Property
'注意!不要刪除或修改下列被注釋的行!
'MemberInfo=7,0,0,1
Public Property Get BackStyle() As Integer
Attribute BackStyle.VB_Description = "返回/設置對象的邊框樣式。"
BackStyle = m_BackStyle
End Property
Public Property Let BackStyle(ByVal New_BackStyle As Integer)
m_BackStyle = New_BackStyle
PropertyChanged "BackStyle"
End Property
'注意!不要刪除或修改下列被注釋的行!
'MappingInfo=MyText,MyText,-1,BorderStyle
Public Property Get BorderStyle() As Integer
Attribute BorderStyle.VB_Description = "返回/設置對象的邊框樣式。"
BorderStyle = MyText.BorderStyle
End Property
Public Property Let BorderStyle(ByVal New_BorderStyle As Integer)
MyText.BorderStyle() = New_BorderStyle
PropertyChanged "BorderStyle"
End Property
'注意!不要刪除或修改下列被注釋的行!
'MappingInfo=MyText,MyText,-1,Refresh
Public Sub Refresh()
Attribute Refresh.VB_Description = "強制完全重畫一個對象。"
MyText.Refresh
End Sub
Private Sub MyText_Click()
RaiseEvent Click
End Sub
Private Sub MyText_DblClick()
RaiseEvent DblClick
End Sub
Private Sub MyText_KeyDown(KeyCode As Integer, Shift As Integer)
'判斷類型
'DirectFocus PreControl, NextControl, MyText, MyText, KeyCode
RaiseEvent KeyDown(KeyCode, Shift)
End Sub
Private Sub MyText_KeyPress(KeyAscii As Integer)
If TextType = 無小數點數字 Then
If KeyAscii = 8 Then '刪除鍵與回退鍵
Exit Sub
Else
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 45 Then
KeyAscii = 0
Exit Sub
End If
End If
End If
If TextType = 有小數點數字 Then
If KeyAscii = 8 Then '刪除鍵與回退鍵
Exit Sub
ElseIf InStr(1, MyText.Text, ".", vbTextCompare) Then
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 45 Then
KeyAscii = 0
Exit Sub
End If
Else
If ((KeyAscii < 46 Or KeyAscii = 47) Or KeyAscii > 57) And KeyAscii <> 45 Then
KeyAscii = 0
Exit Sub
End If
End If
End If
RaiseEvent KeyPress(KeyAscii)
End Sub
Private Sub MyText_KeyUp(KeyCode As Integer, Shift As Integer)
RaiseEvent KeyUp(KeyCode, Shift)
End Sub
Private Sub MyText_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseDown(Button, Shift, X, Y)
End Sub
Private Sub MyText_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseMove(Button, Shift, X, Y)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -