Programming Guide |
Returns the object ID for a graphics file
#include <smmwuser.h>int sm_com_load_picture(char *name, int width, int height);
name
- The name of the graphics file located in a Panther library or in a directory specified by SMPATH.
width
,height
- The size of the graphic. If 0, the picture keeps it natural size; otherwise, these parameters can be used to shrink or enlarge the picture. In JPL these parameters can be omitted and therefore default to 0.
Windows
Client
- · An object ID which represents the picture. The caller is responsible for destroying the picture (by calling sm_obj_delete_id) when the picture is no longer needed.
sm_com_load_picture
gets an object ID for the specified picture so that the image can be passed as a parameter in sm_obj_call or as a value in sm_obj_set_property.In those functions, the image's object ID can be referenced using
@obj
.
In the following example,
@obj
must be used since theImageListcontrol
does not supply sufficient information in its type library. In other cases,@obj
may not be needed (but is not harmful). If you get atype mismatch
error without using@obj
, try@obj
in the call.proc fill_imagelist
{
vars imagelist // imagelist control
vars images // list of images in the imagelist
vars pic // one picture
@app()->current_component_system=PV_SERVER_COM
imagelist = sm_obj_create("MSComctlLib.ImageListCtrl")
images = sm_obj_get_property(imagelist, "ListImages")
pic = sm_com_load_picture("logo.bmp")
call sm_obj_call(images, 1, '', @obj(pic))
sm_obj_delete_id(pic)
pic = sm_com_load_picture("folder.bmp")
call sm_obj_call(images, 2, '', @obj(pic))
sm_obj_delete_id(pic)
pic = sm_com_load_picture("screen.bmp")
call sm_obj_call(images, 3, '', @obj(pic))
sm_obj_delete_id(pic)
call sm_obj_delete_id(images)
// install the ImageList into the control
call sm_obj_set_property(control->id, "ImageList", imagelist)
call sm_obj_delete_id(imagelist)
}
sm_obj_call, sm_obj_set_property