Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

LoadImage + IMAGE_ICON -> how to select a sub-icon ?

144 views
Skip to first unread message

R.Wieser

unread,
May 21, 2013, 8:32:17 AM5/21/13
to
Hello All,

I never noticed it before, but I've got a bit of a problem with the
LoadImage function: I'm using it to load a 16x16 image from an Icon (which I
subsequently use in the SystemTray), but what gets displayed is a schrunken
version of the 32x32 sub-icon, not the -- better fitting -- 16x16 sub-icon.

So, my question: Is there a way to tell LoadImage to grab either the
best-fitting sub-icon or to indicate which sub-icon should be taken ?

If not, is there another command which does provide it ?

P.s.
the LR_LOADREALSIZE flag does not seem to exist anymore.

P.p.s.
I can ofcourse just load an icon only containing a 16x16 sub-icon, but than
I would have it twice in my app (once inside the app-icon, once
stand-alone).



David Lowndes

unread,
May 21, 2013, 9:01:34 AM5/21/13
to
>So, my question: Is there a way to tell LoadImage to grab either the
>best-fitting sub-icon or to indicate which sub-icon should be taken ?

Have you tried supplying the correct sizes in the cxDesired &
cyDesired parameters?

Dave

R.Wieser

unread,
May 21, 2013, 9:41:12 AM5/21/13
to
Hello David,

> Have you tried supplying the correct sizes in the
> cxDesired & cyDesired parameters?

Well, I think that is what I started with, as I knew I needed a 16x16 image
for it to be usable in the SysTray.

Currently the full line is:

call LoadImageA,eax,[@@IconResID],IMAGE_ICON,16,16,LR_SHARED

with "eax" being ofcourse the module handle, and "@@IconResID" being the
(argument holding the) resource ID (as defined in the resource file).

Regards,
Rudy Wieser


-- Origional message:
David Lowndes <Dav...@example.invalid> schreef in berichtnieuws
00smp8pivucgqtuku...@4ax.com...

David Lowndes

unread,
May 21, 2013, 11:41:27 AM5/21/13
to
>Currently the full line is:
>
>call LoadImageA,eax,[@@IconResID],IMAGE_ICON,16,16,LR_SHARED

Try without LR_SHARED.

The documentation notes:

"Do not use LR_SHARED for images that have non-standard sizes"

Dave

R.Wieser

unread,
May 21, 2013, 4:13:55 PM5/21/13
to
Hello David,

> Try without LR_SHARED.

Well, you got something there. Just not what you thought it would be:

I used a test-app which simply puts an icon in the systray. I loaded the
offending icon into the resource file, referenced it and displayed it in the
systray. And whatdoyouknow, it worked perfectly (displaying the 16x16
sub-icon), even though it still had that LR_SHARED argument. [huh?]

Than I got a hunch, and also used, as I did in the malfuntioning app, that
icon also as the one for the app itself (LoadIcon, WM_SETICON) (before
trying to place it in the systray). After that the I got the wrong result
again. [eureka!]

After that I removed the LR_SHARED flag, after which it again behaved as I
wanted it to (displaying the 16x16 sub-icon).

It looks like its not really the LR_SHARED flag or the "nonstandard sizes"
causing the troubles, but the, as far as I can see, fact that that flag
causes it to use a previously-loaded icon, even if it doesn't have the right
dimensions ...

In short, its the sharing-mechanism which seems to act a little dumb :-\
Oh well, another quirk I need to try to remember. :-)

Thanks for your help

Regards,
Rudy Wieser


-- Origional message:
David Lowndes <Dav...@example.invalid> schreef in berichtnieuws
fb5np853i44vof9f7...@4ax.com...

Deanna Earley

unread,
May 22, 2013, 4:09:17 AM5/22/13
to
On 21/05/2013 21:13, R.Wieser wrote:
> It looks like its not really the LR_SHARED flag or the "nonstandard sizes"
> causing the troubles, but the, as far as I can see, fact that that flag
> causes it to use a previously-loaded icon, even if it doesn't have the right
> dimensions ...
>
> In short, its the sharing-mechanism which seems to act a little dumb :-\
> Oh well, another quirk I need to try to remember. :-)

That's exactly what it's documented to do:
> This function finds the first image in the cache with the requested resource name, regardless of the size requested.

--
Deanna Earley (dee.e...@icode.co.uk)
iCatcher Development Team
http://www.icode.co.uk/icatcher/

iCode Systems

(Replies direct to my email address will be ignored. Please reply to the
group.)

R.Wieser

unread,
May 22, 2013, 5:26:35 AM5/22/13
to
Hello Deanna

> That's exactly what it's documented to do: <snip>

I could have sworn I had read the LR_SHARED documentation carefully. Oh
well, a fine example of how my assumed understanding of that flag (even
after doubding it!) got in the way of actually (re)absorbing what was
written. :-\

Thanks for the heads-up.

Regards,
Rudy Wieser


-- Origional message:
Deanna Earley <dee.e...@icode.co.uk> schreef in berichtnieuws
knhufb$u10$1...@speranza.aioe.org...
0 new messages