Presentation is loading. Please wait.

Presentation is loading. Please wait.

PictureBox, MessageBox, Multiple Forms, Splash Screens and Timers

Similar presentations


Presentation on theme: "PictureBox, MessageBox, Multiple Forms, Splash Screens and Timers"— Presentation transcript:

1 PictureBox, MessageBox, Multiple Forms, Splash Screens and Timers
Chapter 2 pp Chapter 4 pp Chapter 7 pp Chapter 8 pp Chapter 2

2 Chapter 2 PictureBox Control Chapter 2

3 PictureBox Control Download these bmp files from the ftp site:
Oklahoma.bmp Utah.bmp Insert PictureBox controls and name them: picOklahoma picUtah Adjust SizeMode. Chapter 2

4 Picture Box SixeMode Values
AutoSize Adjusts automatically to fit size of image it displays. CenterImage Centers image within control size when bounding box is > than the image. Displays center portion of image and cropped to fit if box is < than image. Normal Aligns image with upper left corner of control box; clips image if image is larger than box size. StretchImage Scales image to fit within control box. Stretches smaller image or shrinks larger image. Chapter 2

5 Chapter 2

6 Chapter 4 MessageBox Method Chapter 2

7 MessageBox Dialog box that displays a message to the user.
Types of messages: Information (Your data has been added) Warnings (Do you want to save?) Critical (System Error) Question (Need input from user) Chapter 2

8 MessageBox.Show Method
MessageBox.Show("Message") Message box with OK button; no title Chapter 2

9 MessageBox("Message","Caption")
Comma separates arguments. Quotes surround string literals. Underscore provides line continuation. Caption appears on title bar. Chapter 2

10 MessageBox("Message","Caption",Buttons)
MessageBoxButtons.AbortRetryIgnore MessageBoxButtons.OK MessageBoxButtons.OKCancel MessageBoxButtons.RetryCancel MessageBoxButtons.YesNo MessageBoxButtons.YesNoCancel Will program later when we can control action of buttons. Chapter 2

11 MessageBox.Show("Message","Caption",Buttons,Icon)
MessageBoxIcon.Information MessageBoxIcon.Asterisk MessageBoxIcon.Error MessageBoxIcon.Stop MessageBoxIcon.Warning MessageBoxIcon.Exclamation MessageBoxIcon.Question Chapter 2

12 MessageBox Example Chapter 2

13 Which button clicked? Will cover later after learning about variables.
Stay tuned… Chapter 2

14 Multiple Lines: ControlChars.CrLf
Displays multiple lines within a message box. ControlChars.CrLf Carriage return/line feed Begin a new line Example MessageBox.Show("This is line 1" & _ ("This is line 2") Chapter 2

15 Chapter 7 Multiple Forms Chapter 2

16 Form Names and File Names
Default Name Property: Form1 Default File Name: Form1.vb Should assign descriptive form names for multiple-form programs Need to do more than change Name property: Also change file name Also change Startup Object Chapter 2

17 Default File Name and Name
Chapter 2

18 Changed File Name and Name
Must keep .vb filename extension. Chapter 2

19 Startup Object (p. 405) Right-click Project name (in Solution Explorer window) and choose Properties. …or… Choose Project, Properties. Chapter 2

20 Startup Object Click Startup object drop-down arrow and choose form name to be first object (form) that appears. Chapter 2

21 Add Form Click Add New Item on toolbar. Keep the .vb extension
Chapter 2

22 Switching Between Forms
Active Form Code window for frmStates form frmstates form Chapter 2

23 Instance of Form 1st step to display form: create an instance.
Dim ObjectVariable As New ClassName() ObjectVariable Name that refers to instance of form, sort of like an alias (not name of form itself though) Holds memory address of object (form) so that you can use it ClassName() Form’s class name—the name used in the Name property for a form Chapter 2

24 Example Dim errorForm As New frmError()
errorForm is object variable name that creates instance of actual form frmError is the name of the actual form Does not actually display form Chapter 2

25 ShowDialog Method Modal method ObjectVariable.ShowDialog()
No other form can receive focus until the modal form is closed. Forces user (or timer) to acknowledge active form ObjectVariable.ShowDialog() errorForm.ShowDialog() Chapter 2

26 Show Method Modeless form ObjectVariable.Show() errorForm.Show()
Allows user to switch focus to another form while the modeless form is displayed ObjectVariable.Show() errorForm.Show() Chapter 2

27 Close Method Closes a form and releases it from memory. Me.Close()
Me—current instance of the form Close—closes current instance Use to close a form in a multiple-form program without terminating the application Chapter 2

28 Hide Method Removes form from the screen.
Keeps form in memory; does not release it. Acts like changing form’s Visible property to False. Chapter 2

29 Splash Screens & Timer Control
Chapter 8 Splash Screens & Timer Control Chapter 2

30 Splash Screen (p. 513) Form displayed while a program loads.
Typical content: Logo Copyright Date (©2004) Program Name (e.g., Microsoft Word) Program Version (e.g., 2003) Disappears after short time TopMost Property: True Displays on top of other forms Chapter 2

31 Timer Control (p. 511) Enables a program to automatically execute code at regular time intervals. Examples: Perform animation Unload a form (such as a splash screen) after a time delay Conventional prefix tmr tmrSplashScreen Responds to Tick events Chapter 2

32 Timer Properties Interval Property Enabled Property
Set to value of 1 or greater Each 1 = 1 millisecond (thousandth of a second); 1,000 milliseconds = 1 second Error if set to 0 Enabled Property Set to True Chapter 2

33 Hide Splash Screen (p. 515 Step 7)
Me.Close () closes the current form Chapter 2

34 Main Form (p. 515 Step 9) Set as the Startup Object.
Create object variable in Form Load. Use variable to show other form. Form variable declared Actual name of form Name of actual form Form variable used to show actual form Chapter 2


Download ppt "PictureBox, MessageBox, Multiple Forms, Splash Screens and Timers"

Similar presentations


Ads by Google