Presentation is loading. Please wait.

Presentation is loading. Please wait.

C++ programming in Windows environment

Similar presentations


Presentation on theme: "C++ programming in Windows environment"— Presentation transcript:

1 C++ programming in Windows environment
Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 32./0. C++ programming in Windows environment Tools of software development The message-controlled work of Windows Process of message handling Programming in Borland C++ Builder environment The Borland C++ Builder integrated development environment

2 Tools of software development
Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 32./1. Tools of software development One of the aims of development of object oriented programming (OOP) is to give a tool for development of large (can be more than 1 million lines) programs. This tool, the object oriented programming language, or forms of it represented by integrated development environments (IDEs) do not aid all the steps of software development. The usual steps of software development process are the next: task specification task analysis structural planning detailed planning implementation in a given programming language testing An up-to-date object oriented programming environment, e.g. Microsoft Visual C++ or Borland C++ Builder aids only the last two steps of the upper, so called water fall model. Since the previous steps are very important too, tools to aid them were created. These are the CASE (Computer Aided Software Engineer-ing) tools.

3 the object model (class hierarchy, inheritance),
Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 32./2. The most well-known CASE software is the Rational Rose Modeler made by Rational Corporation that is a realisation of the UML (Unified Modeling Language). The UML is the integration of the concepts of Booch, Rumbaugh and Jacobson. The goal of UML is to declare, construct, visualise and document the components of software systems and theirs relation. To realise these needs different views and diagrams are presented. Views, diagrams regarding to class hierarchy, outer users, co-operation of objects, temporal properties of activities or events, state of objects, available software components and hardware elements to be applied are important. Different models used frequently at modelling the developed system are: the object model (class hierarchy, inheritance), the functional model (data flows, sources, storage, data targets) and the dynamic model (communications, events, states).

4 The message-controlled work of Windows
Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 32./3. The message-controlled work of Windows Programs running on Windows operating system differ significantly from DOS-programs were represented by our earlier programs. More than one application may run in Windows environment at the same time: process based multitasking, and more activities can be processed parallel: multithread multitasking. The transfer of the effects of user interactions (mouse, keyboard) to processes or threads running parallel is achieved by message-controlled operation. The applications run in windows and the addressee of the actual user interaction is the application that is the owner of the active window, or rather the member function of the touched control (button, input field, etc.). The pushing of a button can be interpreted as a message in which the operation system informs the active window of the event of pushing the button. The message-controlled operation is the method of communication between operating system and application.

5 Department of Information Engineering INFORMATION TECHNOLOGY dr
Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 32./4. In case of message-controlled work every control of every window has to be ready to be used so the control object be addressed by a message. The Windows operating system is object oriented. Significant part of its objects works as user interface: windows, buttons, lists, menus, icons, message-windows, etc. The work of these objects are performed by hundreds of member functions that are part of the Application Programming Interface (API) of the operating system. The operation system receives the messages coming from the user in the System Queue then transfers them to the waiting queue of that program which is the owner of the source window of the event. Every running program has own input, waiting queue. The applications takes the next message addressed to them from this input queue and process it, answer to it.

6 The process of message transfer
Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 32./5. The process of message transfer Windows Pushing the 'K' key Application program System queue WinMain function Program queue Message transmitting cycle Reading and forwarding messages Window handler function message interpretation, processing API function that displays K Window of application Source: Benkő Tiborné - Kuzmina, Jekatyerina - Kiss Zoltán - Tamás Péter - Tóth Bertalan : Könnyű a Windowst programozni ComputerBooks K., Budapest

7 Department of Information Engineering INFORMATION TECHNOLOGY dr
Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 32./6. In Windows programs there is WinMain(){} function, not main(){}. This creates the main window of the application and starts the Message transmitting cycle. // Borland Builder Project1.cpp #include <vcl.h> #pragma hdrstop USERES("Project1.res"); USEFORM("Unit1.cpp", Form1); // WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { try Application->Initialize(); Application->CreateForm(__classid(TForm1), &Form1); Application->Run(); } catch (Exception &exception) Application->ShowException(&exception); return 0;

8 Department of Information Engineering INFORMATION TECHNOLOGY dr
Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 32./7. The Message transmitting cycle performs a simple transformation on the message then passes it to the operation system. It does not pass directly to the Window handler function because the operation system wants to rank the messages that received back from different applications and are waiting for execution, so the operation system wants to control the running of programs. If a given application is the following then the operation system calls its Window handler function using the message as a parameter. The task of the Window handler function is to handle all messages that were sent to the window correctly. For this reason it has a switch multiple branching instruction where every branch responsible for handling of one type of messages. The Window handler function is not bound to deal with every received message. Handling of messages happens frequently through the API function of the operation system. It is important that the source code of Windows applications has more common code-segments, e.g. the full content of the previous Project1.cpp file. These common parts are generated automatically by the modern integrated programming environments, like Borland C++ Builder. Device Contexts: The application that wants to write, draw on the window has to build a connection to it through a device driver. The device context can be created and stopped even at running time, more times. This operation is mostly automatic too.

9 Department of Information Engineering INFORMATION TECHNOLOGY dr
Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 32./8. Applications running with Windows use many kinds of resources. A resource is such a thing that is used by the program but requires previous definition outside the program. E.g.: menus, cursors, icons, bitmaps, etc. The required resource file is created by a resource editor that is part of the programming environment. The resource file is compiled to a .RES file automatically by the programming environment. This .RES file can be used directly by the program. The Windows operation system does not store the content of the windows of user applications. After resizing, stopping the overlapping, etc. the application has to repaint the content of the window calling the Paint() member function of the window object. In the 32 bit version of Windows the segment:offset memory structure is not applied, the whole memory has a continuous address range. Moreover the virtual memory on the hard disk can be used as the continuation of physical RAM memory. As a result of 32 bit data width the int type requires 4 bytes.

10 Programming in Borland C++ Builder environment
Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 32./9. Programming in Borland C++ Builder environment The characteristics of C++: Very effective drag and drop, visual program development using visual components from rich component palettes: Rapid Application Development, RAD Requires writing minimal program code Two ways development: on visual side and on source code side  Wizards help the different programming activities Offers example programs, demonstrations, integrated user guide Object and component based development Powerful support of development client/server applications Very effective database development Efficient tracing, debugging, testing and more and more professional possibilities.

11 The Borland C++ Builder integrated development environment
Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 32./10. The Borland C++ Builder integrated development environment Main menu Tools Component palette Window designer Object- inspector Text editor Class- inspector

12 Department of Information Engineering INFORMATION TECHNOLOGY dr
Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 32./11.  Main menu: to reach all the possibilities of the software through menu items Most important menu items: File, View, Project, Run, Help.  Tools: Icons for direct access of most important activities. Can be configured to fulfil the user requirements.  Component palette: For easy selection and insertion into the program of visual components, building elements. E.g.: buttons, window-forms, menus, lists, sliders, input boxes, etc.  Window designer: For building the different windows of the application gives a base form to place the components onto it and position there. Forms are intended to form the windows or user interface of our program.  Object inspector: Offers a comfortable way to enter or modify the properties of objects (the values of data members) and to select the member functions that handle the events happens on the object. Text editor: For writing, editing and displaying the C++ code or for debugging the program. Class inspector: For survey of classes, variables, functions of program and for easy navigation among them.


Download ppt "C++ programming in Windows environment"

Similar presentations


Ads by Google