当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

VC++程序设计_AnlexVC++3(英文)

资源类别:文库,文档格式:PPT,文档页数:33,文件大小:89.5KB,团购合买
点击下载完整版文档(PPT)

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

VC++ Programming UESTC Chapter 5 The Graphics Device Interface Color and Fonts Device context is the key gdi element that represents a physical device e The mfc cdc class has all the member functions that you ll need for drawing Except for the CMetaFiledC class, derived classes are distinct only in their constructor and destructor o For display and printer device context objects, framework attaches the handle to the object For memory device context, you must call a member function to attach the handle after construction

VC++ Programming @ UESTC 6 ⚫ Device context is the key GDI element that represents a physical device. ⚫ The MFC CDC class has all the member functions that you’ll need for drawing. ⚫ Except for the CMetaFileDC class, derived classes are distinct only in their constructor and destructor. ⚫ For display and printer device context objects, framework attaches the handle to the object. ⚫ For memory device context, you must call a member function to attach the handle after construction. Chapter 5 The Graphics Device Interface , Color and Fonts

VC++ Programming@UESTC Chapter 5 The Graphics Device Interface Color and Fonts o The Display Context Classes CClientDC and CWindowDC e CClientdc does not include menu bar. toolbar status bar and scroll bar o CWindowdC is more applicable to the frame windows than it is to the view windows

VC++ Programming @ UESTC 7 ⚫ The Display Context Classes CClientDC and CWindowDC ⚫ CClientDC does not include menu bar, toolbar, status bar and scroll bar. ⚫ CWindowDC is more applicable to the frame windows than it is to the view windows Chapter 5 The Graphics Device Interface , Color and Fonts

VC++ Programming UESTC Chapter 5 The Graphics Device Interface Color and Fonts Properly handle cdc object to release the windows resource Construct object object the stack void CMy View: OnLButton Down qUiNT nFlags Cpoint point) CRect rect CClientDC dc(this); / from stack dc. GetClipBox(rect):i//dc automatically released 2. Use CWnd: GetDC….. OnlButtondown(….){ Crect rect CDC* pDC= GetDCO ReleaseD(pDc); 3. You must not to destroy Cdc object passed by OnDraw. Let framework does it for you

VC++ Programming @ UESTC 8 ⚫ Properly handle CDC object to release the windows resource. 1. Construct object object the stack void CMyView::OnLButtonDown(UINT nFlags, Cpoint point) { CRect rect; CClientDC dc(this); // from stack dc.GetClipBox(rect); }// dc automatically released 2. Use CWnd::GetDC ….. OnLButtonDown(….) { Crect rect; CDC* pDC = GetDC(); …. ReleaseDC(pDC); } 3. You must not to destroy CDC object passed by OnDraw. Let framework does it for you. Chapter 5 The Graphics Device Interface , Color and Fonts

VC++ Programming UESTC Chapter 5 The Graphics Device Interface Color and Fonts e The State of the device Context What you see on screen or printer depends on the current state of device context Attached GDI drawing objects such as pens bruhes and fonts 2. The mapping mode that determines the scale of items then they are drawn 3. Various details such as alignment parameters and polygon filling mode

VC++ Programming @ UESTC 9 ⚫ The State of the Device Context What you see on screen or printer depends on the current state of device context. 1. Attached GDI drawing objects such as pens, bruhes and fonts. 2. The mapping mode that determines the scale of items then they are drawn. 3. Various details such as alignment parameters and polygon filling mode. Chapter 5 The Graphics Device Interface , Color and Fonts

VC++ Programming UESTC Chapter 5 The Graphics Device Interface Color and Fonts ● GDI Objects CGdiObject is the abstract base class for the gDi classes Derived Classes for Windows GDI objects Class windows handle type CPen HPEN CBrush HBRUSH CFont HFONT CBitmap HBITMAP PAlette HPALETTE CR HRGN 10

VC++ Programming @ UESTC 10 ⚫ GDI Objects CGdiObject is the abstract base class for the GDI classes. Derived Classes for Windows GDI Objects Class Windows handle type CPen HPEN CBrush HBRUSH CFont HFONT CBitmap HBITMAP CPalette HPALETTE CRgn HRGN Chapter 5 The Graphics Device Interface , Color and Fonts

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共33页,可试读12页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有