Article View: borland.public.cppbuilder.nativeapi
Article #505Re: How to increase the height of the menu item?
From: Remy Lebeau (TeamB)
Date: Wed, 19 Mar 2008 16:59
Date: Wed, 19 Mar 2008 16:59
78 lines
3696 bytes
3696 bytes
"Renald Yazmir" <renald@partmaker.com> wrote in message
news:47e13843@newsgroups.borland.com...
> 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.
Your drawing code expects an HWND as input, from which an HDC is retreived.
But menu items do not have an HWND of their own. You need to change your
code to draw onto the HDC that the DRAWITEMSTRUCT provides to you, ie:
draw_transparent_picture_hwnd(lpdis->hDC, PICT_SAVE, &menu_rect, RGB(0,
128, 128));
void draw_transparent_picture(HDC hdc, 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 hMemDC = NULL;
hMemDC = CreateCompatibleDC(hDC);
if( hMemDC == 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);
}
Gambit
Technical Details
Message-ID:
<47e14683@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<47de7689@newsgroups.borland.com> <47dea190$1@newsgroups.borland.com> <47e13843@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 From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <47de7689@newsgroups.borland.com> <47dea190$1@newsgroups.borland.com> <47e13843@newsgroups.borland.com> Subject: Re: How to increase the height of the menu item? Date: Wed, 19 Mar 2008 09:59:56 -0700 Lines: 80 Organization: Lebeau Software 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: 207.178.157.90 Message-ID: <47e14683@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1205945987 207.178.157.90 (19 Mar 2008 09:59:47 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail