Print Page | Close Window

Loading icon with alpha for use with XTP

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=6998
Printed Date: 12 November 2025 at 7:36pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Loading icon with alpha for use with XTP
Posted By: robosport
Subject: Loading icon with alpha for use with XTP
Date 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!



Replies:
Posted By: robosport
Date 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!


Posted By: Oleg
Date 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


Posted By: robosport
Date 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)?



Posted By: Oleg
Date 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


Posted By: robosport
Date Posted: 27 April 2007 at 12:55pm
Thanks Oleg!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net