Download
graphical user interface gui n.
Skip this Video
Loading SlideShow in 5 Seconds..
Graphical User Interface (GUI) PowerPoint Presentation
Download Presentation
Graphical User Interface (GUI)

Graphical User Interface (GUI)

103 Vues Download Presentation
Télécharger la présentation

Graphical User Interface (GUI)

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Graphical User Interface(GUI) • A GUI allows user to interact with a program visually. • GUIs are built from GUI components. • A GUI component is an object with which the user interacts via the mouse and keyboard.

  2. Some basic components • Label - An area in which icons or text can be displayed • TextBox – An area in which user inputs data • 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 • ListBox – An area in which a list of items is displayed • Panel – A container in which components can be placed • HScrollBar – A horizontal scroll bar. • VScrollBar – A vertical scroll bar.

  3. Window form • A form is a graphical element that appears on the desktop. • A form can be a dialog, an SDI window (single document interface window) or an MDI window (multiple document interface window)

  4. Form property and events • Common properties • AcceptButton – specifies which button will be clicked when user press enter • AutoScroll – specifies whether scrollbars appear when needed • CancelButton – specifies which button is clicked when user presses Esc • FormBorderStyle – specifies the border of the form • Font -specifies the font of text displayed in the form as well as the default font of controls added to the form • Text – specifies the text in the form’s title bar

  5. Form properties and events • Common methods • Close – closes form. • Hide – hides form • Show – display a hidden form • Common events • Load – occurs before a form is shown

  6. Basic event handling • Double-click the click event in the property window to create an empty event handler in the program code private: System::void formName_Click(System::Object *sender, System::EventArgs *e) { MessageBox::Show(S”Form was pressed”); };

  7. Register event-handler with delegate • After creating the event-handler, we must register it with the delegate, which contains a list of event handlers to call. • Controls have a delegate for each of their events • The delegate has the same name as the event • If we are handling event EventName for object myControl, then the delegate pointer is myControl->EventName • .NET registers events for us this->Click += new System::EventHandler(this, Form1_Click); • The first argument to the EventHandler constructor is a pointer to the object that contains the method specified as the second argument. • Form1_click is a method of class Form1. The first argument will be 0 if the method is static method

  8. Control properties • BackColor: background color of the control • Text: text associated with the control • TextAlign: The alignment of the text on the control. • Font:Font used to display control’s text • ForeColor: Foreground color of the control. Usually color of the text • Focused: specifies whether the control has focus • Visible: specifies whether the control is visible

  9. Common methods • Focus: Transfer the focus to the control • Hide: Hides the control( equivalent to setting Visible to false) • Show: shows the control(equivalent to setting Visible to true)

  10. Control layout • Anchor: anchoring allows control to stay a fixed distance from the sides of the container, even when the control is resized • Dock: docking allows control to extend themselves along the sides of their containers • Fill dock option effectively docks the control to all sides of its parent • Dockpadding sets the distance from docked controls to the edge of the form.

  11. Create window form project • From File->new -> project • Select window form application(.Net) • Click view->toolbox if toolbox is not open • Drag and drop the controls to design GUI