home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_03_01
/
3n01006b
< prev
next >
Wrap
Text File
|
1991-11-26
|
2KB
|
60 lines
/*****************************************************/
/* icon.c */
/* -- Module implements a routine to create an icon. */
/*****************************************************/
/*****************************************************/
/* Header files. */
/*****************************************************/
#include <windows.h>
#include "icon.h"
/*****************************************************/
/* Routines. */
/*****************************************************/
HICON
HicnFromBmpBmp(HBITMAP hbmpColor, HBITMAP hbmpMono)
/******************************************************/
/* -- Given a color and monochrome bitmap with the */
/* dimension, create and return a handle to an */
/* icon. */
/* -- hbmpColor : Color bitmap. */
/* -- hbmpMono : Monochrome bitmap. */
/******************************************************/
{
LPICN lpicn;
BITMAP bmpColor, bmpMono;
HICON hicn;
DWORD cbColor, cbMono;
/* Get the header info from the bitmaps. */
GetObject(hbmpMono, sizeof bmpMono, (LPSTR)&bmpMono);
cbMono = bmpMono.bmWidthBytes * bmpMono.bmHeight;
GetObject(hbmpColor, sizeof bmpColor, (LPSTR)&bmpColor);
cbColor = bmpColor.bmWidthBytes * bmpColor.bmHeight;
/* Get some space for the icon. */
hicn = GlobalAlloc(GMEM_MOVEABLE, sizeof *lpicn -
sizeof(BYTE) + cbColor + cbMono);
if (hicn == NULL)
return hicn;
/* Initialize the icon header info. */
lpicn = (LPICN)GlobalLock(hicn);
lpicn->cbLine = bmpMono.bmWidthBytes;
lpicn->dx = bmpColor.bmWidth;
lpicn->dy = bmpColor.bmHeight;
lpicn->ptHot.x = lpicn->ptHot.y = 0;
lpicn->cpln = bmpColor.bmPlanes;
lpicn->cbit = bmpColor.bmBitsPixel;
/* Finish the filling the icon with bitmap bits. */
GetBitmapBits(hbmpMono, cbMono, lpicn->rgb);
GetBitmapBits(hbmpColor, cbColor,
lpicn->rgb + cbMono);
GlobalUnlock(hicn);
return hicn;
}