Print Page | Close Window

MFC using xaml for HICON

Printed From: Codejock Forums
Category: General
Forum Name: XAML Snippets
Forum Description: Post your XAML snippets here for everyone to enjoy :)
URL: http://forum.codejock.com/forum_posts.asp?TID=24397
Printed Date: 29 April 2024 at 1:57am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: MFC using xaml for HICON
Posted By: Duane
Subject: MFC using xaml for HICON
Date Posted: 19 May 2023 at 11:34am
How can I create an HICON from an  XAML resource?

I've tried

HICON hIcon = (HICON)::LoadImage(theApp.m_hInstance, MAKEINTRESOURCE(IDR_LOGO), IMAGE_ICON, szIcon.cx, szIcon.cy, LR_SHARED);

But hIcon here is NULL.  

Is this possible?  I am able to add that resource to an image vector and use it for a ribbon without problem.



Replies:
Posted By: astoyan
Date Posted: 28 May 2023 at 3:40pm
Hello Duane,

It is possible to make an HICON from XAML by rendering XAML into a bitmap and then making an icon from that bitmap manually. But that is not only a tedious work, but also a useless and pointless one as the whole point of having XAML icons is to ensure that you need only one XAML image to handle or possible icon sizes and to ensure a crisp and scalable image. Look for SetVectorIcon calls in ToolkitPro samples, like RibbonSample and similar.

Regards,
   Alexander


Posted By: Duane
Date Posted: 29 May 2023 at 8:43am
Thanks for the reply.  I guess my question was poorly worded.  I am not specifically looking to convert an XAML into an HICON.  I want to be able to use the XAML as the frame icon.  I am able to use SetVectorIcon for the ribbon without problem.  But the frame icon in the sample is using CXTPFramePaintManager.  And this doesn't have a SetVectorIcon member.  



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