View Single Post
  #9  
Old May 30th 08, 06:23 AM posted to microsoft.public.developer.outlook.addins,microsoft.public.office.developer.com.add_ins,microsoft.public.outlook.program_addins
Jialiang Ge [MSFT]
external usenet poster
 
Posts: 4
Default Icons disapear from a CommanBar

Hello Thomas,

In fact, my code was written by referencing the VB code in the KB article
http://support.microsoft.com/kb/288771/en-us. It demonstrates how to create
a transparent picture for Office CommandBar buttons. But because your code
is importing an icon, instead of a bitmap resource, I suggest you read this
KB article:

How To Add a Transparent Icon to a Toolbar Button
http://support.microsoft.com/kb/260850

It provides the workable way to copy icon to bmp for Outlook 2000 system.
Though the sample code is in VB, the calls of API are the same in VC.

Regards,
Jialiang Ge , remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

"Minor, Thomas" wrote in message
...
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