Odds and Ends Component Tray Menu and contextmenu Splash Screen.

Slides:



Advertisements
Similar presentations
110-H1 More VB Tools Creating a Menu: What is a menu? a group of (related) commands displayed at at the top of an application Top level menu Disabled command.
Advertisements

Making a cartoon or slideshow. Aside VB comments An apostrophe starts a comment to end of line Some of the following slides have code with comments in.
Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
Chapter 1: An Introduction to Visual Basic.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Compunet Corporation Programming with Visual Studio.NET GUI Week 13 Tariq Aziz and Kevin Jones.
Control structures Part 2 iteration control To enable repetition of a statement block.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 7- 1.
An array of controls Not particularly convenient in VB Examples: array of pictureboxes Array of textboxes Notes on Concentration game (a possible final.
Multiple Forms & Procedures. Form Methods: –Show, Hide, Activate, Close Events: –Load, Activated, Closing, Closed.
Creating Menu. Objectives Create a menu system for a form –Create a menu –Create a menu titles –Create a menu items –Create a submenu –Modify menu –Edit.
CS0004: Introduction to Programming Events. Review  Event Procedure  A set of instructions to be executed when a certain event happens.  Many event-driven.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Ch 11: Userforms CP212 Winter Topics Designing User Forms o Controls Setting Properties o Tab Order o Testing Writing Event Handlers o Userform_Initialize.
Multiple Forms, Standard Modules, And Menus
5-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Chapter 3 Introducing Visual Basic.NET. 3.1 Visual Basic.NET Windows Programming -Used to create Windows, Web, and Console applications -Uses predefined.
Tutorial 1: An Introduction to Visual Basic.NET1 Tutorial 1 An Introduction to Visual Basic.NET.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures.
Menus,MonthCalender, DateTimePicker, MDI,Tree View, List View,
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Assignment #1 Advanced Computer Programming.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
1 Working with Menus and Dialog Boxes. 2 Objectives You will be able to Create and edit menus for Windows Forms applications. Write code to handle menu.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
COMPUTER PROGRAMMING I Objective 7.03 Apply Built-in Math Class Functions.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
VB Procedures. Procedures. Sub procedure: Private/Public Sub SubName(Arguments) … End Sub Private: Can only be accessed by procedures in the same form.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
Introduction to Visual Basic.NET Your First Visual Basic.NET Application.
VB.NET Additional Topics
Some graphics. Projects included A slideshow a dark moon moving phases of the moon billiards Your own icons and bitmaps Pie chart.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
MS Visual Basic Applications Walter Milner. Event-driven programming Standard approach for GUIs Contrast with old character interfaces – program determines.
CS0004: Introduction to Programming Project 1 – Lessons Learned.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
3.2 VB.NET Events An Event Procedure Properties and Event Procedures of the Form Tab Order of Controls Exercises.
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
1 Advanced Computer Programming Lab Calculator Project.
Created by Alia Al-Abdulkarim 2008 Visual Basic Vs. Java.
Arrays Chapter 8. Overview u General discussion u Variable arrays u Control arrays u Multi-dimensional variable arrays  Two-dimensional  Three-dimensional.
Creating Menus Menu Bar – behaves like standard Windows menus Can be used in place of or in addition to buttons to execute a procedure Menu items are controls.
Chapter 5 Menus, Sub Procedures and Sub Functions Programming In Visual Basic.NET.
Michael Olivero Microsoft Student Ambassador for FIU Pick up your free drink below to your left. 1 per person please.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
ADO.NET Objects Data Adapters Dr. Ron Eaglin. Agenda Builds on Information in Part I Should have working knowledge of creating a database connection Continuation.
Introduction to VB programming Dr. John P. Abraham UTPA Chapters 2 & 3.
Creating New Forms Projects can appear more professional when using different windows for different types of information. Select Add Windows Form from.
Visual Basic Declaring Variables Dim x as Integer = 0 In the statement above, x is being declared as an Integer (whole number) and is initialised.
Chapter 7 Multiple Forms, Modules, and Menus. Section 7.2 MODULES A module contains code—declarations and procedures—that are used by other files in a.
Computer Science Up Down Controls, Decisions and Random Numbers.
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
Programming with Microsoft Visual Basic 2012 Chapter 1: An Introduction to Visual Basic 2012.
Chapter 7, Slide 1Starting Out with Visual Basic 3 rd Edition Chapter 7 Multiple Forms, Standard Modules, And Menus.
Visual Basic Fundamental Concepts
Chapter 1: An Introduction to Visual Basic .NET
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Using Procedures and Exception Handling
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Introduction to VB programming
Visual Basic..
Chapter 13 Additional Topics in Visual Basic
GUI Programming in Visual Studio .NET
Presentation transcript:

Odds and Ends Component Tray Menu and contextmenu Splash Screen

Examples in this show Mainmenu Context menu Errorprovider Splashscreen Cellular automata

The component tray contains: Timer Errorhandlers Print capabilities DialogBoxes Menus Context menus

Adding a main menu Most apps nowadays have menus – MS powerpoint and the VB IDE both do.

Add Mainmenu to component tray from toolbox

Selecting the mainmenu control allows you to begin editing the menu

and editing…and editing

add submenus to a menu item by filling in the little box that appears below or next to it.

As with other controls, it is a good idea to rename menu items from MenuItem1,…to mnuFile, …

shortcut keys You can add shortcut keys to a menu item by selecting shortcut in the properties for this item. Select the shortcut you wish to associate with the menu item.

Ctrl-s for save

More about menus Menu items display their submenus automatically if they have them. You add itemclick subs to add functionality to menu items that have no submenu.

Save clicked event handler Private Sub mnufilesave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnufilesave.Click MessageBox.Show("save selected", "Menu", MessageBoxButtons.OK, MessageBoxIcon.Asterisk) End Sub

Clicking save in debug

Context menu A context menu is added (to the form component tray) from the toolbox. When you right-click a control information can be displayed.

Context menu

Add context menu to a control in properties

Add to context menu as you would to a regular menu

Add sub code to context

Context menu popup code Private Sub ContextMenu1_Popup(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContextMenu1.Popup MessageBox.Show("context", "context", MessageBoxButtons.OK, MessageBoxIcon.Asterisk) End Sub

Menu example exe In p:\vs\menu

Handling errors Handling errors with an errorprovider It is added to the component tray

Handling errors

Error provider An errorprovider is added to the component tray In this project the “causes validation” property of the two textboxes are both set to true Just the validation code was written – no other processing

Build error provider when form is loaded Private Sub frmmain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load errorhandler = New ErrorProvider() End Sub

Corrected one error, now have another

Another ss entry error

Finally: Corrected ss num error

Two event handlers provided – the validation for the textboxes Private Sub txtint_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtint.Validating Dim int As Integer errorhandler.SetError(txtint, "")’ clear any old errors Try int = Integer.Parse(txtint.Text) Catch ex As Exception errorhandler.SetError(txtint, "field must be int") e.Cancel = True ‘cancel event End Try End Sub

Part of ss validation Private Sub txtss_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtss.Validating ' Me.Refresh() errorhandler.SetError(txtss, "") Dim ss As String ss = txtss.Text If ss = "" Then errorhandler.SetError(txtss, "field required") e.Cancel = True ElseIf ss.Length <> 11 Then e.Cancel = True errorhandler.SetError(txtss, "field must contain 11 chars") ElseIf ss.Substring(3, 1) <> "-" Or ss.Substring(6, 1) <> "-" Then ‘’’’’there’s more End If End sub

Errorprovider example In p:\vsp\errorprovider\bin\... There is more to do with this example… like enable navigation and exit without correcting the error.

Splash screen: comes up briefly with some info when a form is loaded

Splash screens: Create a main form with just a label and exit button Add the exit code (me.close()) Add a second form to the project called frmSplash

Splash screens: On frmsplash put: Information about the application, copyright, programmer, date, pictures, whatever.

Splash screens: Add a timer with interval 5000 to the frmspash. In the timertick sub put –Me.Close() ‘close form after 5 sec Be sure to start the timer in the frmsplash load sub.

Splash screens: set topmost property to true

set frmsplash formborderstyle to fixedtool (so it can’t be resized)

Back in frmmain Add formload code to create an instance of the frmsplash. Recall this code is: Dim x as frmsplash x.show() When frmsplash loads it will start its timer. Exe in p:\vs\splash\splash.exe

Cellular automata: in p drive vb folder

Cellular automata There are many examples of uses of cellular automata, from biological modeling to designing fabric patterns. I cover only a little bit about them here. Discussion of 2-d automata Discussion of 1-d automata

One dimensional automata The original values are stored in an array. These might be generated randomly, or come from measurements. Display (in VB) might be in a panel. The “first generation” consists of a single set of rectangular colors. Each color represents an integer in the array. The next generation is computed from the first (usually) according to some formula for example: Newvalue(i)=(old(i-1)+old(i)+old(i+1)) mod maxcolors You’ll need two one dimensional arrays, and you’ll have to keep copying the new values back into the old array, and displaying.

Two dimensional automata Two d automata are displayed similarly to one-dimensional ones: each value represents a color. But each new generation is computed in two dimensions, often using some rule about how many neighbors a given cell has in the current generation.

Two dimensional automata A sketch of the code goes like this: 1.Assign initial values to a fairly large (like 100X100) array. 2.Loop a bunch of times or do on buttonclick: 3.Compute next generation values into a new array 4.Display the current generation 5.Copy next generation into current 6.endloop

Example..in p:\vb\twodcellularautomata.exe