Step 2:

Application developed with Visual Basic, Part 3.


3rd Step
, modify the frmMain.frm file
.


The frmMain.frm file design, after modification.

TestVB0
........ Info Menu
.
.

...
Learn how to write a Visual Basic application ...
.


  1. Add the files :
    From the ...\VB App\res folder copy the followihg files:
    1. The (GIF Image) ingraphic1.gif  file  to the folder C:\Test\Test VB0\ res .
    2. The (Icon) BookIco.ico file to the folder C:\Test\Test VB0\ res
  2. Modify the frmMain.frm View Object - Form Window:
    1. Modify the Form - frmMain, Form Properties:
      Name:
      Caption:
      Height:
      Left:
      MaxButton:
      MinButton:
      ScaleMode:
      StartUpPosition:
      Top:
      Width:
      frmMain
      TestVB0
      6855
      0
      False
      True
      1 - Twip
      0 - Manual
      0
      9600


    2. Remove The CommonDialog control - dlgCommonDialog.
      The CommonDialog control provides a standard set of dialog boxes for operations such as opening and saving files, setting print options, and selecting colors and fonts.

    3. Add the following controls from the Toolbox :
      One Image control - Image1 and one Label control - Lbword.
      1. Add the Image control - Image1, Image Properties:
        Use the Image control to display a graphic. An Image control can display a graphic from a bitmap, icon, or metafile, as well as enhanced metafile, JPEG, or GIF files.
        Remarks
        :
        The Image control uses fewer system resources and repaints faster than a PictureBox control, but it supports only a subset of the PictureBox properties, events, and methods. Use the Stretch property to determine whether the graphic is scaled to fit the control or vice versa. Although you can place an Image control within a container, an Image control can't act as a container.
        Name:
        BorderStyle:
        Height:
        Left:
        Top:
        Width:
        Image1
        0 - None
        2415
        1800
        960
        2055

        Note:
        The image1
        displays the file ingraphic1.gif - (stored in the folder
        C:\Test\Test VB0\ res)
        .

      2. Add the Label control - Lbword, Label Properties:
        A Label control is a graphical control you can use to display text that a user can't change directly.
        Remarks:
        You can write code that changes the text displayed by a Label control in response to events at run time. For example, if your application takes a few minutes to commit a change, you can display a processing-status message in a Label. You can also use a Label to identify a control, such as a TextBox control, that doesn't have its own Caption property.
        Set the AutoSize and WordWrap properties if you want the Label to properly display variable-length lines or varying numbers of lines.
        Name:
        Alignment:
        Caption:
        Font:
        Height:
        Left:
        Top:
        Width:
        Lbword
        2 - Center
        W ...
        MS Sans Serif, Bold Italic, size = 10
        255
        120
        4920
        9375


    4. Modify the Menu using the Menu Editer :
      A Menu control displays a custom menu for your application. A menu can include commands, submenus, and separator bars. Each menu you create can have up to four levels of submenus.
      Remarks:
      To create a Menu control, use the Menu Editor. Enter the name of the Menu control in the Caption box. To create a separator bar, enter a single hyphen (-) in the Caption box. To display a check mark to the left of a menu item, select the Checked box.
      While you can set some Menu control properties using the Menu Editor, all Menu control properties are displayed in the Properties window. To display the properties of a Menu control, select the menu name in the Objects list at the top of the Properties window.
      When you create an MDI application, the menu bar on the MDI child form replaces the menu bar on the MDIForm object when the child form is active.
      Use the Menu Editor command to create custom menus for your application , add new commands to existing menus, replace menu commands with your own commands, and change and delete existing menus and menu bars.

      From the View menu, choose Project Explorer, at the Project window select the frmMain View Object.
      From the Tools menu, choose Menu Editor ..., the Menu Editor dialog box appears, then
      work with this Properties.

      The Properties values of the menu - Info menu, after modification:

      Item Menu Caption Name Other Properties
      1- Info menu
      2- B
      ook
      3- (seperator bar)
      4- Exit
      Info Menu
      Book
      -
      Exit
      mnuFile
      mnuDataBook
      mnu1
      mnuFileExit
      Enabled and Visible
      Enabled and Visible
      Enabled and Visible
      Enabled and Visible


      The menu designs:

      Before modification   After modification.
       


  3. The frmMain.frm file View Code, after modification :

    Examine these changes:
    -
    The new text Code to be add is red.
    -
    The text Code to be remove is navy and Strikethrough effects.

    Private Sub Form_Load()
    Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
    Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
    Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500)
    Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500)



    'New setting size of frmMain
    Me.Height = Screen.Height - 500
    Me.Width = Screen.Width
    Me.Top = 50
    Me.Left = 0

    'Load the icon - res/BookIco.ico file
    Set Me.Icon = LoadPicture(App.Path & "\res\BookIco.ico")

    'Load the picture and size - ingraphic1.gif file
    Set Image1.Picture = LoadPicture(App.Path & "\res\ingraphic1.gif")
    Image1.Left = (Me.Width - Image1.Width) / 2

    'Load the Caption value of Label and size - Lbword
    Lbword.Caption = "Learn how to write Visual Basic application ..."
    Lbword.Width = Me.Width - 235
    Lbword.Top = Image1.Top + Image1.Height + 2 * (sbStatusBar.Top - (Image1.Top + Image1.Height + Lbword.Height)) / 3


    End Sub

    -------------------------------------------------------------------------------
    Private Sub Form_Unload(Cancel As Integer)
    Dim i As Integer


    'close all sub forms
    For i = Forms.Count - 1 To 1 Step -1
    Unload Forms(i)
    Next
    If Me.WindowState <> vbMinimized Then
    SaveSetting App.Title, "Settings", "MainLeft", Me.Left
    SaveSetting App.Title, "Settings", "MainTop", Me.Top
    SaveSetting App.Title, "Settings", "MainWidth", Me.Width
    SaveSetting App.Title, "Settings", "MainHeight", Me.Height
    End If

    End Sub

    ------------------------------------------------------------------------------
    Private Sub mnuDataBook_Click()
    Dim f As New Book
    f.Show
    End Sub

    ------------------------------------------------------------------------------
    Private Sub mnuFileExit_Click()
    'unload the form
    Unload Me

    End Sub


  4. To save this application; From File menu, choose and click Save Project.
  5. To run it; From Run menu, choose and click Start.

Previous
Home 3 Home
Next