C++ programming in Windows environment

Slides:



Advertisements
Similar presentations
MS® PowerPoint.
Advertisements

Working with Tables for Page Design – Lesson 41 Working with Tables for Page Design Lesson 4.
IS660Z Programming Games Using Visual Basic Overview of Cannonball.
Visual Basic: ballistics
DEVELOPING ICT SKILLS PART -TWO
 Use the Left and Right arrow keys or the Page Up and Page Down keys to move between the pages. You can also click on the pages to move forward.  To.
Formulas, Functions, Formatting, and Web Queries
FrontPage Express By John G. Summerville Ph.D.©, RN.
CREATING A MULTIPLE PAGE REPORT Presented by: Dr. Ennis-Cole.
XP New Perspectives on Microsoft Access 2002 Tutorial 61 Microsoft Access 2002 Tutorial 6 – Creating Custom Reports.
1 Create a Questionnaire Learning Objective  To learn how to use the features in Microsoft Publisher to create a questionnaire.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
SOLIDWORKS: Lesson 1 - Basics and Modeling Fundamentals
European Computer Driving Licence Syllabus version 5.0 Module 4 – Spreadsheets Chapter 22 – Functions Pass ECDL5 for Office 2007 Module 4 Spreadsheets.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Microsoft Expression Web-Illustrated Unit I: Working with Tables.
® Microsoft Office 2010 Excel Tutorial 1: Getting Started with Excel.
Working with Graphics – Lesson 21 Working with Graphics Lesson 2.
1 After completing this lesson, you will be able to: Open a file. Navigate through a document. Scroll through a document. Insert text in a document. Select.
Flash 1. Document Properties Set frame rate and dimensions of project Set frame rate and dimensions of project (default width=550 and height=400)
Web and Multimedia Development Copyright © Genetic Computer School 2007WM LESSON OVERVIEW  Use of Tables  Creating Tables  Try It – 1  Creating.
LC++ programming in Windows environment Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 10./0. lThe Visual Component Library.
Excel Chapter 1 Creating a Worksheet and an Embedded Chart
Word & Windows Terminology Review. 1. Provides one-click access to common commands you use frequently. In the Business Lab some of the commands you will.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
Creating a Workbook Part 1
Chapter 1: An Introduction to Visual Basic .NET
Editing and Formatting Worksheets Section 2
Integrating Office 2003 Applications and the World Wide Web
Microsoft Excel.
Microsoft Access 2007 – Level 2
Learn Animations in Fireworks
Flash Interface, Commands and Functions
Chapter 8: Writing Graphical User Interfaces
Shelly Cashman: Microsoft Word 2016
Chapter 2 – Introduction to the Visual Studio .NET IDE
Microsoft Excel.
Program and Graphical User Interface Design
CHAPTER FIVE Decision Structures.
Project Objectives Open an image Save an image Resize an image
Introduction to the Visual C# 2005 Express Edition IDE
Windows Desktop Applications
Learning Objectives • Dynamic Input Line tool. • Coordinate systems.
Just a minute Time for Action (Intermediate)  
Microsoft Office Access 2003
Program and Graphical User Interface Design
Unit 4: Using Spreadsheets to Make Economic Choices Lessons 20–26
Chapter 2 Adding Web Pages, Links, and Images
Microsoft Excel All editions of Microsoft office.
NOTES for S1. Start by drawing a LINE. Move MOUSE POINTER (MP) over INSERT TAB of TOP MENU and Left.
C++ programming in Windows environment
1.
C++ programming in Windows environment Text controls in the program
DIRECTIONS: 1. Click Enable Editing in the yellow bar above.
DREAMWEAVER MX 2004 Chapter 3 Working with Tables
Chapter 1 Creating a Worksheet and an Embedded Chart
Chapter 5 Microsoft Excel Window
Review: Applying Computer Basics
ICT Spreadsheets Lesson 1: Introduction to Spreadsheets
C++ programming in Windows environment
Objectives At the end of this session, students will be able to:
University of Warith AL-Anbiya’a
Basic parts of Word 2016 EIT, ©Author Gay Robertson, 2017.
University of Warith AL-Anbiya’a
Using Word to Write the Story of Your Life
University of Warith AL-Anbiya’a
PowerPoint Tutorial 1 Creating a Presentation
GO! with Microsoft PowerPoint 2016 Comprehensive
MAINTAINING FILES AND CUSTOMIZING WINDOWS Section 2
In this chapter, you will learn the following:
Presentation transcript:

C++ programming in Windows environment Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 37./0. C++ programming in Windows environment Position adjusters and indicators in the program ScrollBar control TrackBar control ProgressBar control UpDown control Demonstration program on position adjusters and indicators

Department of Information Engineering INFORMATION TECHNOLOGY dr Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 37./1. ScrollBar control The scroll bar is used to scroll in the window the contents that cannot see fully in the window. Its parts are the slider, bar and scrolling buttons. The scroll bar can be handled by mouse or keyboard equally, it has the suitable event handlers. Its orientation can be vertical or horizontal, depending on the value of Kind property. The interval of movement of the content to be scrolled has to scaled to the range of the moving of the slider setting the values for the Min and Max properties. The actual position of slider between Min and Max can be written or read by the Position property. The position will change by steps determined by the value of SmallChange if the scrolling buttons are used. At paging, so clicking between the slider and scrolling buttons or scrolling by the PgUp, PgDn keys the position changes by value of LargeChange property. When changing the position an OnChange event happens. The skeleton of this function can be created double clicking on the scroll bar component. To generate this event the position can be changed by mouse, by keyboard or from program. In the event handler the new position of the scrollable content has to be calculated and set.

Department of Information Engineering INFORMATION TECHNOLOGY dr Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 37./2. The continuously changing value caused by the continuous moving can be used for other purpose too, e.g. rotating an object, performing movements. The scrollbar is controlled by an inner timer. The Min, Max and Position properties can be set all at once calling the SetParams( ) method. Information on the position of slider or manner of scrolling can be get in the OnScroll event handler function. TrackBar control The control that reminds to a scale of an instrument is suitable for controlling or indicating a value which can change in an interval. Its most important property is the location of the pointer that can be written or read by the Position property. The Orientation can be horizontal and vertical. The interval of scale determined by Min and Max properties, and a visually emphasized subrange can be given inside by SelStart and SelEnd properties. The side of the scale determined by TikMarks, the style by TickStyle property. The density of scale can be set by Frequency.

ProgressBar control UpDown control Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 37./3. ProgressBar control The progress bar suitable for indicating the state of processes taking place in time. Its most important property is the Position, that can take values between Min and Max limits. The newer segment determined by Step property appears calling the StepIt( ) method. The value of Position can be increased with arbitrary step calling the StepBy( ) method. The value of Smooth property determines the continuous or segmented form. UpDown control This control is suitable for incrementing or decrementing the value of the Position property by a given integer value. The step is stored in the Increment property. It can be associated to an Edit control by Associate property. After association the position can be entered or stepped using the buttons. The Position can be read or modified from program too. Its value has to be between Min and Max. The most important event handler is the OnClick. The Orientation determines its direction.

Demonstration program on position adjusters and indicators Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 37./4. Demonstration program on position adjusters and indicators The task: make a program that can be characterised by the next window!

Department of Information Engineering INFORMATION TECHNOLOGY dr Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 37./5. The red wheel can be rolled to the left or to the right by the ScrollBar, by the TrackBar or by modifying the UpDown control. The Pointer of the TrackBar indicates the actual height of the centre of the white Fleck, the slider on the ScrollBar moves parallel to the vertical position of the Wheel, while the ProgressBar measures the passed from the starting of the program time. Solution: 1. Create a new folder and save into this a newly opened empty application using Slider.prj name. 2. Place the required controls on the Form, give the sizes and positons according to the given figure of the window. The task of the Timer component is to call in every 5 seconds its OnTimer( ) event handler function and to actualise the progress indicator in this function. The Wheel and the Fleck are TShape components. Their Shape property is set to stEllipse. The Color of the Brush property of the Wheel is set to clRed. The black base bar is a TShape type component and its Shape property has a stRectangle value

The Form after placing the components: Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 37./6. The Form after placing the components:

4. We will need some global variables, define them after the Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 37./7. 3. The Orientation property of TrackBar component has to be set to trVertical value. 4. We will need some global variables, define them after the TForm1 *Form1 line: int position,Dx,Dy,dx,dy,R,r; double angle; The position is the parameter of the motion, can have a value from the 0-314 interval. Its value corresponds to the length of the distance covered by the Wheel, as the radius of Wheel is equal to 100. 5. The computations require the sin, cos, acos functions that have been defined in the math.h headerfile. Insert this file under the line including the Unit1.h header file:           #include "math.h” 6. The BorderStyle property of the Form has bsDialog value, the ReadOnly property of the Edit1 is true. 7. Give the Captions for the components as shown in the figure, and modify it for ScrollBar, TaskBar and ProgressBar demonstration program for the Form.

8. Set the Font property of the main title to 10 point bold value. Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 37./8. 8. Set the Font property of the main title to 10 point bold value. 9. Rename some components: Shape1 --> ShapeWheel Shape2 --> ShapeFleck Shape3 --> ShapeBase. 10. Though most of these initialisation values could be set in the Object Inspector too, give them now in the constructor of the Form: __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { Dx= 113; Dy= 120; //shift relative to the corner of the window dx= 201; dy= 208; //starting centre of Wheel - r: Dx+R-r; Dy+R-r R= 100; r= 12; //radiuses UpDown1->Position= 157; UpDown1->Min= 0; UpDown1->Max= 314; //continued Dx, Dy dx,dy

ScrollBar1->SetParams(157,1,314); Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 37./9. ScrollBar1->SetParams(157,1,314); ScrollBar1->SmallChange = 1; // fine stepping interval ScrollBar1->LargeChange = 10; // big stepping interval TrackBar1->Position=100; TrackBar1->Min= 0; TrackBar1->Max= 200; // for displaying only TrackBar1->SelStart= r; TrackBar1->SelEnd= 2*R-r; TrackBar1->PageSize= 4; TrackBar1->Frequency= 4; ProgressBar1->Min= 0; ProgressBar1->Max= 600; // 5 minutes (600/10 * 5 sec) ProgressBar1->Width= 600; // 2 pixel in the drawing == 1 sec ProgressBar1->Step= 10; // 1 step==10 pixel == 5 sec ProgressBar1->Position= 0; Timer1->Interval=5000; // 5 sec Timer1->Enabled= true; // it starts with the program }

ScrollBar that reflects to the change of the position of the slider: Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 37./10. 11. The most important function is the OnChange( ) event handler of the ScrollBar that reflects to the change of the position of the slider: void __fastcall TForm1::ScrollBar1Change(TObject *Sender) { // Reading out the position of the slider: position= ScrollBar1->Position; Edit1->Text= position; // displaying // Positioning the Wheel: ShapeWheel->Left= Dx+position; // really it slides only… // Positioning the Fleck: angle= (double)position/R; ShapeFleck->Left= dx+position-(int)(R-r)*sin(angle); ShapeFleck->Top= dy+(int)(R-r)*cos(angle); TrackBar1->Position= R+(int)(R-r)*cos(angle); // slider } The turning of the Wheel is made sensible by moving of Fleck. The Pointer is set to the middle of height of white Fleck here too.

void __fastcall TForm1::Timer1Timer(TObject *Sender) { Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 37./11. 12. The Timer gives alarm at every 5 seconds and calls its OnTimer( ) event handler function: void __fastcall TForm1::Timer1Timer(TObject *Sender) { ProgressBar1->StepIt(); // actualises the progress bar } 13. Clicking on one of the buttons of the UpDown control its OnClick() event handler function is invoked that increments or decrements the position motion parameter depending on the button was pushed: void __fastcall TForm1::UpDown1Click(TObject *Sender, TUDBtnType Button) if (Button == btNext) position++; else position--; ScrollBar1->Position= position; // Initiates all the activities, } // because means OnChange event at the ScrollBar!

void __fastcall TForm1::TrackBar1Change(TObject *Sender) { int sv; Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 37./12. 14. Finally program that case when the Pointer of the TrackBar is moved up and down by mouse and because of this have to move everything: Wheel, Fleck, ScrollBar, Edit1 numerical display. The vertical position of the Pointer will be converted to position value and using this will be activated the OnChange( ) event handler of the ScrollBar, that moves everything:. void __fastcall TForm1::TrackBar1Change(TObject *Sender) { int sv; sv= TrackBar1->Position; if (sv<12) sv=12; if (sv>188) sv=188; angle= acos((double)(sv-R)/(R-r)); position= (int)(R*angle); ScrollBar1->Position=position; // Initiates all the activities. } 15. The program works well, though some refinement possibilities are there, e.g. the Timer is not stopped, the application will stop it, the Edit1 field can not get entries and move the Wheel such manner, the usability of keyboard is not checked, etc.