In the past, a naming convention was always set up during development, and the Manual was always checked repeatedly during use. This is really troublesome. Today I am presenting a new external VB6 file to a brother. Program He said that he could not automatically add the control prefix, so there is no need to memorize it, so I tried it, okay, very simple, mainly Code As follows:
Public Withevents ctlhandler As Vbcontrolsevents
' Monitoring Control name prefix
Private Sub Watchnameprefixion (byval vbcontrol As Vbide. vbcontrol)
Dim Filecontent As String
Filecontent = Readall (App. Path & " \ Controlprefixion. config " )
Filecontent = Replace (Filecontent, " " , "" )
Dim Rows () As String
Dim Cols () As String
Dim I As Integer
Dim II As Integer
Rows = Split (Filecontent, vbcrlf)
For I = Lbound (Rows) To Ubound (Rows)
Cols = Split (Rows (I ), " = " )
If Ubound (Cols) = 1 Then
If Ucase (VBA. typename (vbcontrol. controlobject )) = Ucase (Cols ( 0 )) Then
If Ucase (VBA. Left (vbcontrol. properties ( " Name " ), Len (Cols ( 1 )))) <> Ucase (Cols ( 1 )) Then
Vbcontrol. properties ( " Name " ) = Cols ( 1 ) & Vbcontrol. properties ( " Name " )
End If
Exit For
End If
End If
Next
Erase Rows
Erase Cols
End sub
Private Sub Ctlhandler_itemrenamed (byval vbcontrol As Vbide. vbcontrol, byval oldname As String , Byval oldindex As Long )
Watchnameprefixion vbcontrol
End sub
In this Code, we mainly create an external program of VB6, and then add the prefix in the itemrenamed event.
The control prefix list is stored in the controlprefixion. config file, as follows:
3 dpanel = pnl
Adodata = ado
Animatedbutton = ANI
Checkbox = CHK
ComboBox = CBO
Drop-downlistbox = CBO
Commandbutton = cmd
Commondialog = DLG
Communications = com
Data = dat
Data-boundcombobox = dbcbo
Data-boundgrid = dbgrd
Data-boundlistbox = dblst
Datacombo = DBC
DataGrid = DGD
Datalist = DBL
Datarepeater = DRP
Datepicker = DTP
Directorylistbox = dir
DriveListBox = DRV
FileListBox = fil
Flatscrollbar = FSB
Form = FRM
Frame = FRA
Gauge = Gau
Graph = gra
Grid = GRD
Hierarchicalflexgrid = flex
Horizontalscrollbar = HSB
Image = img
Imagecombo = imgcbo
Imagelist = ILS
Label = LBL
Lightweightcheckbox = lwchk
Lightweightcombobox = lwcbo
Lightweightcommandbutton = lwcmd
Lightweightframe = lwfra
Lightweighthorizontalscrollbar = lwhsb
Lightweightlistbox = lwlst
Lightweightoptionbutton = lwopt
Lightweighttextbox = lwtxt
Lightweightverticalscrollbar = lwvsb
Line = Lin
ListBox = lst
Listview = LVW
Mapimessage = mpm
Mapisession = MPs
MCI = MCI
Menu = MNU
Monthview = mvw
Mschart = CH
Msflexgrid = msg
Mstab = MST
Olecontainer = Ole
Optionbutton = OPT
Picturebox = PIC
Pictureclip = CLP
Progressbar = PRG
Remotedata = RD
RichTextBox = RTF
Shape = SHP
Slider = SLD
Spin = spin
Statusbar = sta
Sysinfo = sys
Tabstrip = Tab
Textbox = txt
Timer = TMR
Toolbar = TLB
Treeview = tre
Updown = UPD
Verticalscrollbar = VSB
Once this plug-in is loaded, after a control is added to the form, such as a command, after the name is changed to "OK" in the attribute window, the system automatically adds "cmd" to the front of the Control name and changes it to "cmdok", so you no longer need to remember the control prefix.
With this, I am very happy to be able to at least make the manual thinner.
during the development of this plug-in, it is worth noting that a company always has various specifications to regulate the code development specifications of programmers, in fact, if you can provide some automatic tools or template tools, the programmer will not have to memorize them, and all the standard programmers will automatically abide by them, so there will be no worries. This is the best way, the project manager is easy, ^ _ ^.