CSC 211 Intermediate Programming

Size: px
Start display at page:

Download "CSC 211 Intermediate Programming"

Transcription

1 Introduction CSC 211 Intermediate Programming Graphical User Interface Concepts: Part 1 Graphical user interface Allow interaction with program visually Give program distinct look and feel Built from window gadgets Is an object, accessed via keyboard or mouse 1 2 Fig. 1 Introduction Button Menu Label Menu Bar Box Scrollbar Sample Internet Explorer window with GUI components. Introduction Control Description Label An area in which icons or uneditable text can be displayed. Box An area in which the user inputs data from the keyboard. The area also can display information. Button An area that triggers an event when clicked. CheckBox A GUI control that is either selected or not selected. ComboBox A drop-down list of items from which the user can make a selection, by clicking an item in the list or by typing into a box, if permitted. ListBox An area in which a list of items is displayed from which the user can make a selection by clicking once on any element. Multiple elements can be selected. Panel A container in which components can be placed. HScrollBar Allows the user to access a range of values that cannot normally fit in its container horizontally. VScrollBar Allows the user to access a range of values that cannot normally fit in its container vertically. Fig. 2 Some basic GUI components. 4 Windows Forms Create GUIs for programs Element on the desktop Represented by: Dialog Window Windows Forms Multiple Document Interface (MDI) window Windows Forms Component Class that implements IComponent interface Lacks visual parts Control Component with graphical part Such as button or label Are visible Event Generated by movement from mouse or keyboard Event handlers performs action Specifics written by programmer

2 Windows Forms Windows Forms Form Properties and Events AcceptButton Description / Delegate and Event Arguments Which button will be clicked when Enter is pressed. (Cont.) AutoScroll Whether scrollbars appear when needed (if data fill more than one screen). CancelButton FormBorderStyle Font Button that is clicked when the Escape key is pressed. Border of the form (e.g., none, single, D, sizable). Font of text displayed on the form, as well as the default font of controls added to the form. in the form s title bar. Common Methods Close Closes form and releases all resources. A closed form cannot be reopened. Hide Show Common Events Load Hides form (does not release resources). Displays a hidden form. (Delegate EventHandler, event arguments EventArgs) Occurs before a form is shown. Fig.4 Common Form properties and events. Fig. Components and controls for Windows Forms. 8 Event-Handling Model Event-Handling Model GUIs are event driven Event handlers calls Handler 1 for event E Methods that process events and perform tasks Object A raises event E calls Delegate for event E Handler 2 for event E Handler for event E Fig. Event-handling model using delegates. 10 Basic Event Handling Basic Event Handling Event name Event delegate Event argument class Fig. List of events List of Form events. Class name Fig. Details of Click event

3 Labels, Boxes es and Buttons Labels Provide text instruction Read only text Defined with class Label Derived from class Control box Class Box Area for text input Password textbox Labels, Boxes es and Buttons Button Control to trigger a specific action Checkboxes or radio buttons Derived from ButtonBase 1 14 Labels, Boxes es and Buttons Label Properties Description / Delegate and Event Arguments Font The font used by the text on the Label. The text to appear on the Label. Align The alignment of the Label s text on the control. One of three horizontal positions (left, center or right) and one of three vertical positions (top, middle or bottom). Fig. 8 Label properties. Labels, Boxes es and Buttons Box Properties Description / Delegate and Event Arguments and Events AcceptsReturn If true, pressing Enter creates a new line in text box, if that text box spans multiple lines. If false, pressing Enter clicks the default button of the form. Multiline If true, text box can span multiple lines. Default is false. PasswordChar Single character to display instead of typed text, making the text box a password box. If no character is specified, text box displays the typed text. ReadOnly If true, text box has a gray background and its text cannot be edited. Default is false. ScrollBars For multiline text boxes, indicates which scrollbars appear (none, horizontal, vertical or both). to be displayed in the text box. Common Events (Delegate EventHandler, event arguments EventArgs) Changed Raised when text changes in text box (the user added or deleted characters). Fig. Box properties and events. 1 1 Labels, Boxes es and Buttons Button properties Description / Delegate and Event Arguments and events displayed on the Button face. Common Events (Delegate EventHandler, event arguments EventArgs) Click Raised when user clicks the control. Fig. 10 Button properties and events. 1 // Fig. 12.1: 2 // Using a box, Label and Button to display // the hidden text in a password field. 4 #pragma once 8 namespace LabelBoxButtonTest { 10 using namespace System; 11 using namespace System::ComponentModel; 12 using namespace System::Collections; 1 using namespace System::Windows::Forms; 14 using namespace System::Data; 1 using namespace System::Drawing; 1 1 /// <summary> 18 /// Summary for Form1 1 /// 20 /// WARNING: If you change the name of this class, you will need to 21 /// change the Resource File Name property for the managed 22 /// resource compiler tool associated with all.resx files 2 /// this class depends on. Otherwise, the designers will not 24 /// be able to interact properly with localized resources 2 /// associated with this form. 2 /// </summary> 1 of 1 18

4 2 public gc class Form1 : public System::Windows::Forms::Form 2 System::ComponentModel::Container * components; 28 { 2 public: 4 /// <summary> 0 Form1(void) 1 { 2 InitializeComponent(); } 2 of /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> 8 void InitializeComponent(void) of 4 { protected: 0 this->displaypasswordbutton = void Dispose(Boolean disposing) 1 new System::Windows::Forms::Button(); { 2 this->inputpasswordbox = 8 if (disposing && components) new System::Windows::Forms::Box(); { 40 components->dispose(); 41 } 42 super::dispose(disposing); 4 } 44 private: System::Windows::Forms::Button * displaypasswordbutton; 4 private: System::Windows::Forms::Box * inputpasswordbox; 4 private: System::Windows::Forms::Label * displaypasswordlabel; 4 48 private: 4 /// <summary> 0 /// Required designer variable. 1 /// </summary> 4 this->displaypasswordlabel = new System::Windows::Forms::Label(); this->suspendlayout(); // 8 // displaypasswordbutton // 0 this->displaypasswordbutton->location = 1 System::Drawing::Point(, ); 2 this->displaypasswordbutton->name = S"displayPasswordButton"; this->displaypasswordbutton->size = 4 System::Drawing::Size(, 24); this->displaypasswordbutton->tabindex = 1; 1 20 this->displaypasswordbutton-> = S"Show Me"; 101 // this->displaypasswordbutton->click += new System::EventHandler( 8 this, displaypasswordbutton_click); 102 // Form1 10 // // 80 // inputpasswordbox 81 // 4 of 104 this->autoscalebasesize = System::Drawing::Size(, 1); 10 this->clientsize = System::Drawing::Size(2, 1); 10 this->controls->add(this->displaypasswordlabel); of 82 this->inputpasswordbox->location = 10 this->controls->add(this->inputpasswordbox); 8 System::Drawing::Point(1, 1); 108 this->controls->add(this->displaypasswordbutton); 84 this->inputpasswordbox->name = S"inputPasswordBox"; 10 this->name = S"Form1"; 8 this->inputpasswordbox->passwordchar = * ; 110 this-> = S"LabelBoxButtonTest"; 8 this->inputpasswordbox->size = 111 this->resumelayout(false); 8 System::Drawing::Size(24, 20); this->inputpasswordbox->tabindex = 0; 11 } 8 this->inputpasswordbox-> = S""; 0 // 1 // displaypasswordlabel 2 // this->displaypasswordlabel->borderstyle = 4 System::Windows::Forms::BorderStyle::FixedD; this->displaypasswordlabel->location = System::Drawing::Point(1, 48); this->displaypasswordlabel->name = S"displayPasswordLabel"; 8 this->displaypasswordlabel->size = // display user input on label 11 private: System::Void displaypasswordbutton_click( 11 System::Object * sender, System::EventArgs * e) 118 { 11 displaypasswordlabel-> = inputpasswordbox->; 120 } }; 12 } System::Drawing::Size(24, 2); 100 this->displaypasswordlabel->tabindex = 2; // Fig : 2 // Displaying the hidden text in a password field. #include "" #include <windows.h> GroupBoxes and Panels Arrange components on a GUI 8 using namespace LabelBoxButtonTest; GroupBoxes can display a caption property determines its caption Panels can have scrollbar 1 int ncmdshow) View additional controls inside the Panel 1 System::Threading::Thread::CurrentThread->ApartmentState = 1 System::Threading::ApartmentState::STA; 1 Application::Run(new Form1()); 1 } 2 24

5 GroupBoxes and Panels GroupBoxes and Panels GroupBox Description Properties Common Properties Controls The controls that the GroupBox contains. Common Properties (Cont.) displayed on the top portion of the GroupBox (its caption). Fig. 11 GroupBox properties. Panel Properties Description Common Properties AutoScroll Whether scrollbars appear when the Panel is too small to hold its controls. Default is false. BorderStyle Border of the Panel (default None; other options are FixedD and FixedSingle). Controls The controls that the Panel contains. Fig. 12 Panel properties. 2 2 GroupBoxes and Panels 1 // Fig : 2 // Using GroupBoxes and Panels to hold buttons. 4 #pragma once namespace GroupBoxPanelTest 1 of 4 8 { Controls inside panel panel using namespace System; 10 using namespace System::ComponentModel; 11 using namespace System::Collections; 12 using namespace System::Windows::Forms; 1 using namespace System::Data; 14 using namespace System::Drawing; 1 1 /// <summary> 1 /// Summary for Form1 18 /// panel scrollbars 1 /// WARNING: If you change the name of this class, you will need to 20 /// change the Resource File Name property for the managed 21 /// resource compiler tool associated with all.resx files 22 /// this class depends on. Otherwise, the designers will not 2 /// be able to interact properly with localized resources 24 /// associated with this form. 2 /// </summary> Fig. 1 Creating a Panel with scrollbars public gc class Form1 : public System::Windows::Forms::Form 2 { 28 public: 1 private: 2 /// <summary> /// Required designer variable. 2 Form1(void) 0 { 1 InitializeComponent(); 2 } 2 of 4 4 /// </summary> System::ComponentModel::Container * components; // Visual Studio.NET generated GUI code of protected: // event handlers to change messagelabel void Dispose(Boolean disposing) 0 { 1 // event handler for hi button if (disposing && components) 2 private: System::Void hibutton_click(system::object * sender, 8 { System::EventArgs * e) components->dispose(); 4 { 40 } messagelabel-> = S"Hi pressed"; 41 super::dispose(disposing); } 42 } 4 private: System::Windows::Forms::Label * messagelabel; 8 // event handler for bye button 44 private: System::Windows::Forms::Button * byebutton; private: System::Void byebutton_click(system::object * sender, 4 private: System::Windows::Forms::GroupBox * maingroupbox; 0 System::EventArgs * e) 4 private: System::Windows::Forms::Button * hibutton; 1 { 4 private: System::Windows::Forms::Panel * mainpanel; 2 messagelabel-> = S"Bye pressed"; 48 private: System::Windows::Forms::Button * rightbutton; } 4 private: System::Windows::Forms::Button * leftbutton;

6 // event handler for far left button private: System::Void leftbutton_click(system::object * sender, System::EventArgs * e) 1 // Fig. 12.2: 2 // GroupBox and Panel demonstration. 8 { messagelabel-> = S"Far left pressed"; 80 } 81 4 of 4 #include "" #include <windows.h> 82 // event handler for far right button 8 using namespace GroupBoxPanelTest; 8 private: System::Void rightbutton_click(system::object * sender, 84 System::EventArgs * e) 8 { 8 messagelabel-> = S"Far right pressed"; 8 } 1 int ncmdshow) 88 }; 8 } 1 System::Threading::Thread::CurrentThread->ApartmentState = 1 System::Threading::ApartmentState::STA; 1 Application::Run(new Form1()); 1 } 1 2 CheckBoxes es and RadioButtons Fig. 14 GroupBox and Panel demonstration. State buttons On/off or true/false state Derived from class ButtonBase CheckBox No restriction on usage RadioButton Grouped together Only one can be true Mutually exclusive options 4 CheckBoxes es and RadioButtons CheckBox events and Description / Delegate and Event Arguments properties Checked Whether the CheckBox has been checked. CheckState Whether the CheckBox is checked (contains a black checkmark) or unchecked (blank). An enumeration with values Checked, Unchecked or Indeterminate. displayed to the right of the CheckBox (called the label). Common Events (Delegate EventHandler, event arguments EventArgs) CheckedChanged Raised every time the CheckBox is either checked or unchecked. Default event when this control is double clicked in the designer. CheckStateChanged Raised when the CheckState property changes. Fig. 1 CheckBox properties and events. 1 // Fig. 12.2: 2 // Using CheckBoxes to toggle italic and bold styles. 4 #pragma once namespace CheckBoxTest 8 { using namespace System; 10 using namespace System::ComponentModel; 11 using namespace System::Collections; 12 using namespace System::Windows::Forms; 1 using namespace System::Data; 14 using namespace System::Drawing; 1 1 /// <summary> 1 /// Summary for Form1 18 /// 1 /// WARNING: If you change the name of this class, you will need to 20 /// change the Resource File Name property for the managed 21 /// resource compiler tool associated with all.resx files 22 /// this class depends on. Otherwise, the designers will not 2 /// be able to interact properly with localized resources 24 /// associated with this form. 2 /// </summary> 1 of

7 2 public gc class Form1 : public System::Windows::Forms::Form 2 { 28 public: 1 System::ComponentModel::Container * components; 2 // Visual Studio.NET generated GUI code 2 Form1(void) 0 { 1 InitializeComponent(); 2 } 2 of 4 // make text bold if not bold, if already bold make not bold private: System::Void boldcheckbox_checkedchanged( System::Object * sender, System::EventArgs * e) of 8 { 4 protected: outputlabel->font = new Drawing::Font( void Dispose(Boolean disposing) 0 outputlabel->font->name, outputlabel->font->size, { 1 static_cast< FontStyle >( if (disposing && components) 2 outputlabel->font->style ^ FontStyle::Bold ) ); 8 { } components->dispose(); 4 40 } // make text italic if not italic, if already italic make not italic 41 super::dispose(disposing); private: System::Void italiccheckbox_checkedchanged( 42 } System::Object * sender, System::EventArgs * e) 4 private: System::Windows::Forms::CheckBox * boldcheckbox; 8 { 44 private: System::Windows::Forms::Label * outputlabel; outputlabel->font = new Drawing::Font( 4 private: System::Windows::Forms::CheckBox * italiccheckbox; 0 outputlabel->font->name, outputlabel->font->size, 4 1 static_cast< FontStyle >( 4 private: 2 outputlabel->font->style ^ FontStyle::Italic ) ); 48 /// <summary> } 4 /// Required designer variable. 4 }; 0 /// </summary> } 8 1 // Fig : 2 // CheckBox demonstration. #include "" #include <windows.h> 8 using namespace CheckBoxTest; 1 int ncmdshow) 1 System::Threading::Thread::CurrentThread->ApartmentState = 1 System::Threading::ApartmentState::STA; 1 Application::Run(new Form1()); 1 } 40 CheckBoxes es and RadioButtons RadioButton Description / Delegate and Event Arguments properties and events Checked Specifies whether the radio button is checked. displayed to the right of the radio button (called the label). Common Events (Delegate EventHandler, event arguments EventArgs) Click Raised when user clicks the control. CheckedChanged Raised every time the radio button is checked or unchecked. Fig. 1 RadioButton properties and events. 1 // Fig. 12.0: 2 // Using RadioButtons to set message window options. 4 #pragma once namespace RadioButtonTest 8 { using namespace System; 10 using namespace System::ComponentModel; 11 using namespace System::Collections; 12 using namespace System::Windows::Forms; 1 using namespace System::Data; 14 using namespace System::Drawing; 1 1 /// <summary> 1 /// Summary for Form1 18 /// 1 /// WARNING: If you change the name of this class, you will need to 20 /// change the Resource File Name property for the managed 21 /// resource compiler tool associated with all.resx files 22 /// this class depends on. Otherwise, the designers will not 2 /// be able to interact properly with localized resources 24 /// associated with this form. 2 /// </summary> 1 of 41 42

8 2 public gc class Form1 : public System::Windows::Forms::Form 2 { 28 public: 1 private: System::Windows::Forms::RadioButton * questionbutton; 2 private: System::Windows::Forms::RadioButton * informationbutton; private: System::Windows::Forms::RadioButton * exclamationbutton; 2 Form1(void) 0 { 1 InitializeComponent(); 2 } 2 of 4 private: System::Windows::Forms::RadioButton * errorbutton; private: System::Windows::Forms::Label * displaylabel; private: System::Windows::Forms::Button * displaybutton; private: System::Windows::Forms::Label * promptlabel; of 8 4 protected: private: static MessageBoxIcon icontype = MessageBoxIcon::Error; void Dispose(Boolean disposing) 0 private: static MessageBoxButtons buttontype = MessageBoxButtons::OK; { 1 if (disposing && components) 2 private: 8 { /// <summary> components->dispose(); 4 /// Required designer variable. 40 } 41 super::dispose(disposing); 42 } 4 private: System::Windows::Forms::GroupBox * buttontypegroupbox; 44 private: System::Windows::Forms::RadioButton * retrycancelbutton; 4 private: System::Windows::Forms::RadioButton * yesnobutton; 4 private: System::Windows::Forms::RadioButton * yesnocancelbutton; 4 private: System::Windows::Forms::RadioButton * abortretryignorebutton; 48 private: System::Windows::Forms::RadioButton * okcancelbutton; 4 private: System::Windows::Forms::RadioButton * okbutton; 0 private: System::Windows::Forms::GroupBox * icontypegroupbox; /// </summary> System::ComponentModel::Container * components; 8 // Visual Studio.NET generated GUI code 0 // change button based on option chosen by sender 1 private: System::Void buttontype_checkedchanged( 2 System::Object * sender, System::EventArgs * e) { 4 if ( sender == okbutton ) // display OK button buttontype = MessageBoxButtons::OK; 4 44 // display OK and Cancel buttons 8 else if ( sender == okcancelbutton ) 8 // change icon based on option chosen by sender private: System::Void icontype_checkedchanged( 100 System::Object * sender, System::EventArgs * e) buttontype = MessageBoxButtons::OKCancel; // display Abort, Retry and Ignore buttons 4 of 101 { 102 if ( sender == errorbutton ) // display error icon 10 icontype = MessageBoxIcon::Error; of 82 else if ( sender == abortretryignorebutton ) buttontype = MessageBoxButtons::AbortRetryIgnore; 10 // display exclamation point else if ( sender == exclamationbutton ) 8 // display Yes, No and Cancel buttons 10 icontype = MessageBoxIcon::Exclamation; 8 else if ( sender == yesnocancelbutton ) buttontype = MessageBoxButtons::YesNoCancel; 10 // display information icon else if ( sender == informationbutton ) 8 // display Yes and No buttons 111 icontype = MessageBoxIcon::Information; 0 else if ( sender == yesnobutton ) buttontype = MessageBoxButtons::YesNo; 11 else // only one option left--display question mark icontype = MessageBoxIcon::Question; // only one option left--display Retry and Cancel buttons 11 } // end method icontype_checkedchanged 4 else 11 buttontype = MessageBoxButtons::RetryCancel; 11 // display MessageBox and button user pressed } // end method buttontype_checkedchanged 118 private: System::Void displaybutton_click( 11 System::Object * sender, System::EventArgs * e) 120 { 121 DialogResult = MessageBox::Show( 122 S"This is Your Custom MessageBox.", 12 S"Custom MessageBox", buttontype, icontype ); // check for dialog result and display it in label 12 switch ( DialogResult ) { 148 case DialogResult::Yes: 14 displaylabel-> = S"Yes was pressed."; 10 break; case DialogResult::OK: 12 displaylabel-> = S"OK was pressed."; of case DialogResult::No: 1 displaylabel-> = S"No was pressed."; of 10 break; 14 break; 11 1 } // end switch 12 case DialogResult::Cancel: 1 } // end method displaybutton_click 1 displaylabel-> = S"Cancel was pressed."; 1 }; 14 break; 18 } 1 1 case DialogResult::Abort: 1 displaylabel-> = S"Abort was pressed."; 18 break; case DialogResult::Retry: 141 displaylabel-> = S"Retry was pressed."; 142 break; case DialogResult::Ignore: 14 displaylabel-> = S"Ignore was pressed."; 14 break;

9 1 // Fig. 12.1: 2 // RadioButton demonstration. #include "" #include <windows.h> 8 using namespace RadioButtonTest; 1 int ncmdshow) 1 System::Threading::Thread::CurrentThread->ApartmentState = 1 System::Threading::ApartmentState::STA; 1 Application::Run(new Form1()); 1 } Exclamation icon type Error icon type OKCancel button type OK button type 4 0 Information icon type AbortRetryIgnore button type Question icon type YesNoCancel button type Class PictureBox Displays an image PictureBoxes es Image set by object of class Image. The Image property sets the Image object to use SizeMode property sets how the image is displayed YesNo button type RetryCancel button type 1 2 PictureBox properties and events Image SizeMode PictureBoxes es Description / Delegate and Event Arguments Image to display in the picture box. Gets value from enumeration PictureBoxSizeMode that controls image sizing and positioning. Values Normal (default), StretchImage, AutoSize and CenterImage. Normal puts image in top-left corner of picture box, and CenterImage puts image in middle. (Both cut off image if too large.) StretchImage resizes image to fit in picture box. AutoSize resizes picture box to hold image. Common Events (Delegate EventHandler, event arguments EventArgs) Click Raised when user clicks the control. Fig. 1 PictureBox properties and events. 1 // Fig. 12.: 2 // Using a PictureBox to display images. 4 #pragma once namespace PictureBoxTest 8 { using namespace System; 10 using namespace System::ComponentModel; 11 using namespace System::Collections; 12 using namespace System::Windows::Forms; 1 using namespace System::Data; 14 using namespace System::Drawing; 1 using namespace System::IO; 1 1 /// <summary> 18 /// Summary for Form1 1 /// 20 /// WARNING: If you change the name of this class, you will need to 21 /// change the Resource File Name property for the managed 22 /// resource compiler tool associated with all.resx files 2 /// this class depends on. Otherwise, the designers will not 24 /// be able to interact properly with localized resources 2 /// associated with this form. 1 of 4

10 2 /// </summary> 2 public gc class Form1 : public System::Windows::Forms::Form 28 { 0 /// <summary> 1 /// Required designer variable. 2 /// </summary> 2 public: 0 Form1(void) 1 { 2 InitializeComponent(); 2 of System::ComponentModel::Container * components; 4 // Visual Studio.NET generated GUI code of } // change image whenever PictureBox clicked 4 8 private: System::Void imagepicturebox_click( protected: System::Object * sender,system::eventargs * e) void Dispose(Boolean disposing) 0 { { 1 imagenum = ( imagenum + 1 ) % ; // imagenum from 0 to 2 8 if (disposing && components) 2 { // create Image object from file, display on PictureBox 40 components->dispose(); 41 } 42 super::dispose(disposing); 4 } 44 private: System::Windows::Forms::Label * promptlabel; 4 private: System::Windows::Forms::PictureBox * imagepicturebox; 4 4 imagepicturebox->image = Image::FromFile( String::Concat( Directory::GetCurrentDirectory(), S"\\images\\image", imagenum.tostring(), S".bmp" ) ); } 8 }; } 4 private: static int imagenum = -1; 48 4 private: 1 // Fig. 12.4: 2 // PictureBox demonstration. #include "" #include <windows.h> 8 using namespace PictureBoxTest; 1 int ncmdshow) 1 System::Threading::Thread::CurrentThread->ApartmentState = 1 System::Threading::ApartmentState::STA; 1 Application::Run(new Form1()); 1 } Mouse Event Handling Class MouseEventArgs Contain coordinates of the mouse pointer The mouse pressed Number of clicks Number of notches the wheel turned Passing mouse event Mouse event-handling methods take an object and MouseEventArgs object as argument The Click event uses delegate EventHandler and event arguments EventArgs 8 Mouse Events, Delegates and Event Arguments Mouse Events (Delegate EventHandler, event arguments EventArgs) MouseEnter MouseLeave Mouse Events (Delegate MouseEventHandler, event arguments MouseEventArgs) MouseDown MouseHover MouseMove MouseUp Class MouseEventArgs Properties Button Clicks Mouse Event Handling Raised if the mouse cursor enters the area of the control. Raised if the mouse cursor leaves the area of the control. Raised if the mouse button (either mouse button) is pressed while its cursor is over the area of the control. Raised if the mouse cursor hovers over the area of the control. Raised if the mouse cursor is moved while in the area of the control. Raised if the mouse button (either mouse button) is released when the cursor is over the area of the control. Mouse button that was pressed (left, right, middle or none). The number of times the mouse button (either mouse button) was clicked. X The x-coordinate of the event, relative to the control. Y The y-coordinate of the event, relative to the control. Fig. 18 Mouse events, delegates and event arguments. 1 // Fig. 12.: 2 // Using the mouse to draw on a form. 4 #pragma once namespace PainterTest 8 { using namespace System; 10 using namespace System::ComponentModel; 11 using namespace System::Collections; 12 using namespace System::Windows::Forms; 1 using namespace System::Data; 14 using namespace System::Drawing; 1 1 /// <summary> 1 /// Summary for Form1 18 /// 1 /// WARNING: If you change the name of this class, you will need to 20 /// change the Resource File Name property for the managed 21 /// resource compiler tool associated with all.resx files 22 /// this class depends on. Otherwise, the designers will not 2 /// be able to interact properly with localized resources 24 /// associated with this form. 2 /// </summary> 1 of 4 0

11 2 public gc class Form1 : public System::Windows::Forms::Form 2 { 28 public: 1 2 // Visual Studio.NET generated GUI code 2 Form1(void) 0 { 1 InitializeComponent(); 2 of 4 4 // should paint after mouse button has been pressed private: System::Void Form1_MouseDown(System::Object * sender, System::Windows::Forms::MouseEventArgs * e) of 4 2 } { 8 shouldpaint = true; 4 protected: } void Dispose(Boolean disposing) 0 { 1 // stop painting when mouse button released if (disposing && components) 2 private: System::Void Form1_MouseUp(System::Object * sender, 8 { System::Windows::Forms::MouseEventArgs * e) components->dispose(); 4 { 40 } shouldpaint = false; 41 super::dispose(disposing); } 42 } 4 44 private: static bool shouldpaint = false; // whether to paint 4 4 private: 4 /// <summary> 48 /// Required designer variable. 4 /// </summary> 0 System::ComponentModel::Container * components; // draw circle whenever mouse button moves (and mouse is down) private: System::Void Form1_MouseMove(System::Object * sender, 0 System::Windows::Forms::MouseEventArgs * e) 1 // Fig. 12.: 2 // Mouse event handling demonstration. 1 { 2 if ( shouldpaint ) { Graphics *graphics = CreateGraphics(); 4 graphics->fillellipse( new SolidBrush( 4 of 4 #include "" #include <windows.h> Color::BlueViolet ), e->x, e->y, 4, 4 ); 8 using namespace PainterTest; } // end if } 8 }; } 1 int ncmdshow) 1 System::Threading::Thread::CurrentThread->ApartmentState = 1 System::Threading::ApartmentState::STA; 1 Application::Run(new Form1()); 1 } 4 Keyboard Event Handling Key events Control that inherits from System::Windows::Forms::Control Delegate KeyPressEventHandler Event argument KeyPressEventArgs KeyPress ASCII character pressed No modifier keys Delegate KeyEventHandler Event argument KeyEventArgs KeyUp or KeyDown Special modifier keys Key enumeration value Keyboard Event Handling Keyboard Events, Delegates and Event Arguments Key Events (Delegate KeyEventHandler, event arguments KeyEventArgs) KeyDown Raised when key is initially pushed down. KeyUp Raised when key is released. Key Events (Delegate KeyPressEventHandler, event arguments KeyPressEventArgs) KeyPress Raised when key is pressed. Occurs repeatedly while key is held down, at a rate specified by the operating system. Class KeyPressEventArgs Properties KeyChar Returns the ASCII character for the key pressed. Handled Indicates whether the KeyPress event was handled (i.e., has an event handler associated with it). Class KeyEventArgs Properties Alt Indicates whether the Alt key was pressed. Control Indicates whether the Control key was pressed. Shift Indicates whether the Shift key was pressed. Fig. 1 Keyboard events, delegates and event arguments. (1 of 2)

12 Keyboard Event Handling Handled Indicates whether the event was handled (i.e., has an event handler associated with it). KeyCode Returns the key code for the key, as a Keys enumeration. This does not include modifier key information. Used to test for a specific key. KeyData Returns the key code as a Keys enumeration, combined with modifier information. Used to determine all information about the key pressed. KeyValue Returns the key code as an int, rather than as a Keys enumeration. Used to obtain a numeric representation of the key pressed. Modifiers Returns a Keys enumeration for any modifier keys pressed (Alt, Control and Shift). Used to determine modifier key information only. Fig. 20 Keyboard events, delegates and event arguments. Fig. 20 Keyboard events, delegates and event arguments. (2 of 2) 1 // Fig. 12.: 2 // Displaying information about the key the user pressed. 4 #pragma once namespace KeyDemoTest 8 { using namespace System; 10 using namespace System::ComponentModel; 11 using namespace System::Collections; 12 using namespace System::Windows::Forms; 1 using namespace System::Data; 14 using namespace System::Drawing; 1 1 /// <summary> 1 /// Summary for Form1 18 /// 1 /// WARNING: If you change the name of this class, you will need to 20 /// change the Resource File Name property for the managed 21 /// resource compiler tool associated with all.resx files 22 /// this class depends on. Otherwise, the designers will not 2 /// be able to interact properly with localized resources 24 /// associated with this form. 2 /// </summary> 1 of public gc class Form1 : public System::Windows::Forms::Form 2 { 28 public: 1 2 // Visual Studio.NET generated GUI code 2 Form1(void) 0 { 1 InitializeComponent(); 2 of 4 4 // display the name of the pressed key private: System::Void Form1_KeyPress(System::Object * sender, System::Windows::Forms::KeyPressEventArgs * e) of 4 2 } { 8 charlabel-> = String::Concat( S"Key pressed: ", 4 protected: ( e->keychar ).ToString() ); void Dispose(Boolean disposing) 0 } { 1 if (disposing && components) 2 // display modifier keys, key code, key data and key value 8 { private: System::Void Form1_KeyDown(System::Object * sender, components->dispose(); 4 System::Windows::Forms::KeyEventArgs * e) 40 } { 41 super::dispose(disposing); keyinfolabel-> = String::Concat( 42 } S"Alt: ", ( e->alt? S"Yes" : S"No" ), S"\n", 4 private: System::Windows::Forms::Label * charlabel; 8 S"Shift: ", ( e->shift? S"Yes" : S"No" ), S"\n", 44 private: System::Windows::Forms::Label * keyinfolabel; S"Ctrl: ", ( e->control? S"Yes" : S"No" ), S"\n", 4 0 S"KeyCode: ", box( e->keycode ), S"\n", 4 private: 1 S"KeyData: ", box( e->keydata ), S"\n", 4 /// <summary> 2 S"KeyValue: ", e->keyvalue ); 48 /// Required designer variable. } 4 /// </summary> 4 0 System::ComponentModel::Container * components; 0 // clear labels when key released private: System::Void Form1_KeyUp(System::Object * sender, System::Windows::Forms::KeyEventArgs * e) 1 // Fig : 2 // Keyboard event handling demonstration. 8 { keyinfolabel-> = S""; 80 charlabel-> = S""; 4 of 4 #include "" #include <windows.h> 81 } 82 }; 8 using namespace KeyDemoTest; 8 } 1 int ncmdshow) 1 System::Threading::Thread::CurrentThread->ApartmentState = 1 System::Threading::ApartmentState::STA; 1 Application::Run(new Form1()); 1 } 1 2

13

Chapter 12 - Graphical User Interface Concepts: Part 1

Chapter 12 - Graphical User Interface Concepts: Part 1 Chapter 12 - Graphical User Interface Concepts: Part 1 1 12.1 Introduction 12.2 Windows Forms 12.3 Event-Handling Model 12.3.1 Basic Event Handling 12.4 Control Properties and Layout 12.5 Labels, TextBoxes

More information

1. Windows Forms 2. Event-Handling Model 3. Basic Event Handling 4. Control Properties and Layout 5. Labels, TextBoxes and Buttons 6.

1. Windows Forms 2. Event-Handling Model 3. Basic Event Handling 4. Control Properties and Layout 5. Labels, TextBoxes and Buttons 6. C# cont d (C-sharp) (many of these slides are extracted and adapted from Deitel s book and slides, How to Program in C#. They are provided for CSE3403 students only. Not to be published or publicly distributed

More information

namespace Tst_Form { private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components;

namespace Tst_Form { private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; Exercise 9.3 In Form1.h #pragma once #include "Form2.h" Add to the beginning of Form1.h #include #include For srand() s input parameter namespace Tst_Form using namespace System; using

More information

Events. Event Handler Arguments 12/12/2017. EEE-425 Programming Languages (2016) 1

Events. Event Handler Arguments 12/12/2017. EEE-425 Programming Languages (2016) 1 Events Events Single Event Handlers Click Event Mouse Events Key Board Events Create and handle controls in runtime An event is something that happens. Your birthday is an event. An event in programming

More information

Managed C++ and.net Development STEPHEN R. G. FRASER

Managed C++ and.net Development STEPHEN R. G. FRASER Managed C++ and.net Development STEPHEN R. G. FRASER Managed C++ and.net Development Copyright 2003 by Stephen R. G. Fraser All rights reserved. No part of this work may be reproduced or transmitted in

More information

Lampiran B. Program pengendali

Lampiran B. Program pengendali Lampiran B Program pengendali #pragma once namespace serial using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms;

More information

CST242 Windows Forms with C# Page 1

CST242 Windows Forms with C# Page 1 CST242 Windows Forms with C# Page 1 1 2 4 5 6 7 9 10 Windows Forms with C# CST242 Visual C# Windows Forms Applications A user interface that is designed for running Windows-based Desktop applications A

More information

Overview Describe the structure of a Windows Forms application Introduce deployment over networks

Overview Describe the structure of a Windows Forms application Introduce deployment over networks Windows Forms Overview Describe the structure of a Windows Forms application application entry point forms components and controls Introduce deployment over networks 2 Windows Forms Windows Forms are classes

More information

Philadelphia University Faculty of Information Technology. Visual Programming

Philadelphia University Faculty of Information Technology. Visual Programming Philadelphia University Faculty of Information Technology Visual Programming Using C# -Work Sheets- Prepared by: Dareen Hamoudeh Eman Al Naji Work Sheet 1 Form, Buttons and labels Properties Changing properties

More information

Visual Studio.NET enables quick, drag-and-drop construction of form-based applications

Visual Studio.NET enables quick, drag-and-drop construction of form-based applications Visual Studio.NET enables quick, drag-and-drop construction of form-based applications Event-driven, code-behind programming Visual Studio.NET WinForms Controls Part 1 Event-driven, code-behind programming

More information

Convertor Binar -> Zecimal Rosu Alin, Calculatoare, An2 Mod de Functionare: Am creat un program, in Windows Form Application, care converteste un

Convertor Binar -> Zecimal Rosu Alin, Calculatoare, An2 Mod de Functionare: Am creat un program, in Windows Form Application, care converteste un Convertor Binar -> Zecimal Rosu Alin, Calculatoare, An2 Mod de Functionare: Am creat un program, in Windows Form Application, care converteste un numar binar, in numar zecimal. Acest program are 4 numericupdown-uri

More information

1 Dept: CE.NET Programming ( ) Prof. Akash N. Siddhpura. Working with Form: properties, methods and events

1 Dept: CE.NET Programming ( ) Prof. Akash N. Siddhpura. Working with Form: properties, methods and events Working with Form: properties, methods and events To create a New Window Forms Application, Select File New Project. It will open one dialog box which is shown in Fig 2.1. Fig 2.1 The New Project dialog

More information

Inheriting Windows Forms with Visual C#.NET

Inheriting Windows Forms with Visual C#.NET Inheriting Windows Forms with Visual C#.NET Overview In order to understand the power of OOP, consider, for example, form inheritance, a new feature of.net that lets you create a base form that becomes

More information

How to Use MessageBox

How to Use MessageBox How to Use MessageBox Contents MessageBox Class... 1 Use MessageBox without checking result... 4 Check MessageBox Return Value... 8 Use a property to save MessageBox return... 9 Check MessageBox return

More information

Chapter 13: Handling Events

Chapter 13: Handling Events Chapter 13: Handling Events Event Handling Event Occurs when something interesting happens to an object Used to notify a client program when something happens to a class object the program is using Event

More information

#pragma comment(lib, "irrklang.lib") #include <windows.h> namespace SuperMetroidCraft {

#pragma comment(lib, irrklang.lib) #include <windows.h> namespace SuperMetroidCraft { Downloaded from: justpaste.it/llnu #pragma comment(lib, "irrklang.lib") #include namespace SuperMetroidCraft using namespace System; using namespace System::ComponentModel; using namespace

More information

EEE-425 Programming Languages (2013) 1

EEE-425 Programming Languages (2013) 1 2 System.Drawing Namespace System.Windows.Forms Namespace Creating forms applications by hand Creating forms applications using Visual Studio designer Windows applications also look different from console

More information

EEE-425 Programming Languages (2013) 1

EEE-425 Programming Languages (2013) 1 2 System.Drawing Namespace System.Windows.Forms Namespace Creating forms applications by hand Creating forms applications using Visual Studio designer Windows applications also look different from console

More information

Operatii pop si push-stiva

Operatii pop si push-stiva Operatii pop si push-stiva Aplicatia realizata in Microsoft Visual Studio C++ 2010 permite simularea operatiilor de introducere si extragere a elementelor dintr-o structura de tip stiva.pentru aceasta

More information

Tutorial 5 Completing the Inventory Application Introducing Programming

Tutorial 5 Completing the Inventory Application Introducing Programming 1 Tutorial 5 Completing the Inventory Application Introducing Programming Outline 5.1 Test-Driving the Inventory Application 5.2 Introduction to C# Code 5.3 Inserting an Event Handler 5.4 Performing a

More information

Programming. C# Programming: From Problem Analysis to Program Design 2nd Edition. David McDonald, Ph.D. Director of Emerging Technologies

Programming. C# Programming: From Problem Analysis to Program Design 2nd Edition. David McDonald, Ph.D. Director of Emerging Technologies 9 Programming Based on Events C# Programming: From Problem Analysis to Program Design 2nd Edition David McDonald, Ph.D. Director of Emerging Technologies Chapter Objectives Create applications that use

More information

//filename.cs using System; using System.Windows.Forms; [STAThread] public static void Main() { Application.Run(new Form1()); } }

//filename.cs using System; using System.Windows.Forms; [STAThread] public static void Main() { Application.Run(new Form1()); } } Lecture #10 Introduction Hand-Coding Windows Forms Applications The.NET Framework provide tools and components, such as dialog boxes, menus, buttons, and many other controls, that make up a standard Windows

More information

ListBox. Class ListBoxTest. Allows users to add and remove items from ListBox Uses event handlers to add to, remove from, and clear list

ListBox. Class ListBoxTest. Allows users to add and remove items from ListBox Uses event handlers to add to, remove from, and clear list C# cont d (C-sharp) (many of these slides are extracted and adapted from Deitel s book and slides, How to Program in C#. They are provided for CSE3403 students only. Not to be published or publicly distributed

More information

Classes in C# namespace classtest { public class myclass { public myclass() { } } }

Classes in C# namespace classtest { public class myclass { public myclass() { } } } Classes in C# A class is of similar function to our previously used Active X components. The difference between the two is the components are registered with windows and can be shared by different applications,

More information

Introductionto the Visual Basic Express 2008 IDE

Introductionto the Visual Basic Express 2008 IDE 2 Seeing is believing. Proverb Form ever follows function. Louis Henri Sullivan Intelligence is the faculty of making artificial objects, especially tools to make tools. Henri-Louis Bergson Introductionto

More information

Full file at

Full file at T U T O R I A L 3 Objectives In this tutorial, you will learn to: Set the text in the Form s title bar. Change the Form s background color. Place a Label control on the Form. Display text in a Label control.

More information

Unit-1. Components of.net Framework. 1. Introduction to.net Framework

Unit-1. Components of.net Framework. 1. Introduction to.net Framework 1 Unit-1 1. Introduction to.net Framework The.NET framework is a collection of all the tools and utilities required to execute the.net managed applications on a particular platform. The MS.NET framework

More information

Dive Into Visual C# 2010 Express

Dive Into Visual C# 2010 Express Dive Into Visual C# 2010 Express 2 Seeing is believing. Proverb Form ever follows function. Louis Henri Sullivan Intelligence is the faculty of making artificial objects, especially tools to make tools.

More information

Full file at https://fratstock.eu Programming in Visual Basic 2010

Full file at https://fratstock.eu Programming in Visual Basic 2010 OBJECTIVES: Chapter 2 User Interface Design Upon completion of this chapter, your students will be able to 1. Use text boxes, masked text boxes, rich text boxes, group boxes, check boxes, radio buttons,

More information

Lucrare pentru colocviu de practică

Lucrare pentru colocviu de practică Roman Radu-Alexandru Calculatoare an II Lucrare pentru colocviu de practică Descriere: Aplicatia are ca scop functionalitatea unui decodificator si a unui codificator. Converteste un numar din zecimal

More information

Philadelphia University Faculty of Information Technology. Visual Programming. Using C# -Work Sheets-

Philadelphia University Faculty of Information Technology. Visual Programming. Using C# -Work Sheets- Philadelphia University Faculty of Information Technology Visual Programming Using C# -Work Sheets- Prepared by: Dareen Hamoudeh Eman Al Naji 2018 Work Sheet 1 Hello World! 1. Create a New Project, Name

More information

Controls. By the end of this chapter, student will be able to:

Controls. By the end of this chapter, student will be able to: Controls By the end of this chapter, student will be able to: Recognize the (Properties Window) Adjust the properties assigned to Controls Choose the appropriate Property Choose the proper value for the

More information

Flag Quiz Application

Flag Quiz Application T U T O R I A L 17 Objectives In this tutorial, you will learn to: Create and initialize arrays. Store information in an array. Refer to individual elements of an array. Sort arrays. Use ComboBoxes to

More information

Dive Into Visual C# 2008 Express

Dive Into Visual C# 2008 Express 1 2 2 Dive Into Visual C# 2008 Express OBJECTIVES In this chapter you will learn: The basics of the Visual Studio Integrated Development Environment (IDE) that assists you in writing, running and debugging

More information

Visual Programming (761220) First Exam First Semester of Date: I Time: 60 minutes

Visual Programming (761220) First Exam First Semester of Date: I Time: 60 minutes Philadelphia University Lecturer : Mrs. Eman Alnaji Coordinator : Miss. Reem AlQaqa Internal Examiner: Dr. Nameer Al Emam Faculty of Information Technology Department of CIS Examination Paper Visual Programming

More information

Chapter 6 Dialogs. Creating a Dialog Style Form

Chapter 6 Dialogs. Creating a Dialog Style Form Chapter 6 Dialogs We all know the importance of dialogs in Windows applications. Dialogs using the.net FCL are very easy to implement if you already know how to use basic controls on forms. A dialog is

More information

Chapter 2. Ans. C (p. 55) 2. Which is not a control you can find in the Toolbox? A. Label B. PictureBox C. Properties Window D.

Chapter 2. Ans. C (p. 55) 2. Which is not a control you can find in the Toolbox? A. Label B. PictureBox C. Properties Window D. Chapter 2 Multiple Choice 1. According to the following figure, which statement is incorrect? A. The size of the selected object is 300 pixels wide by 300 pixels high. B. The name of the select object

More information

Chapter 2. Creating Applications with Visual Basic Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of

Chapter 2. Creating Applications with Visual Basic Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 2 Creating Applications with Visual Basic Addison Wesley is an imprint of 2011 Pearson Addison-Wesley. All rights reserved. Section 2.1 FOCUS ON PROBLEM SOLVING: BUILDING THE DIRECTIONS APPLICATION

More information

CHAPTER 3. Writing Windows C# Programs. Objects in C#

CHAPTER 3. Writing Windows C# Programs. Objects in C# 90 01 pp. 001-09 r5ah.ps 8/1/0 :5 PM Page 9 CHAPTER 3 Writing Windows C# Programs 5 9 Objects in C# The C# language has its roots in C++, Visual Basic, and Java. Both C# and VB.Net use the same libraries

More information

Interface Design in C#

Interface Design in C# Interface Design in C# Project 1: Copy text from TextBox to Label as shown in the figure. TextBox and Label have the same property: display.text = nameentry.text; private void nameentry_textchanged display.text

More information

Visual BASIC Creating an Application. Choose File New Project from the menu

Visual BASIC Creating an Application. Choose File New Project from the menu Creating an Application Choose File New Project from the menu Choose Windows Application Name the project Copyright Project Place a check in the Create directory for solution box Click Browse Choose and/or

More information

Full file at Chapter 2: Creating a User Interface

Full file at   Chapter 2: Creating a User Interface Chapter 2: Creating a User Interface TRUE/FALSE 1. Text boxes accept and display information automatically, so no special event is necessary for them to do their assigned task. T PTS: 1 REF: 84 2. A button

More information

1. Introduction The idea of the traditional programming

1. Introduction The idea of the traditional programming 1. Introduction The way of programming differs a lot depending on a programmer using a traditional way of programming or if she/he uses a graphical environment for creating a program. 1.1. The idea of

More information

Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic

Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic Outline 6.1 Test-Driving the Enhanced Inventory Application 6.2 Variables 6.3 Handling the TextChanged

More information

(conditional test) (action if true) It is common to place the above selection statement in an If block, as follows:

(conditional test) (action if true) It is common to place the above selection statement in an If block, as follows: Making Decisions O NE OF THE MOST IMPORTANT THINGS that computers can do is to make decisions based on a condition, and then take an action based on that decision. In this respect, computers react almost

More information

User-Defined Controls

User-Defined Controls C# cont d (C-sharp) (many of these slides are extracted and adapted from Deitel s book and slides, How to Program in C#. They are provided for CSE3403 students only. Not to be published or publicly distributed

More information

#using <System.dll> #using <System.Windows.Forms.dll> #using <System.Drawing.dll>

#using <System.dll> #using <System.Windows.Forms.dll> #using <System.Drawing.dll> Lecture #9 Introduction Anatomy of Windows Forms application Hand-Coding Windows Form Applications Although Microsoft Visual Studio makes it much easier for developers to create Windows Forms applications,

More information

Chapter 12: Using Controls

Chapter 12: Using Controls Chapter 12: Using Controls Examining the IDE s Automatically Generated Code A new Windows Forms project has been started and given the name FormWithALabelAndAButton A Label has been dragged onto Form1

More information

Programming in C# Project 1:

Programming in C# Project 1: Programming in C# Project 1: Set the text in the Form s title bar. Change the Form s background color. Place a Label control on the Form. Display text in a Label control. Place a PictureBox control on

More information

Visual C# Program: Simple Game 3

Visual C# Program: Simple Game 3 C h a p t e r 6C Visual C# Program: Simple Game 3 In this chapter, you will learn how to use the following Visual C# Application functions to World Class standards: Opening Visual C# Editor Beginning a

More information

Lesson 04. Control Structures I : Decision Making. MIT 31043, VISUAL PROGRAMMING By: S. Sabraz Nawaz

Lesson 04. Control Structures I : Decision Making. MIT 31043, VISUAL PROGRAMMING By: S. Sabraz Nawaz Lesson 04 Control Structures I : Decision Making MIT 31043, VISUAL PROGRAMMING Senior Lecturer in MIT Department of MIT Faculty of Management and Commerce South Eastern University of Sri Lanka Decision

More information

EPSON RC+ 7.0 Option. GUI Builder 7.0 EM145A2719F. Rev. 2

EPSON RC+ 7.0 Option. GUI Builder 7.0 EM145A2719F. Rev. 2 EPSON RC+ 7.0 Option GUI Builder 7.0 Rev. 2 EM145A2719F EPSON RC+ 7.0 Option GUI Builder 7.0 Rev.2 EPSON RC+ 7.0 Option GUI Builder 7.0 Rev.2 Copyright 2012-2014 SEIKO EPSON CORPORATION. All rights reserved.

More information

Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects

Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects 1 Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline 19.1 Test-Driving the Microwave Oven Application 19.2 Designing the Microwave Oven Application 19.3 Adding a New

More information

MenuStrip Control. The MenuStrip control represents the container for the menu structure.

MenuStrip Control. The MenuStrip control represents the container for the menu structure. MenuStrip Control The MenuStrip control represents the container for the menu structure. The MenuStrip control works as the top-level container for the menu structure. The ToolStripMenuItem class and the

More information

C# and.net (1) cont d

C# and.net (1) cont d C# and.net (1) cont d Acknowledgements and copyrights: these slides are a result of combination of notes and slides with contributions from: Michael Kiffer, Arthur Bernstein, Philip Lewis, Hanspeter Mφssenbφck,

More information

You can call the project anything you like I will be calling this one project slide show.

You can call the project anything you like I will be calling this one project slide show. C# Tutorial Load all images from a folder Slide Show In this tutorial we will see how to create a C# slide show where you load everything from a single folder and view them through a timer. This exercise

More information

TuneTown Lab Instructions

TuneTown Lab Instructions TuneTown Lab Instructions Purpose: Practice creating a modal dialog. Incidentally, learn to use a list view control. Credit: This program was designed by Jeff Prosise and published in MSDN Magazine. However,

More information

Introduction to the Visual Studio.NET Integrated Development Environment IDE. CSC 211 Intermediate Programming

Introduction to the Visual Studio.NET Integrated Development Environment IDE. CSC 211 Intermediate Programming Introduction to the Visual Studio.NET Integrated Development Environment IDE CSC 211 Intermediate Programming Visual Studio.NET Integrated Development Environment (IDE) The Start Page(Fig. 1) Helpful links

More information

Chapter 8 Advanced GUI Features

Chapter 8 Advanced GUI Features 159 Chapter 8 Advanced GUI Features There are many other features we can easily add to a Windows C# application. We must be able to have menus and dialogs along with many other controls. One workhorse

More information

CIS 3260 Intro. to Programming with C#

CIS 3260 Intro. to Programming with C# Running Your First Program in Visual C# 2008 McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Run Visual Studio Start a New Project Select File/New/Project Visual C# and Windows must

More information

Recommended GUI Design Standards

Recommended GUI Design Standards Recommended GUI Design Standards Page 1 Layout and Organization of Your User Interface Organize the user interface so that the information follows either vertically or horizontally, with the most important

More information

This is the start of the server code

This is the start of the server code This is the start of the server code using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Net; using System.Net.Sockets;

More information

Contents. Using Interpreters... 5 Using Compilers... 5 Program Development Life Cycle... 6

Contents. Using Interpreters... 5 Using Compilers... 5 Program Development Life Cycle... 6 Contents ***Introduction*** Introduction to Programming... 1 Introduction... 2 What is a Program?... 2 Role Played by a Program to Perform a Task... 2 What is a Programming Language?... 3 Types of Programming

More information

Click on the empty form and apply the following options to the properties Windows.

Click on the empty form and apply the following options to the properties Windows. Start New Project In Visual Studio Choose C# Windows Form Application Name it SpaceInvaders and Click OK. Click on the empty form and apply the following options to the properties Windows. This is the

More information

Responding to the Mouse

Responding to the Mouse Responding to the Mouse The mouse has two buttons: left and right. Each button can be depressed and can be released. Here, for reference are the definitions of three common terms for actions performed

More information

Event-based Programming

Event-based Programming Window-based programming Roger Crawfis Most modern desktop systems are window-based. What location do I use to set this pixel? Non-window based environment Window based environment Window-based GUI s are

More information

, , ,

, , , Windows Forms .NET Framework Lecture 5-2 Microsoft technology introduced in 2002 1.1 2003, 2.0 2005, 3.0 2006, 3.5 2007 Integration with Windows systems:.net Framework 1.0, 1.1, 2.0: available for: 98,

More information

SPARK. User Manual Ver ITLAQ Technologies

SPARK. User Manual Ver ITLAQ Technologies SPARK Forms Builder for Office 365 User Manual Ver. 3.5.50.102 0 ITLAQ Technologies www.itlaq.com Table of Contents 1 The Form Designer Workspace... 3 1.1 Form Toolbox... 3 1.1.1 Hiding/ Unhiding/ Minimizing

More information

Tutorial 3 - Welcome Application

Tutorial 3 - Welcome Application 1 Tutorial 3 - Welcome Application Introduction to Visual Programming Outline 3.1 Test-Driving the Welcome Application 3.2 Constructing the Welcome Application 3.3 Objects used in the Welcome Application

More information

IBSDK Quick Start Tutorial for C# 2010

IBSDK Quick Start Tutorial for C# 2010 IB-SDK-00003 Ver. 3.0.0 2012-04-04 IBSDK Quick Start Tutorial for C# 2010 Copyright @2012, lntegrated Biometrics LLC. All Rights Reserved 1 QuickStart Project C# 2010 Example Follow these steps to setup

More information

Windows 7 Control Pack for WinForms

Windows 7 Control Pack for WinForms ComponentOne Windows 7 Control Pack for WinForms By GrapeCity, Inc. Copyright 1987-2012 GrapeCity, Inc. All rights reserved. Corporate Headquarters ComponentOne, a division of GrapeCity 201 South Highland

More information

Final Exam 7:00-10:00pm, April 14, 2008

Final Exam 7:00-10:00pm, April 14, 2008 Name:, (last) (first) Student Number: Section: Instructor: _P. Cribb_ L. Lowther_(circle) York University Faculty of Science and Engineering Department of Computer Science and Engineering Final Exam 7:00-10:00pm,

More information

OCTAVO An Object Oriented GUI Framework

OCTAVO An Object Oriented GUI Framework OCTAVO An Object Oriented GUI Framework Federico de Ceballos Universidad de Cantabria federico.ceballos@unican.es November, 2004 Abstract This paper presents a framework for building Window applications

More information

CALCULATOR APPLICATION

CALCULATOR APPLICATION CALCULATOR APPLICATION Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;

More information

Using Visual Basic Studio 2008

Using Visual Basic Studio 2008 Using Visual Basic Studio 2008 Recall that object-oriented programming language is a programming language that allows the programmer to use objects to accomplish a program s goal. An object is anything

More information

The first program we write will display a picture on a Windows screen, with buttons to make the picture appear and disappear.

The first program we write will display a picture on a Windows screen, with buttons to make the picture appear and disappear. 4 Programming with C#.NET 1 Camera The first program we write will display a picture on a Windows screen, with buttons to make the picture appear and disappear. Begin by loading Microsoft Visual Studio

More information

Your First Windows Form

Your First Windows Form Your First Windows Form From now on, we re going to be creating Windows Forms Applications, rather than Console Applications. Windows Forms Applications make use of something called a Form. The Form is

More information

Visual Basic/C# Programming (330)

Visual Basic/C# Programming (330) Page 1 of 12 Visual Basic/C# Programming (330) REGIONAL 2017 Production Portion: Program 1: Calendar Analysis (400 points) TOTAL POINTS (400 points) Judge/Graders: Please double check and verify all scores

More information

Lecture 1 Introduction Phil Smith

Lecture 1 Introduction Phil Smith 2014-2015 Lecture 1 Introduction Phil Smith Learning Outcomes LO1 Understand the principles of object oriented programming LO2 Be able to design object oriented programming solutions LO3 Be able to implement

More information

Introduction to the Visual Basic Express 2005IDE

Introduction to the Visual Basic Express 2005IDE 2 Introduction to the Visual Basic Express 2005IDE OBJECTIVES In this chapter, you will learn The basics of the VisualStudio Integrated Development Environment (IDE) that assists you in writing, running

More information

Ingegneria del Software T. Interfaccia utente

Ingegneria del Software T. Interfaccia utente Interfaccia utente Creating Windows Applications Typical windows-application design & development 1+ classes derived from System.Windows.Forms.Form Design UI with VisualStudio.NET Possible to do anything

More information

Welcome Application. Introducing the Visual Studio.NET IDE. Objectives. Outline

Welcome Application. Introducing the Visual Studio.NET IDE. Objectives. Outline 2 T U T O R I A L Objectives In this tutorial, you will learn to: Navigate Visual Studio.NET s Start Page. Create a Visual Basic.NET solution. Use the IDE s menus and toolbars. Manipulate windows in the

More information

Avoiding KeyStrokes in Windows Applications using C#

Avoiding KeyStrokes in Windows Applications using C# Avoiding KeyStrokes in Windows Applications using C# In keeping with the bcrypt.exe example cited elsewhere on this site, we seek a method of avoiding using the keypad to enter pass words and/or phrases.

More information

Laboratorio di Ingegneria del Software

Laboratorio di Ingegneria del Software Laboratorio di Ingegneria del Software L-A Interfaccia utente System.Windows.Forms The System.Windows.Forms namespace contains classes for creating Windows-based applications The classes can be grouped

More information

Laboratorio di Ingegneria del L-A

Laboratorio di Ingegneria del L-A Software L-A Interfaccia utente System.Windows.Forms The System.Windows.Forms namespace contains classes for creating Windows-based applications The classes can be grouped into the following categories:

More information

1. What is the definition of a problem? 2. How to solve problems? 3. What is meant by Algorithm? 4. What is a Program testing? 5. What is Flowchart?

1. What is the definition of a problem? 2. How to solve problems? 3. What is meant by Algorithm? 4. What is a Program testing? 5. What is Flowchart? 1. What is the definition of a problem? 2. How to solve problems? 3. What is meant by Algorithm? 4. What is a Program testing? 5. What is Flowchart? 6. Define Visual Basic.NET? 7. Define programming language?

More information

We are going to use some graphics and found a nice little batman running GIF, off course you can use any image you want for the project.

We are going to use some graphics and found a nice little batman running GIF, off course you can use any image you want for the project. C# Tutorial - Create a Batman Gravity Run Game Start a new project in visual studio and call it gravityrun It should be a windows form application with C# Click OK Change the size of the to 800,300 and

More information

Visual Basic.NET. 1. Which language is not a true object-oriented programming language?

Visual Basic.NET. 1. Which language is not a true object-oriented programming language? Visual Basic.NET Objective Type Questions 1. Which language is not a true object-oriented programming language? a.) VB.NET b.) VB 6 c.) C++ d.) Java Answer: b 2. A GUI: a.) uses buttons, menus, and icons.

More information

2 USING VB.NET TO CREATE A FIRST SOLUTION

2 USING VB.NET TO CREATE A FIRST SOLUTION 25 2 USING VB.NET TO CREATE A FIRST SOLUTION LEARNING OBJECTIVES GETTING STARTED WITH VB.NET After reading this chapter, you will be able to: 1. Begin using Visual Studio.NET and then VB.NET. 2. Point

More information

3. The first step in the planning phase of a programming solution is to sketch the user interface.

3. The first step in the planning phase of a programming solution is to sketch the user interface. Chapter 2: Designing Applications TRUE/FALSE 1. For an application to fulfill the wants and needs of the user, it is essential for the programmer to plan the application jointly with the user. ANS: T PTS:

More information

Introduction. Create a New Project. Create the Main Form. Assignment 1 Lights Out! in C# GUI Programming 10 points

Introduction. Create a New Project. Create the Main Form. Assignment 1 Lights Out! in C# GUI Programming 10 points Assignment 1 Lights Out! in C# GUI Programming 10 points Introduction In this lab you will create a simple C# application with a menu, some buttons, and an About dialog box. You will learn how to create

More information

UNIT-3. Prepared by R.VINODINI 1

UNIT-3. Prepared by R.VINODINI 1 Prepared by R.VINODINI 1 Prepared by R.VINODINI 2 Prepared by R.VINODINI 3 Prepared by R.VINODINI 4 Prepared by R.VINODINI 5 o o o o Prepared by R.VINODINI 6 Prepared by R.VINODINI 7 Prepared by R.VINODINI

More information

C# Forms and Events. Evolution of GUIs. Macintosh VT Datavetenskap, Karlstads universitet 1

C# Forms and Events. Evolution of GUIs. Macintosh VT Datavetenskap, Karlstads universitet 1 C# Forms and Events VT 2009 Evolution of GUIs Until 1984, console-style user interfaces were standard Mostly dumb terminals as VT100 and CICS Windows command prompt is a holdover In 1984, Apple produced

More information

In order to create your proxy classes, we have provided a WSDL file. This can be located at the following URL:

In order to create your proxy classes, we have provided a WSDL file. This can be located at the following URL: Send SMS via SOAP API Introduction You can seamlessly integrate your applications with aql's outbound SMS messaging service via SOAP using our SOAP API. Sending messages via the SOAP gateway WSDL file

More information

The Microsoft.NET Framework

The Microsoft.NET Framework Microsoft Visual Studio 2005/2008 and the.net Framework The Microsoft.NET Framework The Common Language Runtime Common Language Specification Programming Languages C#, Visual Basic, C++, lots of others

More information

BackgroundWorker Component Overview 1 Multithreading with the BackgroundWorker Component 3 Walkthrough Running an Operation in the Background 10 How

BackgroundWorker Component Overview 1 Multithreading with the BackgroundWorker Component 3 Walkthrough Running an Operation in the Background 10 How BackgroundWorker Component Overview 1 Multithreading with the BackgroundWorker Component 3 Walkthrough Running an Operation in the Background 10 How to Download a File in the Background 15 How to Implement

More information

Graphical User Interface Canvas Frame Event structure Platform-free GUI operations Operator << Operator >> Operator = Operator ~ Operator + Operator

Graphical User Interface Canvas Frame Event structure Platform-free GUI operations Operator << Operator >> Operator = Operator ~ Operator + Operator Graphical User Interface Canvas Frame Event structure Platform-free GUI operations Operator > Operator = Operator ~ Operator + Operator - Operator [] Operator size Operator $ Operator? Operator!

More information

GUI Components: Part 1

GUI Components: Part 1 1 2 11 GUI Components: Part 1 Do you think I can listen all day to such stuff? Lewis Carroll Even a minor event in the life of a child is an event of that child s world and thus a world event. Gaston Bachelard

More information

Visual Basic/C# Programming (330)

Visual Basic/C# Programming (330) Page 1 of 16 Visual Basic/C# Programming (330) REGIONAL 2016 Program: Character Stats (400 points) TOTAL POINTS (400 points) Judge/Graders: Please double check and verify all scores and answer keys! Property

More information

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK. Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK. Before you start - download the game assets from above or on MOOICT.COM to

More information