关于绘图函数的一些问题

jiaaa1 2004-04-03 12:23:59
请问
CPaintDC dc(this); //CPaintDC是一个做什么的类

CBitmap bitmap; //CBitmap是一个做什么的类
bitmap.LoadBitmap (IDB_BKWOOD);

CDC dcMem; //CDC是一个做什么的类
dcMem.CreateCompatibleDC(&dc);//CreateCompatibleDC是一个做什么的
//函数
CBitmap* pOldBitmap = dcMem.SelectObject(&bitmap);//这句话什么意
//意思?

CRect rect(0 ,0, 0, 0);//CRect是做什么的类
GetClientRect(&rect); //这个函数是哪个类里面的,什么意思?

dc.StretchBlt(0, 0, rect.Width(), rect.Height(), &dcMem,
0, 0, 640, 640, SRCCOPY);//这个函数什么意思?

问题很菜,敬请指教
...全文
25 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
酒红绿叶 2004-04-03
  • 打赏
  • 举报
回复
CBitmap bitmap; //CBitmap是一个做什么的类

The CBitmap class encapsulates a Windows graphics device interface (GDI) bitmap and provides member functions to manipulate the bitmap. To use a CBitmap object, construct the object, attach a bitmap handle to it with one of the initialization member functions, and then call the object’s member functions.

CBitmap Windows 图形设备接口 bitmap,


bitmap.LoadBitmap (IDB_BKWOOD);

BOOL LoadBitmap( LPCTSTR lpszResourceName );

BOOL LoadBitmap( UINT nIDResource );

Return Value

Nonzero if successful; otherwise 0.


Loads the bitmap resource named by lpszResourceName or identified by the ID number in nIDResource from the application’s executable file. The loaded bitmap is attached to the CBitmap object.

装载bitmap资源,名为lpszResourceName ,或由ID确定的资源!
attache到CBitmap 对象上!

CBitmap* pOldBitmap = dcMem.SelectObject(&bitmap);//这句话什么意
//意思?

CDC::SelectObject
CPen* SelectObject( CPen* pPen );

CBrush* SelectObject( CBrush* pBrush );

virtual CFont* SelectObject( CFont* pFont );

CBitmap* SelectObject( CBitmap* pBitmap );

int SelectObject( CRgn* pRgn );

Return Value

A pointer to the object being replaced. This is a pointer to an object of one of the classes derived from CGdiObject, such as CPen, depending on which version of the function is used. The return value is NULL if there is an error. This function may return a pointer to a temporary object. This temporary object is only valid during the processing of one Windows message. For more information, see CGdiObject::FromHandle.


就是设备选用了你自己定义的pBitmap ,把原来用的返回给你!

酒红绿叶 2004-04-03
  • 打赏
  • 举报
回复
CPaintDC dc(this); //CPaintDC是一个做什么的类
The CPaintDC class is a device-context class derived from CDC. It performs a CWnd::BeginPaint at construction time and CWnd::EndPaint at destruction time.

A CPaintDC object can only be used when responding to aWM_PAINT message, usually in your OnPaint message-handler member function.

是由CDC派生的一个设备上下文类!
只响应WM_PAINT


CDC是一个做什么的类

The CDC class defines a class of device-context objects. The CDC object provides member functions for working with a device context, such as a display or printer, as well as members for working with a display context associated with the client area of a window.
设备上下文类!


For specific uses, the Microsoft Foundation Class Library provides several classes derived from CDC . CPaintDC encapsulates calls to BeginPaint and EndPaint. CClientDC manages a display context associated with a window’s client area. CWindowDC manages a display context associated with an entire window, including its frame and controls. CMetaFileDC associates a device context with a metafile.

具体还是看MSDN,希望楼主E语可以!

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧