Thread View: borland.public.cppbuilder.nativeapi
6 messages
6 total messages
Started by Renald Yazmir
Mon, 17 Mar 2008 14:47
How to increase the height of the menu item?
Author: Renald Yazmir
Date: Mon, 17 Mar 2008 14:47
Date: Mon, 17 Mar 2008 14:47
14 lines
1183 bytes
1183 bytes
Hello 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); Thank you Rony
Re: How to increase the height of the menu item?
Author: Remy Lebeau (TeamB)
Date: Mon, 17 Mar 2008 16:50
Date: Mon, 17 Mar 2008 16:50
14 lines
1348 bytes
1348 bytes
"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
Re: How to increase the height of the menu item?
Author: Alan Bellingham
Date: Wed, 19 Mar 2008 16:14
Date: Wed, 19 Mar 2008 16:14
17 lines
1577 bytes
1577 bytes
"Renald Yazmir" <renald@partmaker.com> wrote: >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)); Any particular reason why you've decided not to draw using lpdis->hDC? Alan Bellingham -- Team Browns ACCU Conference 2008: 2-5 April 2008 - Oxford (probably), UK
Re: How to increase the height of the menu item?
Author: Renald Yazmir
Date: Wed, 19 Mar 2008 16:58
Date: Wed, 19 Mar 2008 16:58
104 lines
3897 bytes
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
>
>
Re: How to increase the height of the menu item?
Author: 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
Re: How to increase the height of the menu item?
Author: 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
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads