Icons, Pointers and Bitmaps

As already mentioned, an icon is a graphical representation of an object on the screen. For the purposes of discussion, icons, pointers and bitmaps will be grouped together; a pointer is a graphical image that is associated with a pointing device such as a mouse, and which moves on the screen as the pointing device is moved by the user, whereas a bitmap is a graphical image that typically is used to represent a general item such as a logo. Icons, pointers and bitmaps may be designed interactively using the Icon Editor application supplied as part of the OS/2 Version 2.0 product. Depending on which resource is being created, the Icon Editor saves the resulting icon, pointer or bitmap in a file with an extension of ICO, PTR or BMP. These files are then referenced from the resource script file using the ICON, POINTER or BITMAP keywords:

ICON     MAIN     APPLIC.ICO
POINTER  DRAW     PENCIL.PTR
BITMAP   INTRO    LOGO.BMP

The keyword is followed in each case by a resource identifier, which is a symbolic name used by the application to identify the resource. For an icon, the identifier is used as a parameter to the WinCreateWindow() and WinCreateStdWindow() calls, and identifies the icon resource to be used when the FCF_ICON attribute is specified for the frame window. In all cases, the symbolic name must be defined as an integer constant using a #define statement.

For a pointer or bitmap, the identifier is used as a parameter to the WinLoadPointer() or GpiLoadBitmap() functions, which load the resource into memory. WinLoadPointer() returns a pointer to the resource in memory, which may then be used as a parameter to the WinSetPointer() function, in order to set the desktop pointer to that resource.

A pointer may be set to one of the system-defined pointer styles (such as an arrow or hourglass) using the WinSetPointer() function, by obtaining the handle of the required system pointer using the WinQuerySysPointer() function as follows:

rc = WinSetPointer(HWND_DESKTOP,
                   WinQuerySysPointer(HWND_DESKTOP,
                                      SPTR_WAIT,
                                      FALSE));

This call will set the pointer for the desktop to the hourglass pointer (indicated by the symbolic name SPTR_WAIT). The handle of the hourglass pointer is returned by the WinQuerySysPointer() call. The symbolic names of the various system pointers are described along with the WinQuerySysPointer() function in the IBM OS/2 Version 2.0 Presentation Manager Reference.

A bitmap is drawn within a window on the screen using the WinDrawBitmap() function. The pointer to the bitmap, returned by GpiLoadBitmap() is passed as a parameter to WinDrawBitmap() in order to identify the resource.


[Back: Fonts]
[Next: Menu Bars and Pulldown Menus]