|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
hello world,
there has been a similar question back in 2004 - with no solution, yet: http://groups.google.com/group/microsoft.public.outlook.program_addins/browse_thread/thread/29f3995045b77b4b/
i'm working on an ECE (exchange client extension) for outlook which adds a couple of 16x16 buttons to the outlook toolbar. i'm using VC++ and MAPI. these buttons have a 16 colour bitmap displayed. the purple color RGB(255,0,255) in the bitmaps is the transparent color when outlook runs.
i want to change the button bitmaps to be 256 color (8bpp). when i do this i cannot get transparency to work like it does with the 16 color bitmaps.
the purple shows up. is there any way i can get a color to be transparent?
below is the code used to add the button to the toolbar. i am using outlook XP, but have the same thing happen with outlook 2003.
TBADDBITMAP tbab; tbab.hInst = AfxGetInstanceHandle(); tbab.nID = uiBitmapID;
*puiToolBarM = SendMessage(hwndToolbar, TB_ADDBITMAP, 1, (LPARAM)&tbab);
1) one solution might be to make use of the OOM (outlook object model) to place and paint toolbar buttons. but i'd rather prefer not to add OOM code to my ECE.
2) i found some advice to use TB_SETIMAGELIST instead of TB_ADDBITMAP. but i couldn't get it work from within the ECE's InstallCommands via SendMessage.
any help greatly appreciated.
kind regards, gustafson
some more keywords: ImageList_AddMasked TB_ADDBITMAP TB_ADDBUTTONS TB_SETIMAGELIST toolbar loadbitmap loadimage ImageList_Create ImageList_Add IExchExt LR_CREATEDIBSECTION COLORREF IExchExtCommands LPEXCHEXTCALLBACK EETBID_STANDARD button icon *.bmp resource png
|
|
Hi gustafson,
I created the following function below that seems to work really well for creating a mask. Then call the following few of lines of code using the mask function.
PICTDESC pdBmpMask; pdBmpMask.cbSizeofstruct = sizeof(PICTDESC); pdBmpMask.picType = PICTYPE_BITMAP; pdBmpMask.bmp.hpal = 0;
pdBmp.bmp.hbitmap = ::LoadBitmap( _AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDB_IMAGE));
// Create the mask using white pdBmpMask.bmp.hbitmap = CreateBitmapMask(pdBmp.bmp.hbitmap, RGB(255,255,255));
IPictureDispPtr pPicMask; ::OleCreatePictureIndirect(&pdBmpMask, IID_IPictureDisp, TRUE, (LPVOID*) &pPicMask); spButton->PutMask(pPicMask);
HBITMAP CNewMessage::CreateBitmapMask(HBITMAP hbmColorImage, COLORREF crTransparent) { HDC hdcMem, hdcMem2; HBITMAP hbmMask; BITMAP bm;
// Create monochrome (1 bit) mask bitmap.
GetObject(hbmColorImage, sizeof(BITMAP), &bm); hbmMask = CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, NULL);
// Get some HDCs that are compatible with the display driver hdcMem = CreateCompatibleDC(0); hdcMem2 = CreateCompatibleDC(0);
::SelectObject(hdcMem, hbmColorImage); ::SelectObject(hdcMem2, hbmMask);
// Set the background color of the color image to the color // you want to be transparent. SetBkColor(hdcMem, crTransparent);
BitBlt(hdcMem2, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY); BitBlt(hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem2, 0, 0, SRCINVERT);
// Clean up. DeleteDC(hdcMem); DeleteDC(hdcMem2);
return hbmMask; }
Tom -
"PhilippG.NOSPAM[ at ]gmx.de" wrote:
[Quoted Text] > hello world, > > there has been a similar question back in 2004 - with no solution, yet: > http://groups.google.com/group/microsoft.public.outlook.program_addins/browse_thread/thread/29f3995045b77b4b/> > i'm working on an ECE (exchange client extension) for outlook which > adds a couple of 16x16 buttons to the outlook toolbar. i'm using VC++ > and MAPI. > these buttons have a 16 colour bitmap displayed. the purple color > RGB(255,0,255) in the bitmaps is the transparent color when outlook > runs. > > i want to change the button bitmaps to be 256 color (8bpp). when i do > this i > cannot get transparency to work like it does with the 16 color bitmaps. > > the purple shows up. is there any way i can get a color to be > transparent? > > below is the code used to add the button to the toolbar. i am using > outlook XP, but have the same thing happen with outlook 2003. > > TBADDBITMAP tbab; > tbab.hInst = AfxGetInstanceHandle(); > tbab.nID = uiBitmapID; > > *puiToolBarM = SendMessage(hwndToolbar, TB_ADDBITMAP, 1, > (LPARAM)&tbab); > > > 1) one solution might be to make use of the OOM (outlook object model) > to place and paint toolbar buttons. but i'd rather prefer not to add > OOM code to my ECE. > > 2) i found some advice to use TB_SETIMAGELIST instead of TB_ADDBITMAP. > but i couldn't get it work from within the ECE's InstallCommands via > SendMessage. > > any help greatly appreciated. > > kind regards, gustafson > > > some more keywords: ImageList_AddMasked TB_ADDBITMAP TB_ADDBUTTONS > TB_SETIMAGELIST toolbar loadbitmap loadimage ImageList_Create > ImageList_Add IExchExt LR_CREATEDIBSECTION COLORREF IExchExtCommands > LPEXCHEXTCALLBACK EETBID_STANDARD button icon *.bmp resource png > >
|
|
hi tom,
thank you very much for your answer. unfortunately your code uses the OOM. and as i wrote in my initial posting: i'd rather not add OOM code to my ECE.
so, still hoping for a solution ...
kind regards, gustafson
[Quoted Text] > I created the following function below that seems to work really well for > creating a mask. Then call the following few of lines of code using the mask > function. >
[...] > > ::OleCreatePictureIndirect(&pdBmpMask, IID_IPictureDisp, TRUE, (LPVOID*) > &pPicMask); > spButton->PutMask(pPicMask);
|
|
I don't think you will have much luck - everybody I know gave up on using ECE to modify the icons. Why don't you want to use OOM for that? You can still add buttons using the ECE API, but you should be able to modify the icons using OOM from your ECE.
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool
<PhilippG.NOSPAM[ at ]gmx.de> wrote in message news:1158758027.984426.280960[ at ]m7g2000cwm.googlegroups.com...
[Quoted Text] > hello world, > > there has been a similar question back in 2004 - with no solution, yet: > http://groups.google.com/group/microsoft.public.outlook.program_addins/browse_thread/thread/29f3995045b77b4b/> > i'm working on an ECE (exchange client extension) for outlook which > adds a couple of 16x16 buttons to the outlook toolbar. i'm using VC++ > and MAPI. > these buttons have a 16 colour bitmap displayed. the purple color > RGB(255,0,255) in the bitmaps is the transparent color when outlook > runs. > > i want to change the button bitmaps to be 256 color (8bpp). when i do > this i > cannot get transparency to work like it does with the 16 color bitmaps. > > the purple shows up. is there any way i can get a color to be > transparent? > > below is the code used to add the button to the toolbar. i am using > outlook XP, but have the same thing happen with outlook 2003. > > TBADDBITMAP tbab; > tbab.hInst = AfxGetInstanceHandle(); > tbab.nID = uiBitmapID; > > *puiToolBarM = SendMessage(hwndToolbar, TB_ADDBITMAP, 1, > (LPARAM)&tbab); > > > 1) one solution might be to make use of the OOM (outlook object model) > to place and paint toolbar buttons. but i'd rather prefer not to add > OOM code to my ECE. > > 2) i found some advice to use TB_SETIMAGELIST instead of TB_ADDBITMAP. > but i couldn't get it work from within the ECE's InstallCommands via > SendMessage. > > any help greatly appreciated. > > kind regards, gustafson > > > some more keywords: ImageList_AddMasked TB_ADDBITMAP TB_ADDBUTTONS > TB_SETIMAGELIST toolbar loadbitmap loadimage ImageList_Create > ImageList_Add IExchExt LR_CREATEDIBSECTION COLORREF IExchExtCommands > LPEXCHEXTCALLBACK EETBID_STANDARD button icon *.bmp resource png >
|
|
|