🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #502

Re: How to increase the height of the menu item?

#502
From: Renald Yazmir
Date: Wed, 19 Mar 2008 16:58
104 lines
3897 bytes
I have related question:

The code below works ok if when I draw transparent pict in the child window.
When I use it to draw pict on the menu it does not draw at all.

it is called like this:
 draw_transparent_picture_hwnd(lpdis->hwndItem, PICT_SAVE, &menu_rect, 
RGB(0, 128, 128));



void draw_transparent_picture(
     HWND hwnd,
     int  pictid,
     RECT *rct,
     COLORREF picture_background_color
     )
{
 BITMAP bitmap;
 COLORREF crOldBack   = 0;
 HDC dcImage     = NULL;
 HDC dcTrans     = NULL;
 HBITMAP pOldBitmapImage  = NULL;
 HBITMAP bitmapTrans   = NULL;
 HBITMAP pOldBitmapTrans  = NULL;
 HBITMAP hBitmap    = NULL;
 HDC hDC      = NULL;
 HDC hMemDC     = NULL;

 hDC = GetDC(hwnd);

 if ((hMemDC = CreateCompatibleDC(hDC)) == (HDC) NULL)
  return ;

 hBitmap = LoadBitmap(res_lib, MAKEINTRESOURCE(pictid));

 if (hBitmap == NULL)
  return ;

 crOldBack = SetBkColor(hDC, RGB(255, 255, 255));

 // Create two memory dcs for the image and the mask
 dcImage=CreateCompatibleDC(hDC);
 dcTrans=CreateCompatibleDC(hDC);

 // Select the image into the appropriate dc
 pOldBitmapImage = (HBITMAP)SelectObject(dcImage, hBitmap);

 // Create the mask bitmap
 GetObject(hBitmap, sizeof(BITMAP), &bitmap);
 bitmapTrans=CreateBitmap(bitmap.bmWidth, bitmap.bmHeight, 1, 1, NULL);

 // Select the mask bitmap into the appropriate dc
 pOldBitmapTrans = (HBITMAP)SelectObject(dcTrans, bitmapTrans);

 // Build mask based on transparent colour
 SetBkColor(dcImage, picture_background_color);
 BitBlt(dcTrans, 0, 0, bitmap.bmWidth, bitmap.bmHeight, dcImage, 0, 0, 
SRCCOPY);

 // Do the work - True Mask method - cool if not actual display
 BitBlt(hDC, rct->left, rct->top, bitmap.bmWidth, bitmap.bmHeight, dcImage, 
0, 0, SRCINVERT);
 BitBlt(hDC, rct->left, rct->top, bitmap.bmWidth, bitmap.bmHeight, dcTrans, 
0, 0, SRCAND);
 BitBlt(hDC, rct->left, rct->top, bitmap.bmWidth, bitmap.bmHeight, dcImage, 
0, 0, SRCINVERT);

 // Restore settings
 SelectObject(dcImage, pOldBitmapImage);
 SelectObject(dcTrans, pOldBitmapTrans);
 SetBkColor(hDC, crOldBack);


 DeleteDC (hMemDC);
 DeleteDC (dcImage);
 DeleteDC (dcTrans);

 ReleaseDC(hwnd, hDC);

}


Thank you
Rony

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:47dea190$1@newsgroups.borland.com...
>
> "Renald Yazmir" <renald@partmaker.com> wrote in message 
> news:47de7689@newsgroups.borland.com...
>
>> How can increase the height of the menu item in
>> order to display a bitmap icon by using
>>
>> SetMenuItemBitmaps(hMenu, id, MF_BYCOMMAND, hBitmap, hBitmap);
>
> You have to set the menu item to be owner-drawn.  You can then respond to 
> the WM_MEASUREITEM message for that item.
>
>
> Gambit
>
> 
Technical Details
Message-ID: <47e13843@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!feed.xsnews.nl!border-2.ams.xsnews.nl!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <47de7689@newsgroups.borland.com> <47dea190$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fe96c06e62fe8dc6
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Renald Yazmir" <renald@partmaker.com>
From: "Renald Yazmir" <renald@partmaker.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <47de7689@newsgroups.borland.com> <47dea190$1@newsgroups.borland.com>
Subject: Re: How to increase the height of the menu item?
Date: Wed, 19 Mar 2008 11:58:56 -0500
Lines: 106
Organization: IMCS Inc
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 66.106.28.123
Message-ID: <47e13843@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1205942339 66.106.28.123 (19 Mar 2008 08:58:59 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!feed.xsnews.nl!border-2.ams.xsnews.nl!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail