The MASM Forum

General => The Workshop => Topic started by: Siekmanski on July 26, 2020, 08:18:07 PM

Title: A strange thing happened.
Post by: Siekmanski on July 26, 2020, 08:18:07 PM
Setting up a framework and loading a PNG icon and changing it into a CURSOR. ( getting a smaller executable size )
A strange thing happened.

In filemanager and taskmanager the Hand cursor shows up as the file icon???
It should be the Palette icon.

What am I doing wrong here?
Can't figure it out.  :undecided:
Title: Re: A strange thing happened.
Post by: daydreamer on July 26, 2020, 09:37:38 PM
I checked many resource files and everything is numbered over 100,so maybe
IDI_APPLICATION constant =100 or some other windows constant already is 100,so second line redefines IDI_APPLICATION to hand icon
Title: Re: A strange thing happened.
Post by: hutch-- on July 26, 2020, 09:42:32 PM
Nah, its just handy but note that some OS functions use resource ID numbers below 100. From memory you can go up to 64k.
Title: Re: A strange thing happened.
Post by: Siekmanski on July 26, 2020, 09:46:41 PM
Tried higher resource ID numbers, it didn't solve it.
Title: Re: A strange thing happened.
Post by: jj2007 on July 26, 2020, 10:38:20 PM
Quote from: Siekmanski on July 26, 2020, 08:18:07 PMIt should be the Palette icon

Your original exe, Win7-64

The mouse pointer is a hand, indeed.
Title: Re: A strange thing happened.
Post by: Siekmanski on July 26, 2020, 11:17:51 PM
Yes, it shows up correctly with the Palette icon on the taskbar.
But if you look into file manager or task manager it shows the Hand image as the file icon.
Very strange....
Title: Re: A strange thing happened.
Post by: hutch-- on July 27, 2020, 12:12:03 AM
Its probably the case that Windows expects the first icon to be an ICO icon and it may just treat a PNG file as another resource rather than the main icon.
Title: Re: A strange thing happened.
Post by: daydreamer on July 27, 2020, 01:44:15 AM
What about use loadicon after cursor code part?
Title: Re: A strange thing happened.
Post by: JK on July 27, 2020, 02:06:24 AM
AFAIK not the first icon in the resource file but the icon with the lowest id in alpha order is shown as an exe´s icon. So in terms of alpha order "100" comes before "IDI_APPLICATION". I would try to rename "100" to maybe "Hand" (HAND ICON "Res\handpointer64.ico")


JK
Title: Re: A strange thing happened.
Post by: Siekmanski on July 27, 2020, 02:52:28 AM
Thanks JK.

That did the trick.
Lowest resource ID number is the main Icon.  :thumbsup:
Title: Re: A strange thing happened.
Post by: daydreamer on July 27, 2020, 08:05:08 AM
Quote from: Siekmanski on July 27, 2020, 02:52:28 AM
Thanks JK.

That did the trick.
Lowest resource ID number is the main Icon.  :thumbsup:
Maybe that explains why I see vc uses one ID that's -1 to guarantee it's the lowest
Title: Re: A strange thing happened.
Post by: jj2007 on July 27, 2020, 08:32:11 AM
Quote from: Siekmanski on July 27, 2020, 02:52:28 AM
Lowest resource ID number is the main Icon.  :thumbsup:

I can't reproduce this behaviour - this code produces the "Eye" icon :sad:
  mov wc.hIcon, rv(LoadIcon, eax, IDI_APPLICATION)
  mov wc.hIconSm, eax

#include "resource.h"
100 ICON "\\Masm32\\MasmBasic\\icons\\Smiley.ico"
IDI_APPLICATION ICON "\\Masm32\\MasmBasic\\icons\\Eye.ico"
01 RT_MANIFEST "\\Masm32\\MasmBasic\\Res\\XpManifest.xml"
Title: Re: A strange thing happened.
Post by: Siekmanski on July 27, 2020, 08:35:00 AM
Hi Magnus,

I tried -1 for the file icon but, that didn't work.
Now I have 1000 and 1001 ( the Hand cursor ) as the resource ID's and it works like a charm.  :eusa_dance:

Hi Jochen,

Set the eye.ico to 99 101 and it probably works.

EDIT: 99 has to be 101
Title: Re: A strange thing happened.
Post by: Siekmanski on July 27, 2020, 08:48:25 AM
Another thing,
I created the icons with PNG images.
If I create a PNG cursor, the resource compiler chokes on it. ( only 1 byte is changed -> cursor ID )
That's why I load it as an icon and change it into a cursor in the source code.
Title: Re: A strange thing happened.
Post by: jj2007 on July 27, 2020, 10:29:25 AM
Quote from: Siekmanski on July 27, 2020, 08:35:00 AMSet the eye.ico to 99 101 and it probably works.

Try putting #include "resource.h" on top of the rc file :cool:

I've tried some varieties with my icons, but IDI_APPLICATION always wins:
#include <\masm32\INCLUDE\RESOURCE.H>
; #include "resource.h"
101 ICON "\\Masm32\\MasmBasic\\icons\\Smiley.ico"
IDI_APPLICATION ICON "\\Masm32\\MasmBasic\\icons\\plot.ico"


Note that the resource compiler does not throw errors if it encounters undefined constants such as IDI_APPLICATION :cool:

Besides, Windows is sometimes confused: If the exe has the smiley in Explorer, when running it may still have the previous icon.
Title: Re: A strange thing happened.
Post by: Siekmanski on July 27, 2020, 10:59:20 AM
It was included before this issue.

It was IDI_APPLICATION that messed things up for me.
Title: Re: A strange thing happened.
Post by: daydreamer on July 27, 2020, 08:09:31 PM
here take a look how it uses -1 and MY_ICON 2
it also uses help popup and file menu and shortcuts in .rc file as code style instead of masm messagebox with text macros for caption and text
http://masm32.com/board/index.php?topic=8581.0 (http://masm32.com/board/index.php?topic=8581.0)
Title: Re: A strange thing happened.
Post by: Siekmanski on July 27, 2020, 08:43:38 PM
Hi Magnus,

Quote/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.

This is exactly what JK pointed me at.

ID value: IDI_APPLICATION = 32512 ( was my application icon )
The ID value of the hand pointer icon was lower, hence my problem.
But it is solved now.
Title: Re: A strange thing happened.
Post by: daydreamer on August 15, 2020, 04:57:39 AM
wonder what settings you exported your icon files with?
I tried inspired by this thread,but it blows up exe
first attempt is some simple drawing in paint png->ico
second attempt a Blonde.png->ico
Title: Re: A strange thing happened.
Post by: Siekmanski on August 15, 2020, 05:03:19 AM
They are PNG files.
Title: Re: A strange thing happened.
Post by: daydreamer on August 16, 2020, 09:15:11 AM
I want to make it a PROC for cursorchanges,some I seen in games,cursor changes to different things depending on what it points to
must it be a 64x64 to work?
using 101,102,103,104 and I get exclamation mark,question mark and all kinds of default windows icons
trying to set my custom ICON it works as ICON
trying to set it as cursor,it shows circle(busy icon) and keeps going until I stop it with ctrl-alt-delete