All user interface components which are used in your code should be named with something like unique_UIType or UIMenu_Level1_Level2. The menus and toolbar objects should have the type first so that they will sort together. The rest sort alphabetically on the unique identifier name.
Static components which are not referenced via code should keep their default names.
Visual Basic 6.0
Status_UITextBox.ForeColor = vbRED 'set the color Status_UITextBox = "red" ' set the text property Status_UITextBox = 5 ' set the text property With commondlg .HelpFile = "filename.chm" .HelpCommand = &HB .ShowHelp End With
When you use the standard Windows Copy and Paste to copy an object, you will get a dialog box asking if "you want to create a control array?" If you answer no, the copy will have a unique name; if you answer yes, both objects will have the same name and the index properties of both the original and the new copy are assigned unique values.
Because the index property identifies specific objects in the array, it is required for all references to the array. Likewise, because it does not exist for regular objects, references to them do not allow it.
' Regular button object - It has a unique name Private Sub UIToolBar_Next_UIButton_Click() 'Your Code Here End Sub ' Buttons in a Control Array - Several buttons have same name Private Sub UIToolBar_Next_UIButton_Click(Index As Integer) 'Your Code Here End SubThe following references a property.
UniqueControlName.top = 5 ControlArrayName(index).top = 5When compiling an event, if the presence of the index parameter does not match the object definition, you will get the following error message
Compile error: Procedure declaration does not match description of event or procedure having the same name
The same error message is displayed if the value of the index property is deleted and the index parameter is left in the event definition, or vise versa.
Warning: When you place the cursor on a button's index property and press F1, the help refers to objects in a collection (a completely different concept). Following this thread leads to multiple dead ends.
Delphi
Video_1_UICheckBox.Caption := 'test';The use of with is not as clear as in VB because the leading dots are not used to indicate which parameters are part of the object. This causes significant confusion.
type TDate = record Day: Integer; Month: Integer; Year: Integer; end; var OrderDate: TDate; with OrderDate do begin Month := 1; Year := Year + 1; end // Is equivalent to OrderDate.Month := 1; OrderDate.Year := OrderDate.Year + 1;
if OpenDialog1.Execute then Memo1.Lines.LoadFromFile(OpenDialog1.FileName);If a component needs to reference another component on the form, You can try this
var xx : TRichEdit ; begin xx := application.MainForm.FindComponent('RichEdit1') as TRichEdit; xx.text := xx.text + "some string';
C++ Builder
Does not have a with construct
if (OpenDialog1->Execute()) Memo1->Lines->LoadFromFile(OpenDialog1->FileName);
Java
T1_UILabel.setName("Label1"); T1_UILabel.setAlignment(java.awt.Label.CENTER); T1_UILabel.setText("test data"); T1_UILabel.setBounds(19, 25, 127, 90); T1_UILabel.setBackground(Color.blue);
Others
SomeValue_UIEdit.SetFocus tempxx = SomeValue_UIEdit.TextAuthor: Robert Clemenzi - clemenzi@cpcug.org