Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > General Discussion
  New Posts New Posts RSS Feed - Using CXTButton with CXTPGraphicBitmapPng
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Using CXTButton with CXTPGraphicBitmapPng

 Post Reply Post Reply
Author
Message Reverse Sort Order
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Topic: Using CXTButton with CXTPGraphicBitmapPng
    Posted: 26 June 2007 at 1:22am
Hello,
 
You can override virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
and draw tranparent part as you need.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
shobits1 View Drop Down
Newbie
Newbie
Avatar

Joined: 18 June 2007
Location: Algeria
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote shobits1 Quote  Post ReplyReply Direct Link To This Post Posted: 25 June 2007 at 5:28pm
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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 25 June 2007 at 1:22am
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
Back to Top
shobits1 View Drop Down
Newbie
Newbie
Avatar

Joined: 18 June 2007
Location: Algeria
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote shobits1 Quote  Post ReplyReply Direct Link To This Post 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 ...
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.109 seconds.