在做位图显示的时候遇到了一个问题,请指教。
把要显示的位图拷到res文件下
在程序中用下面的代码不能显示:
CBitmap m;
m.LoadBitmap("1.bmp");
CDC dc;
if(dc.CreateCompatibleDC(pDC) == FALSE)
AfxMessageBox("Can't create DC");
dc.SelectObject(m);
pDC->StretchBlt(0, 0, 201, 150, &dc, 0, 0, 201, 150, SRCCOPY);
在vc的资源视图里将它引入,虽然提示超过256色,但将LoadBitmap的参数改为资源的ID就可显示
为什么m.LoadBitmap("位图名");不行?我在网上查了一下,好像说 参数应该是资源名
但我加载小的位图时,参数用的是"1.bmp"可以显示
把要显示的位图拷到res文件下
在程序中用下面的代码不能显示:
CBitmap m;
m.LoadBitmap("1.bmp");
CDC dc;
if(dc.CreateCompatibleDC(pDC) == FALSE)
AfxMessageBox("Can't create DC");
dc.SelectObject(m);
pDC->StretchBlt(0, 0, 201, 150, &dc, 0, 0, 201, 150, SRCCOPY);
在vc的资源视图里将它引入,虽然提示超过256色,但将LoadBitmap的参数改为资源的ID就可显示
为什么m.LoadBitmap("位图名");不行?我在网上查了一下,好像说 参数应该是资源名
但我加载小的位图时,参数用的是"1.bmp"可以显示
解决方案 »
- 这是什么情况?求歌大神解释下。。。
- Disable/Enable Device 在 win7 下不起作用,求解。
- WM_NCACTIVATE 钩子如何写
- exe中看得见,转成dll就看不见了
- 关于程序图标的问题
- 关于cfile类从txt文件读取数据的问题,能帮一下吗?谢谢了
- 用sendmessage发送WM_PRINT来截图得到的为什么是黑色的
- 如何通过IP获得机器名或者是域名?
- 用ATL写的控件,加入了属性页,但在VB中加入后点击右键菜单最下面没有"属性"一项,要加什么接口才能使之可在菜单中打开属性对话框? 在线
- 如何向系统中所有的窗口发送SW_HIDE的广播消息?
- 有没有人用过CArray的?指点一下。
- 怎样即时的检查文本框里的字符?
加载大的图片的时候有什么错误吗?
调试看一下,是什么错误,,
我没有MSDN...
This function loads an icon, cursor, or bitmap.HANDLE LoadImage(
HINSTANCE hinst,
| LPCTSTR lpszName,
UINT uType,
int cxDesired,
int cyDesired,
UINT fuLoad );
Parameters
hinst
[in] 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
[in] Identifies 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 hinst module.
If hinst is NULL and LR_LOADFROMFILE is not specified, the low-order word of this parameter must be the identifier of the OEM image to load. The OEM image identifiers are defined in Winuser.h and have the following prefixes: Prefix Description
OBM_ OEM bitmaps
OIC_ OEM icons
OCR_ OEM cursors
If the fuLoad parameter includes the LR_LOADFROMFILE value, lpszName is the name of the file that contains the image. uType
[in] Specifies the type of image to be loaded. This parameter can be one of the following values:
Value Description
IMAGE_BITMAP Loads a bitmap.
IMAGE_CURSOR Loads a cursor.
IMAGE_ICON Loads an icon.
cxDesired
[in] Specifies the width, in pixels, of the icon or cursor. If this parameter is zero, the function uses the SM_CXICON or SM_CXCURSOR system metric value to set the width. If uType is IMAGE_BITMAP, this parameter must be zero.
cyDesired
[in] Specifies the height, in pixels, of the icon or cursor. If this parameter is zero, the function uses the SM_CYICON or SM_CYCURSOR system metric value to set the height. If uType is IMAGE_BITMAP, this parameter must be zero.
fuLoad
[in] Set to zero.
Windows CE behaves as though the LR_DEFAULTCOLOR and LR_DEFAULTSIZE values are set. LR_DEFAULTCOLOR means “not monochrome.” LR_DEFAULTSIZE means that the system uses the width or height specified by the system metric values for cursors or icons if the cxDesired or cyDesired values are set to zero. If the resource contains multiple images, the function uses the size of the first image. Return Values
The handle of the newly loaded image indicates success. NULL indicates failure. To get extended error information, call GetLastError.
LoadImage(实例句柄,文件名,IMAGE_BITMAP,0,0,LR_LOADFROMFILE),最后一个参数指名是从文件中装入,另外第一个参数应该可以设为NULL