将HBITMAP 转为 HICONHICON ConvertToHICON( CBitmap& bitmap) ;

HICON HICONFromCBitmap(CBitmap& bitmap)
{
BITMAP bmp;
bitmap.GetBitmap(&bmp);

 

HBITMAP hbmMask = ::CreateCompatibleBitmap(::GetDC(NULL), 
bmp.bmWidth, bmp.bmHeight);

ICONINFO ii = {0};
ii.fIcon = TRUE;
ii.hbmColor = bitmap;
ii.hbmMask = hbmMask;

HICON hIcon = ::CreateIconIndirect(&ii);
::DeleteObject(hbmMask);

return hIcon;
}

posted on 2010-11-30 12:37  C杨阳  阅读(395)  评论(0编辑  收藏  举报

导航