Presentation is loading. Please wait.

Presentation is loading. Please wait.

Learning Programming Windows API Morpheus Feb-28, 2008.

Similar presentations


Presentation on theme: "Learning Programming Windows API Morpheus Feb-28, 2008."— Presentation transcript:

1 Learning Programming Windows API Morpheus Feb-28, 2008

2 Ralation ApplicationMessage Queue OS IO Device 12 3 4

3 Create Windows Design Windows Class Register Windows Create Windows Display and Update Windows Destroy Windows

4 Design Windows Class Syntax HWND CreateWindow( LPCTSTR lpClassName LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam );

5 Message Loop A program retrieves these messages from the message queue by executing a block of code known as the "message loop": while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; }

6 Message structure The msg variable is a structure of type MSG, which is defined in the WINUSER.H header file like this: typedef struct tagMSG { HWND hwnd ; UINT message ; WPARAM wParam ; LPARAM lParam ; DWORD time ; POINT pt ; }MSG, * PMSG ;

7 Basic Drawing The GDI Primitives Line and Cures Bresenham DDA Filled areas Bitmaps Text

8 The Device Context When you want to draw on a graphics output device such as the screen or printer, you must first obtain a handle to a device context. The most common method for obtaining a device context handle: Hdc = BeginPaint (hwnd, &ps); //program lines EndPaint (hwnd, &ps);

9 Other stuff HDC hdc = GetDC(hwnd); //coding ReleaseDC(hwnd); HDC hdc = GetWIndowDC(hwnd); //coding ReleaseDC(hwnd): HDC = hdc = CreateDC(pszDriver…..); //coding DeleteDC(hdc);

10 800 * 600 ? 800 * 800 Most video displays these days have screens that are 33 percent wider than they are high. This represents an aspect ratio of 1.33:1 or (as it's more commonly written) 4:3.

11 Color takes three arguments representing red, green, and blue values and combines them into an unsigned long: #define RGB(r,g,b) …..

12 Handle A handle is simply a number (usually 32 bits in size) that refers to an object. The handles in Windows are similar to file handles used in conventional C or MS-DOS programming. A program almost always obtains a handle by calling a Windows function. The program uses the handle in other Windows functions to refer to the object. The actual value of the handle is unimportant to your program, but the Windows module that gives your program the handle knows how to use it to reference the object.

13 HINSTANCE

14 HWND

15 Handle HINSTANCE Handle to an "instance"—the program itself HWND Handle to a window HDC Handle to a device context

16 CommonControls InitCommonControlsEx void InitCommonControls(void);

17 List control A list-view control is a window that displays a collection of items; each item consists of an icon and a label. List-view controls provide several ways to arrange and display items.

18 Create List control

19 Tree Control A tree view control displays a hierarchical list of items using lines to connect related items in a hierarchy. Each item consists of a label and an optional bitmap. Windows Explorer uses a tree view control to display directories.

20 Create Tree Control

21 Thank You


Download ppt "Learning Programming Windows API Morpheus Feb-28, 2008."

Similar presentations


Ads by Google