AeroTextBox.ctl
上传用户:jnjasmy
上传日期:2015-01-04
资源大小:637k
文件大小:12k
源码类别:

GDI/图象编程

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Begin VB.UserControl AeroTextBox 
  3.    BackColor       =   &H00B2ACA5&
  4.    ClientHeight    =   1740
  5.    ClientLeft      =   0
  6.    ClientTop       =   0
  7.    ClientWidth     =   2910
  8.    BeginProperty Font 
  9.       Name            =   "Segoe UI"
  10.       Size            =   9
  11.       Charset         =   0
  12.       Weight          =   400
  13.       Underline       =   0   'False
  14.       Italic          =   0   'False
  15.       Strikethrough   =   0   'False
  16.    EndProperty
  17.    ScaleHeight     =   116
  18.    ScaleMode       =   3  'Pixel
  19.    ScaleWidth      =   194
  20.    ToolboxBitmap   =   "AeroTextBox.ctx":0000
  21.    Begin VB.TextBox Text1 
  22.       BorderStyle     =   0  'None
  23.       Height          =   495
  24.       Left            =   840
  25.       TabIndex        =   0
  26.       Text            =   "Text1"
  27.       Top             =   600
  28.       Width           =   1215
  29.    End
  30. End
  31. Attribute VB_Name = "AeroTextBox"
  32. Attribute VB_GlobalNameSpace = False
  33. Attribute VB_Creatable = True
  34. Attribute VB_PredeclaredId = False
  35. Attribute VB_Exposed = True
  36. Option Explicit
  37. 'Default Property Values:
  38. Const m_def_BorderStyle = 1
  39. 'Property Variables:
  40. Dim m_BorderStyle As Integer
  41. 'Event Declarations:
  42. Event Click() 'MappingInfo=Text1,Text1,-1,Click
  43. Attribute Click.VB_Description = "Occurs when the user presses and then releases a mouse button over an object."
  44. Event DblClick() 'MappingInfo=Text1,Text1,-1,DblClick
  45. Attribute DblClick.VB_Description = "Occurs when the user presses and releases a mouse button and then presses and releases it again over an object."
  46. Event KeyDown(KeyCode As Integer, Shift As Integer) 'MappingInfo=Text1,Text1,-1,KeyDown
  47. Attribute KeyDown.VB_Description = "Occurs when the user presses a key while an object has the focus."
  48. Event KeyPress(KeyAscii As Integer) 'MappingInfo=Text1,Text1,-1,KeyPress
  49. Attribute KeyPress.VB_Description = "Occurs when the user presses and releases an ANSI key."
  50. Event KeyUp(KeyCode As Integer, Shift As Integer) 'MappingInfo=Text1,Text1,-1,KeyUp
  51. Attribute KeyUp.VB_Description = "Occurs when the user releases a key while an object has the focus."
  52. Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=Text1,Text1,-1,MouseDown
  53. Attribute MouseDown.VB_Description = "Occurs when the user presses the mouse button while an object has the focus."
  54. Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=Text1,Text1,-1,MouseMove
  55. Attribute MouseMove.VB_Description = "Occurs when the user moves the mouse."
  56. Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=Text1,Text1,-1,MouseUp
  57. Attribute MouseUp.VB_Description = "Occurs when the user releases the mouse button while an object has the focus."
  58. Event Change() 'MappingInfo=Text1,Text1,-1,Change
  59. Attribute Change.VB_Description = "Occurs when the contents of a control have changed."
  60. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  61. 'MappingInfo=Text1,Text1,-1,BackColor
  62. Public Property Get BackColor() As OLE_COLOR
  63. Attribute BackColor.VB_Description = "Returns/sets the background color used to display text and graphics in an object."
  64.   BackColor = Text1.BackColor
  65. End Property
  66. Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
  67.   Text1.BackColor() = New_BackColor
  68.   PropertyChanged "BackColor"
  69. End Property
  70. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  71. 'MappingInfo=Text1,Text1,-1,ForeColor
  72. Public Property Get ForeColor() As OLE_COLOR
  73. Attribute ForeColor.VB_Description = "Returns/sets the foreground color used to display text and graphics in an object."
  74.   ForeColor = Text1.ForeColor
  75. End Property
  76. Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
  77.   Text1.ForeColor() = New_ForeColor
  78.   PropertyChanged "ForeColor"
  79. End Property
  80. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  81. 'MappingInfo=UserControl,UserControl,-1,Enabled
  82. Public Property Get Enabled() As Boolean
  83. Attribute Enabled.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events."
  84.   Enabled = UserControl.Enabled
  85. End Property
  86. Public Property Let Enabled(ByVal New_Enabled As Boolean)
  87.   UserControl.Enabled() = New_Enabled
  88.   PropertyChanged "Enabled"
  89. End Property
  90. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  91. 'MappingInfo=Text1,Text1,-1,Font
  92. Public Property Get Font() As Font
  93. Attribute Font.VB_Description = "Returns a Font object."
  94. Attribute Font.VB_UserMemId = -512
  95.   Set Font = Text1.Font
  96. End Property
  97. Public Property Set Font(ByVal New_Font As Font)
  98.   Set Text1.Font = New_Font
  99.   PropertyChanged "Font"
  100. End Property
  101. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  102. 'MappingInfo=Text1,Text1,-1,Refresh
  103. Public Sub Refresh()
  104. Attribute Refresh.VB_Description = "Forces a complete repaint of a object."
  105.   Text1.Refresh
  106. End Sub
  107. Private Sub Text1_Click()
  108.   RaiseEvent Click
  109. End Sub
  110. Private Sub Text1_DblClick()
  111.   RaiseEvent DblClick
  112. End Sub
  113. Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
  114.   RaiseEvent KeyDown(KeyCode, Shift)
  115. End Sub
  116. Private Sub Text1_KeyPress(KeyAscii As Integer)
  117.   RaiseEvent KeyPress(KeyAscii)
  118. End Sub
  119. Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
  120.   RaiseEvent KeyUp(KeyCode, Shift)
  121. End Sub
  122. Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  123.   RaiseEvent MouseDown(Button, Shift, X, Y)
  124. End Sub
  125. Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  126.   RaiseEvent MouseMove(Button, Shift, X, Y)
  127. End Sub
  128. Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  129.   RaiseEvent MouseUp(Button, Shift, X, Y)
  130. End Sub
  131. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  132. 'MappingInfo=Text1,Text1,-1,Alignment
  133. Public Property Get Alignment() As Integer
  134. Attribute Alignment.VB_Description = "Returns/sets the alignment of a CheckBox or OptionButton, or a control's text."
  135.   Alignment = Text1.Alignment
  136. End Property
  137. Public Property Let Alignment(ByVal New_Alignment As Integer)
  138.   Text1.Alignment() = New_Alignment
  139.   PropertyChanged "Alignment"
  140. End Property
  141. Private Sub Text1_Change()
  142.   RaiseEvent Change
  143. End Sub
  144. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  145. 'MappingInfo=UserControl,UserControl,-1,hWnd
  146. Public Property Get hWnd() As Long
  147. Attribute hWnd.VB_Description = "Returns a handle (from Microsoft Windows) to an object's window."
  148.   hWnd = UserControl.hWnd
  149. End Property
  150. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  151. 'MappingInfo=Text1,Text1,-1,MaxLength
  152. Public Property Get maxLength() As Long
  153. Attribute maxLength.VB_Description = "Returns/sets the maximum number of characters that can be entered in a control."
  154.   maxLength = Text1.maxLength
  155. End Property
  156. Public Property Let maxLength(ByVal New_MaxLength As Long)
  157.   Text1.maxLength() = New_MaxLength
  158.   PropertyChanged "MaxLength"
  159. End Property
  160. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  161. 'MappingInfo=Text1,Text1,-1,PasswordChar
  162. Public Property Get PasswordChar() As String
  163. Attribute PasswordChar.VB_Description = "Returns/sets a value that determines whether characters typed by a user or placeholder characters are displayed in a control."
  164.   PasswordChar = Text1.PasswordChar
  165. End Property
  166. Public Property Let PasswordChar(ByVal New_PasswordChar As String)
  167.   Text1.PasswordChar() = New_PasswordChar
  168.   PropertyChanged "PasswordChar"
  169. End Property
  170. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  171. 'MappingInfo=Text1,Text1,-1,SelLength
  172. Public Property Get SelLength() As Long
  173. Attribute SelLength.VB_Description = "Returns/sets the number of characters selected."
  174.   SelLength = Text1.SelLength
  175. End Property
  176. Public Property Let SelLength(ByVal New_SelLength As Long)
  177.   Text1.SelLength() = New_SelLength
  178.   PropertyChanged "SelLength"
  179. End Property
  180. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  181. 'MappingInfo=Text1,Text1,-1,SelStart
  182. Public Property Get SelStart() As Long
  183. Attribute SelStart.VB_Description = "Returns/sets the starting point of text selected."
  184.   SelStart = Text1.SelStart
  185. End Property
  186. Public Property Let SelStart(ByVal New_SelStart As Long)
  187.   Text1.SelStart() = New_SelStart
  188.   PropertyChanged "SelStart"
  189. End Property
  190. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  191. 'MappingInfo=Text1,Text1,-1,SelText
  192. Public Property Get SelText() As String
  193. Attribute SelText.VB_Description = "Returns/sets the string containing the currently selected text."
  194.   SelText = Text1.SelText
  195. End Property
  196. Public Property Let SelText(ByVal New_SelText As String)
  197.   Text1.SelText() = New_SelText
  198.   PropertyChanged "SelText"
  199. End Property
  200. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  201. 'MappingInfo=Text1,Text1,-1,Text
  202. Public Property Get Text() As String
  203. Attribute Text.VB_Description = "Returns/sets the text contained in the control."
  204.   Text = Text1.Text
  205. End Property
  206. Public Property Let Text(ByVal New_Text As String)
  207.   Text1.Text() = New_Text
  208.   PropertyChanged "Text"
  209. End Property
  210. 'Initialize Properties for User Control
  211. Private Sub UserControl_InitProperties()
  212.   m_BorderStyle = m_def_BorderStyle
  213.   Text1.Text = Ambient.DisplayName
  214. End Sub
  215. 'Load property values from storage
  216. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  217.   Text1.BackColor = PropBag.ReadProperty("BackColor", &H80000005)
  218.   Text1.ForeColor = PropBag.ReadProperty("ForeColor", &H80000008)
  219.   UserControl.Enabled = PropBag.ReadProperty("Enabled", True)
  220.   Set Text1.Font = PropBag.ReadProperty("Font", Ambient.Font)
  221.   Text1.Alignment = PropBag.ReadProperty("Alignment", 0)
  222.   Text1.maxLength = PropBag.ReadProperty("MaxLength", 0)
  223.   Text1.PasswordChar = PropBag.ReadProperty("PasswordChar", "")
  224.   Text1.SelLength = PropBag.ReadProperty("SelLength", 0)
  225.   Text1.SelStart = PropBag.ReadProperty("SelStart", 0)
  226.   Text1.SelText = PropBag.ReadProperty("SelText", "")
  227.   Text1.Text = PropBag.ReadProperty("Text", Ambient.DisplayName)
  228.   m_BorderStyle = PropBag.ReadProperty("BorderStyle", m_def_BorderStyle)
  229.   UserControl_Resize
  230. End Sub
  231. Private Sub UserControl_Resize()
  232.   Text1.Move m_BorderStyle, m_BorderStyle, ScaleWidth - (m_BorderStyle * 2), ScaleHeight - (m_BorderStyle * 2)
  233.   Height = (Text1.Height + (m_BorderStyle * 2)) * Screen.TwipsPerPixelY
  234.   SetWindowRgn hWnd, CreateRoundRectRgn(0, 0, ScaleWidth + 1, ScaleHeight + 1, 2, 2), True
  235. End Sub
  236. Private Sub UserControl_Show()
  237.   UserControl_Resize
  238. End Sub
  239. 'Write property values to storage
  240. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  241.   Call PropBag.WriteProperty("BackColor", Text1.BackColor, &H80000005)
  242.   Call PropBag.WriteProperty("ForeColor", Text1.ForeColor, &H80000008)
  243.   Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
  244.   Call PropBag.WriteProperty("Font", Text1.Font, Ambient.Font)
  245.   Call PropBag.WriteProperty("Alignment", Text1.Alignment, 0)
  246.   Call PropBag.WriteProperty("MaxLength", Text1.maxLength, 0)
  247.   Call PropBag.WriteProperty("PasswordChar", Text1.PasswordChar, "")
  248.   Call PropBag.WriteProperty("SelLength", Text1.SelLength, 0)
  249.   Call PropBag.WriteProperty("SelStart", Text1.SelStart, 0)
  250.   Call PropBag.WriteProperty("SelText", Text1.SelText, "")
  251.   Call PropBag.WriteProperty("Text", Text1.Text, Ambient.DisplayName)
  252.   Call PropBag.WriteProperty("BorderStyle", m_BorderStyle, m_def_BorderStyle)
  253. End Sub
  254. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  255. 'MemberInfo=7,0,0,1
  256. Public Property Get BorderStyle() As Integer
  257. Attribute BorderStyle.VB_Description = "Returns/sets the border style for an object."
  258.   BorderStyle = m_BorderStyle
  259. End Property
  260. Public Property Let BorderStyle(ByVal New_BorderStyle As Integer)
  261.   m_BorderStyle = New_BorderStyle
  262.   PropertyChanged "BorderStyle"
  263. End Property