0. This paper submitted by
- We have surveyed how to write form and code modules (with special attention to arrays and strings for storing data and to writing our own Sub and Function procedures to break code into small, focused pieces so that loop can be written compactly), we have reviewed the toolbox controls and become familiar with many of the events that the controls recognize and the process of coding event procedures. In this lab we turn to the organization of the GUI at run-time (forms and frames being the organizers at design time). We have built several forms for some of our projects, but we had to execute the forms one at a time by setting the project property to the form to be run when we ran the project. Thus our projects have utilized a SDI or single document interface. Chapter 11 introduces the MDI form that is visually distinctive from the forms we have been using in what two characteristics?
- A MDI form is added to a project from the Project menu. A project may have up to __________ MDI forms.
- A "standard" form can be converted into a child form by changing the value of its _________ property.
- Create a new project, add a second form, then add a MDI form. Run the project. What can the user do?
- Check the startup object in the project properties and change it to a different form. What difference does it make?
- Place some controls on each of your three forms. How are you restricted?
- What does the PictureBox offer in the way of removing the restriction?
- Place a button in a picture box on the MDI form and then run with form1 as the start object. What do you observe about the behavior of form1?
- Some form must be loaded first, and it can then load other forms. Place a button on each of your three forms. Label the button on Form1 "load form 2" . Label the button on the Midi form "load form 1". When either of these buttons are pressed, Call load for the specified form and then call that form’s show property. The button on Form2 should print on form1 "printing from form 2" every time it is pressed. Insert the project (*.vbp) file here.
- The Picture box is aligned top by default. Change its alignment to Right and run the project and observe what is different (record your observations here).
- You cannot Print to the MDIform, but you CAN print to its picture box. Do so when form2’s button is pressed.
- Add two buttons to the MDIform, one labeled Tile and the the other labeled Cascade. When either is pressed, invoke the Arrange method with the proper argument and explain what happens here.
- Modify the project to that the button to load a form also unloads the other other form. Insert the *.frm file for form2 here.
- MDI forms serve as a frame to hold multiple windows and its Arrange method determines how the child windows appear in the frame. The MDIframe may also contain other controls (we could have a second PictureBox). However, we can have multiple forms displayed on the screen without nesting them insider a MDIform. Add a third form to the project and used the Form Layout window to position it in the upper right corner while the MDIform1 is positioned with its upper left corner toward the middle of the screen. Place a button on form3 the loads and shows the MDIform and set form3 as the load object. Manipulate both forms to the extent that you can and then explain how form3 and the MDIform interact when the project is run.
- The remaining entry on the project properties start object drop-down is Sub Main. This procedure must be written and stored in a *.bas module because it is NOT connected to a form. It is explained on page 472 and illustarted on page 473. How is it like and unlike a form_Load event procedure ?
- Forms have a title and we have exercised the minimize and maximize buttons at the right end of the title bar, but we have only used the close button to end the program. In 14 we should have noticed that the close button only ended the program because there was no other form being displayed. The event procedure QueryUnload is called when the close button is pressed, and if no code has been provided, the form Unload event is processed. Pages 472 to 475 illustrate writing code for the QueryUnload, code which uses the MsgBox with a Yes/No option. The example deals with four different frames. How many are visible at once? For each visible frame, what happens when its close button is pressed (you may have to run the author’s code to find the answer, but if so, you want to either remark out the set statements in frmStarter or find the path to the *.gif files )?
- Explain why the author used an array of images in fir. 11.16. Would the program work the same if all of the buttons said
frmForm1.imageImage.Picture=….
Call frmForm1.Show(….
That is, if ONLY ONE FRAME WERE USED?
- When Windows Explorer is used to click on a *.frm file VB60 is called and the form file is added to a default project and executed. However, VB60 can be set to make an *.exe file that will execute in Windows without VB (except that it may still need the *.dll file). This is discussed in 11.10, EXCEPT that your demo version of VB60 does not have this capability. Write and execute the program specified in exercise 11.10. Although this is just a "busy" loop and it is not expecting the user to do anything else, if it takes a long time we might get tired and like to stop (there should be a start and stop button on the interface and a textbox into which the 200 million or some like number can be input before the START button is pressed, and there should be a label in which the elapse time is displayed). Therefore you will want to use the DoEvents method as illustrated in fig. 11.20 and discussed on p. 479.