Article View: borland.public.cppbuilder.nativeapi
Article #506Re: How to increase the height of the menu item?
From: Renald Yazmir
Date: Wed, 19 Mar 2008 19:30
Date: Wed, 19 Mar 2008 19:30
88 lines
4161 bytes
4161 bytes
Thank you very much!
It works!!!
Rony.
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:47e14683@newsgroups.borland.com...
>
> "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:
<47e15bab$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder2.cambrium.nl!feed.tweaknews.nl!193.201.147.68.MISMATCH!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<47de7689@newsgroups.borland.com> <47dea190$1@newsgroups.borland.com> <47e13843@newsgroups.borland.com> <47e14683@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> <47e13843@newsgroups.borland.com> <47e14683@newsgroups.borland.com> Subject: Re: How to increase the height of the menu item? Date: Wed, 19 Mar 2008 14:30:01 -0500 Lines: 90 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: <47e15bab$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1205951403 66.106.28.123 (19 Mar 2008 11:30:03 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder2.cambrium.nl!feed.tweaknews.nl!193.201.147.68.MISMATCH!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail