Using CXTButton with CXTPGraphicBitmapPng |
Post Reply |
Author | |
shobits1
Newbie Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16 |
Post Options
Thanks(0)
Posted: 24 June 2007 at 2:16pm |
Hello very one,,
I tired in search for using CXTButton with CXTPGraphicBitmapPng so please help me if you can.
I know that there are many way to load CXTButton with icon or bitmap, but I want to use PNG image in my CXTButton.
Why should I use it: after the success help of oleg to how draw a PNG image (PNG with alpha layer) correctly (see: http://forum.codejock.com/forum_posts.asp?TID=7402 )
I used it in my own controls, some of these PNG are like icons in size (48x48) so for reduce the size of my resource and help my program to execute rapidly (use the preloaded image in my CXTPGraphicBitmapPng objects), I decided to use these CXTPGraphicBitmapPng but when I try to add it in CXTButton, I fail, the two function used in CXTButton to set icon or image are:
BOOL SetBitmap( CSize size, UINT nID, BOOL bRedraw = TRUE);
And
BOOL SetIcon( CSize size, HICON hIcon, HICON hIconHot = NULL, BOOL bRedraw = TRUE);
BOOL SetIcon( CSize size, UINT nID, UINT nHotID = 0, BOOL bRedraw = TRUE);
BOOL SetIcon( CSize size, LPCTSTR lpszID, LPCTSTR lpszHotID = NULL, BOOL bRedraw = TRUE);
BOOL SetIcon( CSize size, CXTPImageManagerIconHandle hIconHandle, CXTPImageManagerIconHandle hIconHotHandle, BOOL bRedraw = TRUE);
I can't use the first one because my Images are stored externally, so I try with SetIcon (exactly with the last one), I think to convert my CXTPGraphicBitmapPng to CXTPImageManagerIconHandle, or create CXTPImageManagerIconHandle object by using CXTPGraphicBitmapPng as HBITMAP but it can't be helped
What I want:
1- If possible how I can set image for CXTButton using CXTPGraphicBitmapPng;
2- How I can set CXTButton image (this image is PNG sorted externally in Dll file);
3- How I can create a valid icon with alpha layer using CXTPGraphicBitmapPng;
4- Is CXTButton support icons with alpha layer, if not how I can use it with these icons;
Note: all my PNG files are images with alpha layer and sorted in resource file externally this resource file is a Dll file.
Thanks to every one ... |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
you need 4th method and load image using methods of CXTPImageManagerIconHandle/CXTPImageManagerIcon:
CXTPImageManagerIconHandle hIconHandle;
BOOL bAlphaBitmap = FALSE;
HBITMAP hBitmap = CXTPImageManagerIcon::LoadBitmapFromResource(MAKEINTRESOURCE(nID), &bAlphaBitmap); if (!hBitmap)
return FALSE; if (bAlphaBitmap)
{ hIconHandle = hBitmap; // Will call DeleteObject; } else { CBitmap bmpIcon; bmpIcon.Attach(hBitmap); // convert the bitmap to a transparent icon.
HICON hIcon = CXTPTransparentBitmap(bmpIcon).ConvertToIcon(); hIconHandle = hIcon; // Will call DestoyIcon;
} if (hIconHandle.IsEmpty())
return FALSE; return CXTButton::SetIcon(size, hIconHandle, CXTPImageManagerIconHandle(), bRedraw);
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
shobits1
Newbie Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16 |
Post Options
Thanks(0)
|
It's ok and work fine, how ever some area of my PNG image are transparent and I want to make my button transparent in this area too
is there any method that do it or I must use the BS_OWNERDRAW style then define my draw function
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hello,
You can override virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
and draw tranparent part as you need. |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |