News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

How to add 32-bit icons

Started by Professor, July 29, 2024, 09:42:53 AM

Previous topic - Next topic

stoo23

Gee, I think I'd be wanting to 'ditch' Windows 8.1 and move to Windows 10.
You may find it all just works better  :smiley:

NoCforMe

Does that unwanted behavior survive a reboot?
Assembly language programming should be fun. That's why I do it.

TimoVJL

May the source be with you

jj2007

Try converting the *.ico to *.png

I can't test it right now.

Professor

Quote from: stoo23 on July 30, 2024, 02:43:07 PMGee, I think I'd be wanting to 'ditch' Windows 8.1 and move to Windows 10.
You may find it all just works better  :smiley:

You could be right. That said, I'm not always convinced by the relentless drive forwards. Continuously adding complexity doesn't guarantee reduced problems!

stoo23

I only suggest it as had a good old friend that had been having endless weird issues with her 8.1 laptop.
Once upgraded to 10,.. she had no further problems.

QuoteContinuously adding complexity doesn't guarantee reduced problems!
Understood but you ARE virtually there anyway,.. 8.1 is just a rather Badly formed 10  :smiley:

I honestly Don't think you would be wishing you didn't upgrade after doing so  :wink2:

jj2007

Quote from: stoo23 on August 01, 2024, 11:26:38 AM8.1 is just a rather Badly formed 10

I jumped from 7 to 10 and confirm that Win10 is running rather smoothly. Hutch, btw, also liked Win10. But I will continue to ignore the invitation to install Win11 on this machine. That one must mature a couple of years :cool:

Professor

Quote from: jj2007 on July 30, 2024, 09:42:46 PMTry converting the *.ico to *.png

I'm loving the idea that Windows has moved on from the dated .ico format and is now embracing the far more versatile .png format. I immediately tried this, only to get the following compilation error:
JPGExtra3.rc (4): error RC2175 : resource file JPGExtra_48x48_v2_32bit.png is not in 3.00 format

Microsoft's help pages aren't particularly helpful:
The specified resource used a format earlier than version 3.00. The resource file must be converted or recreated using the format for version 3.00 or later.

I'll keep experimenting...

jj2007

See this SOF post. The second answer involves Gdi+, maybe that's a way to do it. I don't have time to test it right now, sorry...

stoo23

QuoteI jumped from 7 to 10 and confirm that Win10 is running rather smoothly
Yeah, so did I on the laptop, it was well configured i7 8 gig ram etc and the update process went very smoothly and the machine has been faultless since the upgrade !!

I like Win 7 but also am completely happy with the Win 10 installations I have  :thumbsup:

Professor

Quote from: jj2007 on August 01, 2024, 05:37:02 PMSee this SOF post. The second answer involves Gdi+, maybe that's a way to do it. I don't have time to test it right now, sorry...

Interesting – thanks! I wasn't aware of the 32-bit "premultiplied alpha" bitmap format.

Professor

Thanks also to various folks for their advice on Win-10. About a year ago I upgraded my partner's computer to Win-10 (I've been a PC specialist since the 1990s) and it had been mostly smooth sailing ever since. Her bluetooth-enabled hearing aids now get intermittent audio, so we reverted to good-old-fashioned headphones! (*sigh*)

Professor

After experiencing much frustration with all of this back in August, I finally gave in, resigning myself to revisiting the issue with a fresh mind at a later date. And so here we are in the New Year!

This is where I'm at currently – hopefully some of this helps others.

My original approach had three separate .ico files specified in the resource file – one each for 48x48, 32x32 and 16x16 pixels. When my program starts, I load the 32x32 icon, feed the handle to "wc.hIcon", load the 16x16 icon, feed that handle to "wc.hIconSm". Easy enough!

Windows Explorer would also display the embedded 48x48 icon when the .exe was viewed on the desktop or in a folder. When Explorer's folder view was changed to "Extra large icons" or "Large icons", the icon was small but still adequate. However, when the view was set to "Small icons", "List" or "Details", for which it *should* load the 16x16 icon, it instead rescaled that 48x48 down to 16x16 – which looked awful.

I could instead have the 16x16 icon appear first in the resource file, with the opposite result of showing the 16x16 icon in each different view. Not great either! In addition, the 48x48 icon then goes to waste – unless someone specifically creates a shortcut and changes the icon to the third one listed.

Okay, that was my original approach. After much research, I finally hit on the solution.

Windows Explorer will always load the first – or lowest numbered – icon resource from the .exe file. However, if that icon resource contains more than one size of icon, Explorer will load the appropriate sized icon to suit the view.

I therefore created a single .ico file containing all three sizes: 48x48, 32x32 and 16x16. I then found how to set the correct parameters to "LOADIMAGE" to similarly load the correct sized icon from that single icon file.

Just to be safe, rather than hard-code my source with "16" or "32" for the "cx" and "cy" parameters, I figured it would be better to allow for computer setups where people have adjusted their system to display larger or smaller icons than the "standard" sizes.

Here, then, is the final code that worked:

Resource file:
#define IanIcons 100
IanIcons ICON DISCARDABLE JPGExtra_v2_483216x32.ico

Assembler file:
IanIcons        EQU 100                ;48/32/16 x 32-bit icons
...
INVOKE GetSystemMetrics, SM_CXICON            ;Large icon width
INVOKE LoadImage, wc_hInstance, IanIcons, IMAGE_ICON, EAX, EAX, LR_SHARED
MOV wc_hIcon, EAX
INVOKE GetSystemMetrics, SM_CXSMICON            ;Small icon width
INVOKE LoadImage, wc_hInstance, IanIcons, IMAGE_ICON, EAX, EAX, LR_SHARED
MOV wc_hIconSm, EAX

All's good now – except for implementing 256x256 pixel icons. Try as I might, I haven't been able to succeed with these! The error always occurs at the resource compiler stage. I get one of two messages:

JPGExtra3.rc (8): error RC2176 : old DIB in JPGExtra_v2_256x32.ico; pass it through SDKPAINT
- or -
JPGExtra3.rc (8): error RC2175 : resource file JPGExtra_v2_256x32.bmp is not in 3.00 format

I'm guessing these are due to an older version of rc.exe? In any case, I'm not that keen on quadrupling the finished size of my nice tiny .exe file, so I'll leave it for another day. The small icons are more than sufficient for their task.