《VC++高级编程》
来历版块:C/C++压缩包内文件格式:文本内容
附件来历:互联网
运行方式:Windows方式
是不是经自己验证:是
附件性质:免费
详细说明:《VC++高档编程》
2.3绘图操作终结
下面介绍绘图操作的源程序使您对设备上下文的使用有一个大致的理解。
首要生成一个设备上下文。CPaintDC是MFC提供的一个从CDC承继出来的类。使用它有啥好处呢?假如直接使用CDC的话,我们需要首要调用CWnd的BeginPaint函数为重绘工作做一些准备工作,在终结制作之还要用EndPaint函数表明完毕制作工作。一切的绘图操作都必须在这两个函数之间终结。CPaintDC封装了这两个函数,自动地对它们进行调用,使用者无须再去进行这些调用。
CPaintDCdc(this);
BITMAPbm;
m_bitmap_gt;GetBitmap(bm);
CDCdcImage;
if(!dcImage.CreateCompatibleDC(dc))
return;
CBitmap
pOldBitmap=dcImage.SelectObject(m_bitmap);
dc.BitBlt(0,0,bm.bmWidth,bm.bmHeight,
dcImage,0,0,SRCCOPY);
(Origin section: C/C
Compressed file format: text content
Attachment source: Internet
Operation mode: Windows mode
Is it verified by yourself: yes
Attachment nature: free
Detailed description: "VC Advanced Programming"
2.3 The end of the drawing operation
The source program of the drawing operation is introduced below to give you a general understanding of the use of the device context.
First generate a device context. CPaintDC is a class provided by MFC that inherits from CDC. What are the benefits of using it? If we use CDC directly, we need to call the BeginPaint function of CWnd first to do some preparatory work for the redrawing work, and use the EndPaint function to indicate the completion of the production work before the end of the production. All drawing operations must terminate between these two functions. CPaintDC encapsulates these two functions and calls them automatically, and the user does not need to make these calls.
CPaintDCdc(this);
BITMAPbm;
m_bitmap_gt;GetBitmap(bm);
CDCdcImage;
if(!dcImage.CreateCompatibleDC(dc))
return;
CBitmap
pOldBitmap=dcImage.SelectObject(m_bitmap);
dc.BitBlt(0,0,bm.bmWidth,bm.bmHeight,
dcImage,0,0,SRCCOPY);)
页:
[1]