|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Timothy Anderson
|
May 28, 2008 - 6:36 PM
|
You need a combo LoadIconFromModule and LoadIconFile that is something like: STDMETHODIMP CExtAutoCommand::LoadIconFromModuleFile( BSTR strFileName, int nIconIndex, int dx,int dy, VARIANT_BOOL * bRetVal )
So I can set the toolbar button size instead of hard coding it to 16x16... Luckily this is easy enough to hammer together myself.
|
|
Timothy Anderson
|
May 28, 2008 - 8:02 PM
|
I added this in to LoadIconFromModule, hopefully it is correct. I just yanked it from google ICONINFO IconInfo; if (!GetIconInfo( hIcon, &IconInfo )) { ::DestroyIcon(hIcon); return S_OK; }
BITMAP bmp; if (GetObject( IconInfo.hbmColor, sizeof(BITMAP), &bmp ) == 0) { ::DestroyIcon(hIcon); return S_OK; }
// Convert the color format to a count of bits. DWORD cClrBits = (DWORD)(bmp.bmPlanes * bmp.bmBitsPixel); if (cClrBits == 1) cClrBits = 1; else if (cClrBits <= 4) cClrBits = 4; else if (cClrBits <= 8) cClrBits = 8; else if (cClrBits <= 16) cClrBits = 16; else if (cClrBits <= 24) cClrBits = 24; else cClrBits = 32;
BITMAPINFOHEADER bih; ::memset( &bih, 0, sizeof(BITMAPINFOHEADER) ); bih.biSize = sizeof(BITMAPINFOHEADER);
bih.biWidth = bmp.bmWidth; bih.biHeight = bmp.bmHeight; bih.biPlanes = bmp.bmPlanes; bih.biBitCount = bmp.bmBitsPixel; bih.biCompression = BI_RGB; if (cClrBits < 24) { bih.biClrUsed = (1<<cClrBits); }
// Compute the number of bytes in the array of color // indices and store the result in biSizeImage. // For Windows NT, the width must be DWORD aligned unless // the bitmap is RLE compressed. This example shows this. // For Windows 95/98/Me, the width must be WORD aligned unless the // bitmap is RLE compressed. bih.biSizeImage = ((bih.biWidth * cClrBits + 31) & ~31) /8 * bih.biHeight;
|
|
Technical Support
|
May 31, 2008 - 10:39 AM
|
Could you show the entire source code of this method to let us debug and test it?
|
|