By convention, any selection which opens a dialog box ends with three dots (e.g. Open...).
The standard menu options are
File Edit Help New Undo Open... ----- -------- Save Cut About... Save As... Copy ------- Paste Print... ----- ------- ExitYou should use Notepad as a guide.
When referring to a menu selection, list all options from the top of the hierarchy - File/Open...
The menu editor can be explicitly opened to make modifications. Properties of individual menu options can be modified using the Properties window - just select the desired menu from the Properties window pull-down.
Private Sub UIMenu_File_Exit_Click() Unload Main_UIForm ' If there are no problems, ' this ends the application End ' Otherwise, this forces the application to quit End SubNotice that, by itself, the End command stops program execution and that code placed in the Unload, QueryUnload, and Terminate events of forms and class modules is not executed.
Alternatively,
Unload Mecould be used without having to know the name of the form.
Screen.ActiveControl.SelTextcan access the selected text, but how do I know if the ActiveControl is a text box and not a button? Well Screen.ActiveControl returns a control. However, there is no built-in help for control - no members, no properties, no parent, nothing. Neither the help file nor the fabulous Object Browser provides any information.
The help for ActiveControl contains a partial answer: TypeOf returns the object's type. However, the help for the TypeOf keyword points to If..Then..Else and provides no additional help at all. (The help for VB 3.0 and VB 6.0 are equally bad.) Additional TypeOf help is provided under Clipboard / checking data formats.
In order to control whether or not the menu selections are enabled, it is necessary for all editable UI Controls to add calls to UIMenu_Edit_Set_Enabled in the following events.
Form_Activate | Executed when the form starts |
xx_UITextBox_Click | Triggered when the mouse selects text |
xx_UITextBox_GotFocus | Required for when the user Tabs into the control |
xx_UITextBox_KeyUp | Triggered when the keyboard changes the selection (shift cursor key) |
xx_UITextBox_LostFocus | The next active control may be a button or some other control which does not have a SelLength property. If so, this call will disable the menu selections. |
There does not appear to be a way for events to bubble up and be handled at one place for all components. Instead, each editable component must add 4 calls to UIMenu_Edit_Set_Enabled, otherwise there will be problems. (Click on a TextBox with these calls, then click on another TextBox without these calls. Notice that Paste is still active. Now click on a button and then Edit/Paste. There will be an error.)
****************
It would make a lot more sense if the UI Controls had built-in overloaded virtual functions which handled these basic commands.
The whole point of object oriented programming is that you can treat an unknown object as a base object in the class hierarchy and execute overloaded methods without knowing, or caring, what the specific type of the object is.
VB 6.0 fails totally as an object oriented language.
Visual Basic uses the regular menu builder to define pop-up menus
(those that appear when you right click something).
Simply add a top level menu option and make sure that Visible is false.
The following code is from the VB 6 help ("pop-up menus / displaying"). It pops up a menu when the right mouse button is released.
Private Sub Form_MouseUp (Button As Integer, Shift As Integer, _ X As Single, Y As Single) If Button = 2 Then ' Check if right mouse button ' was clicked. PopupMenu mnuFile ' Display the File menu as a ' pop-up menu. End If End SubI suggest using a more descriptive name, like UIPopUpMenu_File.
Delphi
Double click the component to open the menu editor.
Properties of individual menu options can be modified using the
Object Inspector -
just click on the desired menu option.
The main properties are Caption (what is shown),
Name, and ShortCut (such as Ctrl-Ins).
procedure TForm1.Menu_File_ExitClick(Sender: TObject); begin Application.Terminate; end;
Many common actions are already defined.
When either a MainMenu or a PopupMenu component is placed on a form,
you double click it to open the Menu Designer dialog box.
Right click this dialog box to open the Insert From Template dialog box.
A variety of "templates" are available.
Notice that these templates do not assign actions or provide any code - you must manually define what each one of the selections actually does.
It appears that these templates are stored in
If you use Actions, then the default menu templates should not be used.
C++ Builder