VC++ Programming UESTC Chapter 5 The Graphics Device Interface Color and Fonts o This hands-on chapter shows you how to build a mfc library application working with only the view element o How to use Graphics Device Interface(GDI) How to use resource editor Debug target vs. Release Target Understand Diagnostic Macros o Understand the Precompiled Headers
VC++ Programming @ UESTC 1 Chapter 5 The Graphics Device Interface , Color and Fonts ⚫ This hands-on chapter shows you how to build a MFC library application working with only the view element. ⚫ How to use Graphics Device Interface (GDI) ⚫ How to use Resource Editor ⚫ Debug Target vs. Release Target ⚫ Understand Diagnostic Macros ⚫ Understand the Precompiled Headers
VC++ Programming UESTC Chapter 5 The Graphics Device Interface Color and Fonts Windows class and C++ object and how to related them together o Device context classes revisited GDI Objects Windows Color Mapping ● Fonts
VC++ Programming @ UESTC 2 ⚫ Windows Class and C++ Object and how to related them together ⚫ Device Context Classes revisited ⚫ GDI Objects ⚫ Windows Color Mapping ⚫ Fonts Chapter 5 The Graphics Device Interface , Color and Fonts
VC++ Programming UESTC Chapter 5 The Graphics Device Interface Color and Fonts o typedef struct tag WNDCLAS UINT WNDPROC lpfn WndProc cbClsextra cbWndExtra HINSTANCE hInstance HICON hIcon cURSOr hCurso HBRUSH hbr Background LPCSTR lpszMenuName LPCSTR lpszclassName; 3 WNDCLASS 3
VC++ Programming @ UESTC 3 ⚫ typedef struct tagWNDCLASS { UINT style; WNDPROC lpfnWndProc; int cbClsExtra; int cbWndExtra; HINSTANCE hInstance; HICON hIcon; HCURSOR hCursor; HBRUSH hbrBackground; LPCSTR lpszMenuName; LPCSTR lpszClassName; } WNDCLASS; Chapter 5 The Graphics Device Interface , Color and Fonts
VC++ Programming UESTC Chapter 5 The Graphics Device Interface Color and Fonts o The mfC classes wrap Windows object handles with C++ objects For example, each C++ device context object has an associated hdc handle Associate the two wrapper class and the handle to the windows object by calling Attach
VC++ Programming @ UESTC 4 ⚫ The MFC classes wrap Windows object handles with C++ objects. For example, each C++ device context object has an associated HDC handle. Associate the two wrapper class and the handle to the windows object by calling Attach. Chapter 5 The Graphics Device Interface , Color and Fonts
VC++ Programming UESTC Chapter 5 The Graphics Device Interface Color and Fonts For example C Wnd my Wnd my Wnd Attach(h Wnd) This makes an entry in the permanent map associating myWnd and hwnd When myW'nd is deleted, the destructor will automaticall destroy the hWnd by calling the Windows Destroy Window function If this is not desired. the hwnd must be detached from myWnd before the myWnd object is destroyed(normally when leaving the scope at which myWnd was defined)
VC++ Programming @ UESTC 5 For example: CWnd myWnd; myWnd.Attach(hWnd); This makes an entry in the permanent map associating myWnd and hWnd. When myWnd is deleted, the destructor will automatically destroy the hWnd by calling the Windows DestroyWindow function. If this is not desired, the hWnd must be detached from myWnd before the myWnd object is destroyed (normally when leaving the scope at which myWnd was defined). Chapter 5 The Graphics Device Interface , Color and Fonts