LoadImageA()函数的参数的说明

qq_ll_yy 2002-03-13 03:34:12
如果你能告知,谢谢
...全文
796 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
SenseKey 2002-03-13
  • 打赏
  • 举报
回复
两个函数是一样的
SenseKey 2002-03-13
  • 打赏
  • 举报
回复
LoadImage (long hInst, cstring lpsz ,long un1,long n,long n2, long un2 )
说明
载入一个位图、图标或指针
返回值
Long,执行成功则返回对象的一个句柄;零表示失败
参数表
参数 类型及说明
hInst Long,要从其中载入图象的DLL或应用程序模块或实例句柄。零表示装载一幅固有图象
lpsz CString,欲载入图象的名字。如指定了hInst,就用这个参数指定资源或资源的标志符(标志符是一个长整数)。如hInst为空,而且已指定了LR_LOADFROMFILE,那么这个参数代表文件名(位图、图标或指针文件)。如果是个Long型值,这个参数就代表固有位图、图标或指针的编号
un1 Long,下述常数之一,指定了欲载入的图象类型:IMAGE_BITMAP, IMAGE_CURSOR, IMAGE_ICON
n1,n2 Long,要求的图象宽度和高度。图象会根据情况自动伸缩。如设为零,表示用图象的默认大小
un2 Long,下述常数的任意组合,它们都在api32.txt文件中得到了定义:
LR_DEFAULTCOLOR 以常规方式载入图象
LR_LOADREALSIZE 不对图象进行缩放处理。忽略n1和n2的设置
LR_CREATEDIBSECTION 如果指定了IMAGE_BITMAP,就返回DIBSection的句柄,而不是位图的句柄
LR_DEFAULTSIZE 如果n1和n2为零,就使用由系统定义的图象默认大小,而不是图象本身定义的大小
LR_LOADFROMFILE 如hInst为零,lpsz就代表要载入适当类型的一个文件的名字,仅适用于Win95
LR_LOADMAP3DCOLORS 将图象中的深灰、灰、以及浅灰像素都替换成COLOR_3DSHADOW,COLOR_3DFACE以及COLOR_3DLIGHT的当前设置
LR_LOADTRANSPARENT 与图象中第一个像素相符的所有像素都由系统替换
LR_MONOCHROME 将图象转换成单色
LR_SHARED 将图象作为一个共享资源载入。在NT 4.0中装载固有资源时要用到这个设置

Top

qq_ll_yy 2002-03-13
  • 打赏
  • 举报
回复
我问的是LoadImageA()函数,加了一个A
strip 2002-03-13
  • 打赏
  • 举报
回复
你哪个参数不明白??
这个函数可以load cursor, bitmap, icon

----------------------------------

Platform SDK: Windows User Interface
LoadImage
The LoadImage function loads an icon, cursor, animated cursor, or bitmap.

HANDLE LoadImage(
HINSTANCE hinst, // handle to instance
LPCTSTR lpszName, // image to load
UINT uType, // image type
int cxDesired, // desired width
int cyDesired, // desired height
UINT fuLoad // load options
);
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] Specifies the image to load. If the hinst parameter is non-NULL and the fuLoad parameter omits LR_LOADFROMFILE, lpszName specifies the image resource in the hinst module. If the image resource is to be loaded by name, the lpszName parameter is a pointer to a null-terminated string that contains the name of the image resource. If the image resource is to be loaded by ordinal, use the MAKEINTRESOURCE macro to convert the image ordinal into a form that can be passed to the LoadImage function.
If the hinst parameter is NULL and the fuLoad parameter omits the LR_LOADFROMFILE value, the lpszName specifies the OEM image to load. The OEM image identifiers are defined in Winuser.h and have the following prefixes. Prefix Meaning
OBM_ OEM bitmaps
OIC_ OEM icons
OCR_ OEM cursors



To pass these constants to the LoadImage function, use the MAKEINTRESOURCE macro. For example, to load the OCR_NORMAL cursor, pass MAKEINTRESOURCE(OCR_NORMAL) as the lpszName parameter and NULL as the hinst parameter.

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 Meaning
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 and the fuLoad parameter is LR_DEFAULTSIZE, the function uses the SM_CXICON or SM_CXCURSOR system metric value to set the width. If this parameter is zero and LR_DEFAULTSIZE is not used, the function uses the actual resource width.
cyDesired
[in] Specifies the height, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function uses the SM_CYICON or SM_CYCURSOR system metric value to set the height. If this parameter is zero and LR_DEFAULTSIZE is not used, the function uses the actual resource height.
fuLoad
[in] This parameter can be one or more of the following values. Value Meaning
LR_DEFAULTCOLOR The default flag; it does nothing. All it means is "not LR_MONOCHROME".
LR_CREATEDIBSECTION When the uType parameter specifies IMAGE_BITMAP, causes the function to return a DIB section bitmap rather than a compatible bitmap. This flag is useful for loading a bitmap without mapping it to the colors of the display device.
LR_DEFAULTSIZE 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 this flag is not specified and cxDesired and cyDesired are set to zero, the function uses the actual resource size. If the resource contains multiple images, the function uses the size of the first image.
LR_LOADFROMFILE Loads the image from the file specified by the lpszName parameter. If this flag is not specified, lpszName is the name of the resource.
LR_LOADMAP3DCOLORS Searches the color table for the image and replaces the following shades of gray with the corresponding 3-D color:
Color Replaced with
Dk Gray,
RGB(128,128,128) COLOR_3DSHADOW
Gray,
RGB(192,192,192) COLOR_3DFACE
Lt Gray,
RGB(223,223,223) COLOR_3DLIGHT
Do not use this option if you are loading a bitmap with a color depth greater than 8bpp.
LR_LOADTRANSPARENT Retrieves the color value of the first pixel in the image and replaces the corresponding entry in the color table with the default window color (COLOR_WINDOW). All pixels in the image that use that entry become the default window color. This value applies only to images that have corresponding color tables.
Do not use this option if you are loading a bitmap with a color depth greater than 8bpp.

If fuLoad includes both the LR_LOADTRANSPARENT and LR_LOADMAP3DCOLORS values, LRLOADTRANSPARENT takes precedence. However, the color table entry is replaced with COLOR_3DFACE rather than COLOR_WINDOW.

LR_MONOCHROME Loads the image in black and white.
LR_SHARED Shares the image handle if the image is loaded multiple times. If LR_SHARED is not set, a second call to LoadImage for the same resource will load the image again and return a different handle.
When you use this flag, the system will destroy the resource when it is no longer needed.

Do not use LR_SHARED for images that have non-standard sizes, that may change after loading, or that are loaded from a file.

When loading a system icon or cursor, you must use LR_SHARED or the function will fail to load the resource.

Windows 95/98/Me: The function finds the first image with the requested resource name in the cache, regardless of the size requested.

LR_VGACOLOR Uses true VGA colors.


Return Values
If the function succeeds, the return value is the handle of the newly loaded image.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks
When you are finished using a bitmap, cursor, or icon you loaded without specifying the LR_SHARED flag, you can release its associated memory by calling one of the functions in the following table.

Resource Release function
Bitmap DeleteObject
Cursor DestroyCursor
Icon DestroyIcon


The system automatically deletes these resources when the process that created them terminates, however, calling the appropriate function saves memory and decreases the size of the process's working set.

For an example, see Icon Creation.

Requirements
Windows NT/2000 or later: Requires Windows NT 4.0 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

See Also
Resources Overview, Resource Functions, CopyImage, GetSystemMetrics, LoadBitmap, LoadCursor, LoadIcon

Microsoft Platform SDK, February 2001 Edition.
This content last built on Thursday, February 01, 2001.
Requirements
Windows NT/2000 or later: Requires Windows NT 4.0 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
See Also
Resources Overview, Resource Functions, CopyImage, GetSystemMetrics, LoadBitmap, LoadCursor, LoadIcon

16,551

社区成员

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

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

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