Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Loading icon with alpha for use with XTP
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Loading icon with alpha for use with XTP

 Post Reply Post Reply
Author
Message
robosport View Drop Down
Groupie
Groupie


Joined: 20 June 2005
Location: United States
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote robosport Quote  Post ReplyReply Direct Link To This Post Topic: Loading icon with alpha for use with XTP
    Posted: 27 April 2007 at 1:56am
I have a full color icon with alpha channel (okay, lots of icons). For the last couple years I've used the CommandBar designer to input icons as part of the interface I made with XTP and MFC.
 
I'm making a dynamic menu now and the icons are loaded at runtime either from memory buffer or from ICO file. I'm using the same ICO file imported into CommandBar Designer (and using Axialis) to confirm the icon has all the bits including alpha included in the file.
 
My question is: What is the correct way to load an icon, either from ICO file or from bits in memory, so that it works correctly with XTP's controls and compositing. When I use ExtractIcon it doesn't preserve the alpha. When I use LoadImage I get mixed results based on settings but nothing seems quite right. 
 
Any pointers are appreciated.

Thanks!
Back to Top
robosport View Drop Down
Groupie
Groupie


Joined: 20 June 2005
Location: United States
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote robosport Quote  Post ReplyReply Direct Link To This Post Posted: 27 April 2007 at 3:12am
Here is a little more information... my app is using the icon shadows and faded icons features of the paint manager.
 
When I turn off icon shadows and faded icons the imported icons (using LoadImage) work perfectly.
 
When I have faded icons turned on the icon doesn't show up (except for a very very faint outline on right and bottom). WHen I mouse over the icon (turning off the faded state) the icon looks perfect.
 
When I have icon shadows turned on the icon offsets correctly when moused over but the shadow is not drawn (again except for the very very faint edge).
 
Do I have to do something special with the HICON other than SetCustomIcon when adding it to the dynamically generated button for these two features to work?
 
Thanks!
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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: 27 April 2007 at 4:00am
Hi,
 
Don't use LoadImage or SetCustomIcon.
 
use this method:
BOOL CXTPImageManager::SetIcon(UINT nIDResourceIcon, UINT nIDCommand, CSize szIcon, XTPImageState imageState)
 
 
where nIDResourceIcon is your Alpha ico file resource. - it will load alpha icon and set it for nIDCommand command.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
robosport View Drop Down
Groupie
Groupie


Joined: 20 June 2005
Location: United States
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote robosport Quote  Post ReplyReply Direct Link To This Post Posted: 27 April 2007 at 4:06am

Does CXTPImageManager::SetIcon work with an external ICO file or a memory buffer (preferably), or am I forced to use a resource ID from my EXE (or other resouce DLL)?

Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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: 27 April 2007 at 6:51am
Hi,
You can load external ICO with
 
HBITMAP CXTPImageManagerIcon::LoadAlphaIcon(LPCTSTR pszFileName, int nWidth)
method and then add it with
CXTPImageManager::SetIcon(CXTPImageManagerIconHandle hIcon, UINT nIDCommand, CSize szIcon, XTPImageState imageState)
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
robosport View Drop Down
Groupie
Groupie


Joined: 20 June 2005
Location: United States
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote robosport Quote  Post ReplyReply Direct Link To This Post Posted: 27 April 2007 at 12:55pm
Thanks Oleg!
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.031 seconds.