News:

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

Main Menu

Cann't load icon via LoadImage

Started by Rockphorr, August 01, 2022, 06:57:12 AM

Previous topic - Next topic

NoCforMe

OK.

Did you try my suggestion?

INVOKE LoadIcon, NULL, IDI_WINLOGO


Works for me. Tell us what you get from this.
Assembly language programming should be fun. That's why I do it.

NoCforMe

JJ; I think you're mistaken about the icon being displayed. When I run my little program on my Windows 2000 machine I get the following, which you can see is different from the icon you showed in your previous post. This is the "ugly gray boring Windows icon", not that other one, which is one of the newer shell icons. Yes?
Assembly language programming should be fun. That's why I do it.

TimoVJL

From WindowsXP things changed, themes arrived.
Just check MS documentation.
May the source be with you

NoCforMe

Yes, I know that. That's what I'm saying: what I just posted is the old W2K look. The other pics are from newer (Win7 in my case) versions. The difference is obvious.
Assembly language programming should be fun. That's why I do it.

jj2007

Quote from: NoCforMe on August 03, 2022, 05:45:10 AM
what I just posted is the old W2K look. The other pics are from newer (Win7 in my case) versions. The difference is obvious.

I have no access to a W2K machine, but I believe you, of course. So instead of the crappy grey icon, you get this colourful icon... but it doesn't change the rule that with LoadIcon, hInstance... you get an icon from the embedded resources of your own exe, while with LoadIcon, NULL... you get some default icon as a friendly gift from Windows ;-)

Quote from: jj2007 on August 02, 2022, 08:04:41 PMThere are two locations in a standard Windows program where to load icons:
A. in WinMain: mov wc.hIcon, rv(LoadIcon, ...
B. in the WM_PAINT handler: invoke DrawIcon, hdc, 10, 10, rv(LoadIcon, ...

The two locations behave differently. In WinMain, if you load an invalid icon, you get this:



This is the ugly default icon for executables, and it dates back to the 20th Century - see also below the AltTab screenshot.

If you load an invalid icon in the WM_PAINT handler, you just see nothing.

If you use LoadIcon, hInstance..., Windows checks in this instance, i.e. in the resources of this exe, for a matching ICON.
If you use LoadIcon, NULL..., Windows checks elsewhere, and finds, in most cases, the crappy grey default icon.

I attach a testbed for playing, 48 lines only - the absolute minimum for a Windows program. Pure Masm32 SDK ;-)

Quote from: Rockphorr on August 03, 2022, 04:36:01 AMI prefer a code style look like inside the debugger.

Have fun :thumbsup:

No problem for 100 line proggies, but once you reach the 1,000 lines, you will have a lot of fun. No arg count, no arg checks, that's a recipe for numerous lovely bugs :biggrin:

NoCforMe

Quote from: jj2007 on August 03, 2022, 06:42:04 AM
Quote from: NoCforMe on August 03, 2022, 05:45:10 AM
what I just posted is the old W2K look. The other pics are from newer (Win7 in my case) versions. The difference is obvious.

I have no access to a W2K machine, but I believe you, of course. So instead of the crappy grey icon, you get this colourful icon... but it doesn't change the rule that with LoadIcon, hInstance... you get an icon from the embedded resoures of your own exe, while with LoadIcon, NULL... you get some default icon as a friendly gift from Windows ;-)

Quite right, old chap. What we're still not sure of is what, exactly, the OP wants. Do they want the "generic" icon or something specific to their executable? In any case, they now have no excuse for not being able to load something, since I've shown that you can use LoadIcon() with a NULL hInstance to load ... something.

BTW, that "crappy" icon isn't gray, it's green. And it is a "new" one, not one that dates back to the 20th century.
Assembly language programming should be fun. That's why I do it.

jj2007

Quote from: NoCforMe on August 03, 2022, 06:56:15 AMBTW, that "crappy" icon isn't gray, it's green. And it is a "new" one, not one that dates back to the 20th century.

Well, it looks grey to me, and it looks old to me :biggrin:

Most probably, I hate it because I associate it with "something went wrong with the resource file" :tongue:



Btw there is also a short Icon Explorer thread (warning: it's MasmBasic :eusa_boohoo:)


Rockphorr

Quote from: jj2007 on August 03, 2022, 02:29:48 AM
Quote from: Rockphorr on August 03, 2022, 02:05:04 AM
   mov   EAX,LR_SHARED
   push   EAX   ;fuLoad
   mov   EAX,32 ;y height
   push   EAX   ;cyDesired

Can you explain, in a few words, the logic of your approach? Why don't you use

push LR_SHARED  ; fuLoad
push 32  ; cyDesired

?

It is my dos legacy code style.

A full solution is in attachment .


It looks awesome on Windows 95. See screens.zip --- I write it for W95 and it is enought for me.

Thanks You all for your help!
Regards.


NoCforMe

QuoteIt is my dos legacy code style.

Bzzzzzt! Bad answer. So you're coding as if you're still writing for the 8088, where you couldn't push constants (or do a lot of other things). So basically you're wearing blinders, saying "La la la la la" while you ignore all the advances that have been made since those days.

Get with the program. You already know basic X86 assembler, so you just need to learn a few new tricks. Believe me, life will be a lot easier.

BTW, congrats on your program working. We expect to see great things from you now.
Assembly language programming should be fun. That's why I do it.