MFC中怎么加载外部指定路径图片 让他显示在窗口中!

来源:百度知道 编辑:UC知道 时间:2024/06/23 05:28:26

一个是loadimage;还一个是LoadBitmap这个比较简单
CBitmap m_bitmap;
m_bitmap.LoadBitmap(IDB_BITMAP1);
bitmap呢你先加入一个bitmap的资源,就可以了注意在MFC的View类中写这个代码就可以达到你想要的结果

LoadImage
The LoadImage function loads an icon, cursor, or bitmap.

HANDLE LoadImage(
HINSTANCE hinst, // handle of the instance containing the image
LPCTSTR lpszName, // name or identifier of image
UINT uType, // type of image
int cxDesired, // desired width
int cyDesired, // desired height
UINT fuLoad // load flags
);

Parameters
hinst
Handle to an instance of the module that contains the image to be loaded. To load an OEM image, set this parameter to zero.
lpszName
Handle to the image to load.
If the hinst parameter is non-NULL and the fuLoad parameter does not include LR_LOADFROMFILE, lpszName is a pointer to a null-terminated string that contains the name of the image resource in the hin