dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic Classic (6 and earlier)
Expertise: Advanced
Oct 15, 2015

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Converting PNG to HICON

Loading any PNG resource as an hIcon. Vista introduced PNG encoding for icons. There is an API that will convert PNGs to valid hIcon handles. API Declaration follows:

Private Declare Function CreateIconFromResourceEx Lib "user32.dll" ( _
   pbIconBits As Any, ByVal cbSize As Long, ByVal fIcon As Long, _
   ByVal dwVersion As Long, ByVal cxDesired As Long, _
   ByVal cyDesired As Long, ByVal uFlags As Long) As Long

Simple example.

Let's say you have the entire PNG image format in a zero-bound byte array, maybe loaded from file or form a resource, or within an actual ICO/CUR file. The API only needs to know where in the byte array that the PNG format begins. No icon directory or other icon header information is required.

hIcon = CreateIconFromResourceEx(pngData(0), UBound(pngData) + 1, 1, &H30000, 0, 0, 0)

Of course, you would destroy the hIcon when it is no longer needed.

Keith
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date