How do I put bitmaps on buttons?

Stefan Gruendal (Stefan_Gruendel@wue.maus.de) writes:

But to my question: How do I build my own "smart icons", i.e. bitmaps on pushbuttons, that optically "move into the screen"? I didn't find any way to achieve this with the Toolkit's Dialog Editor. But as mentioned above, I know there's a way.

Starting with OS/2 2.x, a new button style was added - BS_ICON - which allows you to do what you are trying to accomplish. It works, as far as I know, only for pushbuttons, and the icon or bitmap is taken from the resource file, whose resource id is specified in the pushbutton text.

For example:

In FOO.H:

#define IDBM_BUTTON 256
#define IDPB_BUTTON 257

In FOO.RC:

BITMAP IDBM_BUTTON BUTTON.BMP

In FOO.C:

sprintf(achText,"#%d",IDBM_BUTTON);

hwndButton=WinCreateWindow(hwndClient,WC_BUTTON,achText,
                           WS_VISIBLE|BS_PUSHBUTTON|BS_ICON,
                           10,10,32,32,hwndClient,HWND_TOP,
                           IDPB_BUTTON,NULL,NULL);

The bitmap is stretched or compressed to fill the button.

(Quoted almost directly from EDMI/2 Edition 1)


[Back: How does programming PM compare to programming X?]
[Next: Can a PM program tell if there's a previous instance of itself running?]