A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Icons disapear from a CommanBar



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 29th 08, 12:43 PM 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

I notice your response to Eric with some code snippets after I posted my
initial reply. :-) I¡¯m starting to build an Outlook 2000 environment to
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?

Below is a workable example of Copy2clipboard for Outlook 2000. I wrote &
tested it when I was dealing with the thread mentioned in my last reply. I¡¯ve
also attached its project to this reply, and you may download it with
Outlook Express or Windows Mail.

void CCOMAddinUtil::CopyTransBitmap()
{
//////////////////////////////////////////////
/////////////Part 1. Load the button image and get a HBITMAP object.
//////////////////////////////////////////////

//HBITMAP hSrcBmp = LoadBitmap(AfxGetResourceHandle(),
MAKEINTRESOURCE(IDB_BITMAP1));
HBITMAP hSrcBmp = (HBITMAP)::LoadImage(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
//// Get a device context
HDC hDC = GetDC(0);

//////////////////////////////////////////////
/////////////Part 2(2). Load the Mask image and get a HBITMAP object for
the mask. (CORRECT)
//////////////////////////////////////////////
////Create the Bitmap MASK
BITMAP bitmap;
HBITMAP hbmMask;
// Get the BITMAP
GetObject(hSrcBmp, sizeof(BITMAP), &bitmap);
// Create memory DCs to work with.
HDC hdcMask = CreateCompatibleDC(hDC);
HDC hdcImage = CreateCompatibleDC(hDC);
// Create a monochrome bitmap for the mask.
hbmMask = CreateBitmap(bitmap.bmWidth, bitmap.bmHeight, 1, 1, NULL);
// Select the mono bitmap into its DC.
HBITMAP hbmOldMask = (HBITMAP)SelectObject(hdcMask, hbmMask);
// Select the image bitmap into its DC.
HBITMAP hbmOldImage = (HBITMAP)SelectObject(hdcImage, hSrcBmp);
// Set the transparency color to be the top-left pixel.
SetBkColor(hdcImage, GetPixel(hdcImage, 0, 0));
SetTextColor(hdcImage, RGB(255,255,255));
// Make the mask.
BitBlt(hdcMask, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hdcImage, 0, 0,
SRCCOPY);
// Cleaup up
SelectObject(hdcMask, hbmOldMask);
SelectObject(hdcImage, hbmOldImage);
DeleteDC(hdcMask);
DeleteDC(hdcImage);


//////////////////////////////////////////////
/////////////Part 3. Set the "Toolbar Button Face"
//////////////////////////////////////////////
BITMAPINFO bmi = {0};
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
GetDIBits(hDC, hSrcBmp, 0, 0, 0, &bmi, DIB_RGB_COLORS);

int nColors = (bmi.bmiHeader.biBitCount 8) ? 0 : (1
bmi.bmiHeader.biBitCount);
DWORD headerLen = sizeof(bmi.bmiHeader) + nColors*sizeof(RGBQUAD);
HGLOBAL hBits = GlobalAlloc(GMEM_SHARE|GMEM_MOVEABLE, headerLen +
bmi.bmiHeader.biSizeImage);
if(hBits)
{
LPVOID pBits = GlobalLock(hBits);
CopyMemory(pBits, &bmi.bmiHeader, sizeof(bmi.bmiHeader));

GetDIBits(hDC, hSrcBmp, 0, bmi.bmiHeader.biHeight,
((LPBYTE)pBits+headerLen), (LPBITMAPINFO)pBits, DIB_RGB_COLORS);

// S_OFF2000_CLIP_IMAGE was filled earlier with the localized name of the
clipboard format "Toolbar Button Face"
UINT clipImage = RegisterClipboardFormat(_T("Toolbar Button Face"));

// I copy the DIB to put CF_DIB as well as the Toolbar format into the
clipboard
// I tried adding only the Toolbar format or both - neither way the
disabled button image was displayed
SIZE_T cbDIB = GlobalSize(hBits);
HANDLE hgDIB = GlobalAlloc(GMEM_SHARE|GMEM_MOVEABLE, cbDIB);
LPVOID pDIB = GlobalLock(hgDIB);
CopyMemory(pDIB, pBits, cbDIB);
GlobalUnlock(hgDIB);

GlobalUnlock(hBits);

BOOL f = OpenClipboard(NULL);

if (!EmptyClipboard())
AfxMessageBox(_T("error emty clipboard"));

// CF_DIB might be optional so I tried with and without this clipboard
data
if(SetClipboardData(CF_DIB, hgDIB) == NULL)
GlobalFree(hgDIB);

if(SetClipboardData(clipImage, hBits) == NULL)
{
GlobalFree(hBits);
}
else
{
//////////////////////////////////////////////
/////////////Part 4. Set the "Toolbar Button Mask"
//////////////////////////////////////////////
ZeroMemory(&bmi, sizeof(bmi));
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);

GetDIBits(hDC, hbmMask, 0, 0, 0, &bmi, DIB_RGB_COLORS);

nColors = (bmi.bmiHeader.biBitCount 8) ? 0 : (1
bmi.bmiHeader.biBitCount);
headerLen = sizeof(bmi.bmiHeader) + nColors*sizeof(RGBQUAD);
hBits = GlobalAlloc(GMEM_SHARE|GMEM_MOVEABLE,
headerLen+bmi.bmiHeader.biSizeImage);

if(hBits)
{
//AfxMessageBox(_T("Allocate"));
LPVOID pBits = GlobalLock(hBits);
CopyMemory(pBits, &bmi.bmiHeader, sizeof(bmi.bmiHeader));

GetDIBits(hDC, hbmMask, 0, bmi.bmiHeader.biHeight,
((LPBYTE)pBits+headerLen), (LPBITMAPINFO)pBits, DIB_RGB_COLORS);

// S_OFF2000_CLIP_MASK contains the localized name of the "Toolbar
Button Mask"
UINT clipMask = RegisterClipboardFormat(_T("Toolbar Button Mask"));
GlobalUnlock(hBits);

if(clipMask == 0 || SetClipboardData(clipMask, hBits) == NULL)
{
//AfxMessageBox(_T("Fail"));
GlobalFree(hBits);
}
}
}
}
// Close the clipboard
CloseClipboard();
}

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.
=================================================

"Jialiang Ge [MSFT]" wrote in message
...
Good morning, Thomas. Welcome to office.developer.com.add_ins newsgroup!
My
name is Jialiang Ge [MSFT].



I once handled a very similar issue, where a customer said his
CommandBarButton icon cannot be shown only in Outlook 2000. That problem
turned out to be caused by the code:

HBITMAP hSrcBmp = LoadBitmap(AfxGetResourceHandle(),

MAKEINTRESOURCE(IDB_BITMAP1));

The method LoadBitmap has been superseded by the LoadImage function
because
it is incompatible with some device context. Thus, the resolution was to
replace the line with:

HBITMAP hSrcBmp = (HBITMAP)::LoadImage(GetModuleHandle(NULL),

MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);



Thomas, because you did not mention how you loaded the bitmap icon or
provided any code snippet for test, I cannot quickly figure out the reason
for this specific issue. But I suggest you read the above-mentioned
thread:

http://office-outlook.com/outlook-fo...60/#msg_209360



And if the thread does not help, would you please show us some code
snippets? I'd be very happy to test it for you.



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:
.



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...#notifications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support

Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support

professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations

that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

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



"Minor, Thomas" wrote in message
...
Hi all,

I have a problem with an Outllok AddIn.

Our AddIn creates a CommandBar and adds some buttons to it.
Depending on the context of the user actions (ie which message type is
highlighted, is a contact highlighted..) some buttons
are enabled or disabled. This runs flawlessly on most of our customers
enviroments.
We now have one customer where the following problems occur:

On some or most buttons the icons are missing. The button is there and
can
be used, but there is no icon.
We have a 'restore Toolbar' option in our settings dialog wich, under the
hood, removes all buttons from
the CommandBar and then adds them again. Interstingly, after each hit on
the restore-button, a different set of
Icons is displayed on the CommandBar until finally, after a non
deterministic count of tries, all icons are displayed.
This ist not quite the way we would like this to function.

The enviroment is Windows Server 2003, Terminal Server Mode, Citrix
Metaframe and Outlook 2000 SR3

Any hints are strongly appreciated...


--Thomas







  #2  
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




  #3  
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






  #4  
Old June 3rd 08, 04:26 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

I'm writing to check whether the icon-bmp conversion method in my last
reply help you or not. If you need my help to translate those VB code
(http://support.microsoft.com/kb/260850) to VC, please let me know.

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.
=================================================

"Jialiang Ge [MSFT]" wrote in message
...
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








 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Folders Disapear ???? Chip and Roxanne Outlook Express 5 March 8th 08 06:56 PM
Saving commanbar position in shared add-in ian Add-ins for Outlook 1 September 1st 06 07:10 PM
All of my new appointments disapear in Outlook 2007 Beta2 MWDoty Outlook - Calandaring 7 June 23rd 06 02:19 PM
Large Icons/Icons Disappearing Barattolo_67 Outlook Express 5 March 6th 06 02:43 AM
Re-occurring appointments disapear. sby Outlook - Calandaring 0 February 6th 06 02:30 PM


All times are GMT +1. The time now is 12:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.