View Single Post
  #8  
Old May 29th 08, 02:24 PM posted to microsoft.public.developer.outlook.addins,microsoft.public.office.developer.com.add_ins,microsoft.public.outlook.program_addins
Minor, Thomas
external usenet poster
 
Posts: 5
Default Icons disapear from a CommanBar

Heallo Jialiang,

thanks for your extensive posts on my issue.

test it. Based on my experience, Thomas, I feel the problem may lie in
your code line:
hIcon = theApp.CRL_GetIcon(lIcon, CRL_ENABLED | CRL_SIZE_SMALL);
What¡¯s your implementation of CRL_GetIcon?


We use a resource dll for whitelabeling the application which implements
the function like this:

extern "C" HICON CALLBACK CRL_GetIcon(DWORD nID, DWORD dwFlags)
{
// Tell MFC to use our own resources not those of the loading module
// (must be used for every exported function that loads resources).
#ifdef _AFXDLL
AFX_MANAGE_STATE(AfxGetStaticModuleState())
#endif

// Size?
INT cx = CrlGetSize_(dwFlags);

// Enabled or disabled icon?
LPCTSTR pszName = MAKEINTRESOURCE(dwFlags & CRL_DISABLED ? nID +1 : nID);

// Note that LoadImage() does not require a subsequent DestroyIcon() in
Win32.
// Important: If the icon can't be found, return the icon 'empty' to avoid
// program crashes when returning NULL as HICON.
hIcon = (HICON)LoadImage(
AfxGetResourceHandle(),
pszName,
IMAGE_ICON,
cx, cx,
LR_DEFAULTCOLOR);

// LoadImage fails to load 128x128 icons on some Win9X systems, so use the
64x64 as fallback.
if(!hIcon && (cx == 128))
hIcon = (HICON)LoadImage(
AfxGetResourceHandle(),
pszName,
IMAGE_ICON,
64, 64,
LR_DEFAULTCOLOR);
if(!hIcon)
hIcon = (HICON)LoadImage(
AfxGetResourceHandle(),
MAKEINTRESOURCE(IDI_CRL_MISC_UNKNOWN_ID),
IMAGE_ICON,
cx, cx,
LR_DEFAULTCOLOR);

// LoadImage fails to load 128x128 icons on some Win9X systems, so use the
64x64 as fallback.
if(!hIcon && (cx == 128))
hIcon = (HICON)LoadImage(
AfxGetResourceHandle(),
MAKEINTRESOURCE(IDI_CRL_MISC_UNKNOWN_ID),
IMAGE_ICON,
64, 64,
LR_DEFAULTCOLOR);
return hIcon;
}

The main difference in our handling seems to be that we load the icon
as an icon first and convert it to a bitmap afterwards.
We chose this approach to use a generic way to load the icons.
Maybe there is a fault in this conversion...


--Thomas




Ads