Computers and programming The 10 th lecture Jiří Šebesta.

Slides:



Advertisements
Similar presentations
Mobile Development Introduction to Visual Studio Development Rob Miles Department of Computer Science.
Advertisements

Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Developing a Simple Graphical User Interface (GUI)
 2007 Dr. Natheer Khasawneh. Chapter 13. Graphical User Interface Concepts: Part 1.
Computers and programming The 7 th lecture Jiří Šebesta.
© by Pearson Education, Inc. All Rights Reserved.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Microsoft Visual C#.NET: From Problem Analysis to Program Design1 Chapter 9 Programming Based on Events Microsoft Visual C#.NET: From Problem Analysis.
C# Programming: From Problem Analysis to Program Design1 9 Programming Based on Events.
Programming Based on Events
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.
CVEV 118/698 Visual Basic Lecture 3 Prof. Mounir Mabsout Elsa Sulukdjian Walid El Asmar.
MENUS AND THE MENU EDITOR Elements of a Menu Menu bar Menu title Separator bar Menu items.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
KEAN UNIVERSITY Visual C++ Dr. K. Shahrabi. Developer studio Is a self-contain environment for creating, compiling, linking and testing windows program.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
Getting Started Example ICS2O curriculum
McGraw-Hill© 2007 The McGraw-Hill Companies, Inc. All rights reserved. 1-1.
1 Graphical User Interfaces Part 2 Outline Multiple Document Interface (MDI) Windows Visual Inheritance User-Defined Controls.
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Working with Unmanaged Code.
Tutorial 11 Using and Writing Visual Basic for Applications Code
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Using Arrays and File Handling
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Object Oriented Programming Graphical User Interfaces Dr. Mike Spann
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
IE 411/511: Visual Programming for Industrial Applications
Teacher: Ms. Olifer MICROSOFT VISUAL STUDIO 2010: PROPERTIES OF WINDOWS FORM OBJECT.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Enhancing the Graphical User Interface Multiple Forms, Controls, and Menus.
Computers and programming 1 The 11 th lecture Jiří Šebesta.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline.
OBJECTIVE  After completing this Lab, students will upgrade their knowledge in the field of VC++.  Students will also get the clear view about the concepts.
Introduction to Windows Programming
An Example of Windows Forms Applications Windows-based application –Win Forms Control structures (selection and repetition) Graphics Read integers from.
BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
1/62 Introduction to and Using MS Access Database Management and Analysis Yunho Song.
Controls. Adding Controls to Form -You can pick controls from the toolbox. -To add the controls from Toolbox to the Form You have be in design view. -To.
1 Introduction to C# Programming Console applications No visual components Only text output Two types MS-DOS prompt - Used in Windows 95/98/ME Command.
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.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Creating a Multiple-Form Interface.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 5.1 Test-Driving the Inventory Application.
Menus Menus provide groups of related commands for windows applications Menu, menu items, submenus A menu item that contains a submenu is considered to.
MS-Access XP Lesson 4. Modifying Queries 1.Select query in queries 2.Click design button or Right click on query and click design view 3.Change query.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 – Introduction to C# Programming Outline 3.1 Introduction 3.2 Simple Program: Printing a Line.
Overview of Previous Lesson(s) Over View 3 Program.
Visual Basic.Net. Software to Install Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available.
Creating New Forms Projects can appear more professional when using different windows for different types of information. Select Add Windows Form from.
Strings in C++/CLI us/library/system.string.aspxhttp://msdn.microsoft.com/en- us/library/system.string.aspx public: static.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 2: The Visual Studio .NET Development Environment
INF230 Basics in C# Programming
INF230 Basics in C# Programming
MFC Dialog Application
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Developing a Simple Graphical User Interface (GUI)
Advanced Programming Lecture 02: Introduction to C# Apps
The University of Texas – Pan American
CIS16 Application Development Programming with Visual Basic
Chapter 3 – Introduction to C# Programming
Introduction to Data Structure
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Chapter 4 Enhancing the Graphical User Interface
Presentation transcript:

Computers and programming The 10 th lecture Jiří Šebesta

TOPIC – programming in MSVS for Windows 1.Basic definitions 2.Form application 3.Examples

Basic definitions (1/4) Project for Windows: – header files files xxx.h – source code files files xxx.c or xxx.cpp – resources = above all graphic objects determined by set of properties and behavior files xxx.rc (xxx.ico)

Basic definitions (2/4) Resources: – menus – shortcuts – bit rasters, icons, cursors – character strings – tool panels – dialog windows Dialog window: – fundamental objekt (each window is dialog window) – control objects in dialog window are again dialog windows with special properties – applied principle: parent’s vs. child’s dialogs

Basic definitions (3/4) Dialog window (resp. object): – properties – variables define a visual characteristic and behavior of window (object) and events, i.e. functions called if an events in window (object) occurs, e.g. click by mouse - window modality - modal window, cannot be leaved without closing (style attribute WS_VISIBLE is set) - unmodal window can be whenever leaved (defocused)

Basic definitions (4/4) Fundamental sorts of Win applications: – using MFC (Microsoft Foundation Class Library) SDI (Single-document interface) – application using one document MDI (Multiple-document interface) – application using more documents at the same time (e.g. MS Visual Studio is MDI application) Dialog application – single dialog window for simple programs – using standard resources from Windows Form application for Windows

Form application (1/10) Form project establishment (MSVS 2008/10/12):

Form application (2/10) Form creating (setting of properties + inserting of standard graphic objects to design Form1.h[design] ):

Form application (3/10) this->ColorBox->BackColor = system::Drawing::Color::Transparent; this->ColorBox->Controls->Add(this->RB_blue); this->ColorBox->Controls->Add(this->RB_green); this->ColorBox->Controls->Add(this->RB_red); this->ColorBox->ForeColor = system::Drawing::SystemColors::ControlText; this->ColorBox->Location = System::Drawing::Point(2, 86); this->ColorBox->Name = L"ColorBox"; this->ColorBox->Size = System::Drawing::Size(88, 100); this->ColorBox->TabIndex = 1; this->ColorBox->TabStop = false; this->ColorBox->Text = L"Color"; Automatically generated code for setting of graphic object properties in Form1.h : this is pointer to this form

Form application (4/10) Function generation for event processing … private: System::Void RB_blue_Click(System::Object^ sender, System::EventArgs^ e) { this->My_text->ForeColor = System::Drawing::Color::Blue; } … in Form1.h a header of function for events is generated, required code can be written into the body of this function

Form application (5/10) Function main() in Ex76.cpp #include "stdafx.h" #include "Form1.h" using namespace Ex76; [STAThreadAttribute] int main(array ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault (false); // Create the main window and run it Application::Run(gcnew Form1()); return 0; } Code: Ex76

Form application (6/10) Windows Form application in MSVS2013: new project A form application can not be established directly It needs to insert an empty project of type CLR Empty Project with adequate name

Form application (7/10) A form application required an adding UI – Windows Form with adequate name, e.g. MyForm.h or Form.h, by Project – Add (use right mouse button):

Form application (8/10) Insert to MyForm.cpp following code: #include "MyForm.h" using namespace System; using namespace System::Windows::Forms; [STAThread] void Main(array ^args) { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault (false); Ex76::MyForm form; Application::Run(%form); return 0; } Modify code according to project name and form name

Form application (9/10) Set in Project – Properties: Linker - System

Form application (10/10) Set Linker – Advanced – Entry Point to name of starting function, e.g. Main

Examples (1/7) 1) Create a form application for a simple calculator – adding, subtracting, multiplying and division of two rational numbers. Visual design of form

double get_A(void) { return System::Convert::ToDouble(this->text_A->Text); } double get_B(void) { return System::Convert::ToDouble(this->text_B->Text); } Examples (2/7) Function for text reading from the TextBox and conversion to double conversion method calling pointer to this form object of form TextBox named as text_B variable of TextBox

private: System::Void bt_plus_Click(System::Object^ sender, System::EventArgs^ e) { this->Res->Text = System::Convert::ToString(get_A()+get_B()); } … private: System::Void bt_div_Click(System::Object^ sender, System::EventArgs^ e) { this->Res->Text = System::Convert::ToString(get_A()/get_B()); } Examples (3/7) Event processing – pressing of particular buttons function of class System pointer to this form conversion method calling function for inputs reading calling Code: Ex77

Examples (4/7) 2) Create an form application for simple database of computers (items: producer, price and memory capacity) with record up to 20 computers using dynamic access. Visual design of form

#include typedef struct t_pc { char prod[ 20]; // name of the producer int price; // price of the computer float mem; // RAM capacity in GB } a_pc; void add(char* _prod, int _price, float _mem); // adding new computer void sort(void); // sorting according to the price t_pc* get_fwd(void); // point out to the next computer t_pc* get_bwd(void); // point out to the prev. computer int show_price(void);// get price of an added pc int show_cheap(void);// get price of the cheapest pc Examples (5/7) Building-up of own function library computer.h

#include "computer.h"// definition of the struct t_pc t_pc *register[20]; // array of pointers to computers int index=0; // first free position in the katalog int ptr=index-1; // pointer to a pc displayed in edits void add(char* _prod, int _price, float _mem) { t_pc *my_pc; my_pc = (t_pc*) malloc(sizeof(t_pc)); strcpy(my_pc->prod, _prod); my_pc->price = _price; my_pc->mem = _mem; register[ptr=index++] = my_pc; } Examples (6/7) Array of pointers to records declaration + solution example of the function add() in computer.cpp

#pragma once #include "computer.h" using namespace System::Runtime::InteropServices; namespace Ex78 { …. private: System::Void AddBtn_Click(System::Object^ sender, System::EventArgs^ e) { add((char*)Marshal::StringToHGlobalAnsi(ProdEdit- >Text).ToPointer(), System::Convert::ToInt32(PriceEdit- >Text), System::Convert::ToDouble(MemEdit->Text)); ShowLbl->Text = System::Convert::ToString(show_price()); } Examples (7/7) Adding the library pocitac.h and processing of event for pressing button Add in Form1.h conversion method VisualString => *char calling Code: Ex78

TOPIC OF THE NEXT LECTURE 1.FINAL TEST THANK YOU FOR YOUR ATTENTION