Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Oriented Programming Dr. Ennis-Cole CECS 5100.

Similar presentations


Presentation on theme: "Object Oriented Programming Dr. Ennis-Cole CECS 5100."— Presentation transcript:

1

2 Object Oriented Programming Dr. Ennis-Cole CECS 5100

3 Day 4 - The Device Context If ( (nFlags & MK_LBUTTON) == MK_LBUTTON ) { …………; ………….;} nFlags - Ctrl and Shift keys pressed MK_LBUTTON - left mouse button

4 Day 4 - Device Context Day 4 - Device Context Device Context (dc) imaginary screen in memory which holds drawn images that are transferred to the monitor

5 SetPixel ( ) Function: Draws a pixel (picture element) at the location specified by the horizontal and vertical parameters dc.SetPixel(point.x, point.y,…)

6 SetPixel ( ) Needs three parameters: The values (arguments) for the : 1.) horizontal coordinate (right of window’s left edge) 2.) vertical coordinate (pixels below window’s top edge)

7 SetPixel( ) 3.) Returned Value from RGB( ) RGB determines the amount color of the pixel that is drawn. R (red) B (blue) G (green) RGB(255,0,0) - red RGB(0,255,0) - blue RGB(255,255,255) - white

8 WM_MOUSEMOVE New Event automatically executed when the mouse is moved void ( ) ; Objects corresponding to a class :: Name of a function Values sent to a function for processing Function added OnMouseMove( )

9 OnMouseMove( ) Void CdrawDlg::OnMouseMove(UINT nFlags, Cpoint point) *data type *actual value

10 Pointer Variables bVbVbVbVertical & Horizontal Coordinates bpbpbpbpoint.x, point.y bSbSbSbSymbolic Ways to Process Addresses bEbEbEbEfficiently Allocate & Use Memory bAbAbAbAdd Complexity bAbAbAbA pointer is a variable that contains an address of another variable.

11 b The address is the location in memory where a value is stored. The & operator usually indicates the address. b Ptr1 = &X; X FFFA 10

12 Pointer Variables The unary operator (*) in programming gives you the value stored at a memory location. T = 5; Pointer px is declared and assigned &T, it gets the memory location of the variable T. If, y = X + *px; Then the value stored at px is added to X and the result is stored in y.

13 Pointer Activities b Assignment - an address & b De-referencing - finding a value * b Incrementing - useful for finding subsequent values (arrays) b Differencing - getting the difference between two pointers

14 Concept of An Array Concept of An Array b Array - contiguous block of memory used to hold a certain number of data elements of the same type. Advantages: grouping and processing related itemsAdvantages: grouping and processing related items Disadvantages: fixed number memory locations and all may not be usedDisadvantages: fixed number memory locations and all may not be used Applications: character strings, student grades, student names, payment historyApplications: character strings, student grades, student names, payment history

15 The End The End b “That’s all folks.”


Download ppt "Object Oriented Programming Dr. Ennis-Cole CECS 5100."

Similar presentations


Ads by Google