LoadResPicture Function |
Syntax
LoadResPicture(resID, resType)
resID
Use: Required
Data Type: Variant
A numeric or string value specifying the resource ID of the picture to load.
resType
Use: Required
Data Type: Variant
A numeric constant denoting the format of the picture to load. See the following table for valid constants and values:
Constant Value Description vbResBitmap 0 Bitmap resource vbResIcon 1 Icon resource vbResCursor 2 Cursor resource
Return Value
An IPictureDisp interface.
Description
Assigns a graphic from a resource file (.RES ) to the Picture property of a form or control.
Rules at a Glance
The images to be loaded by LoadResPicture must be included in a resource (.RES ) file. Each must be assigned a unique identifier, which is typically represented by a numeric constant.
The file loaded by LoadResPicture can be a Windows bitmap file (.BMP or .RLE), an icon file (.ICO), or a cursor file (.CUR ).
The image returned by the LoadResPicture function can be assigned to any form or control property that expects an StdPicture object. These include the Picture property of a PictureBox or an Image control, the Icon property of a Form object, or the MouseIcon property of a form.
Programming Tips and Gotchas
LoadResPicture is part of the VB Runtime Library and, as such, isn't available in VBA applications.
Visual Basic 6 includes an add-in Resource Editor; see the previous sidebar for more information.
Using graphics from a .RES file speeds up the loading of a form.
Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.