News:

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

Main Menu

Can't load a bitmap resource?!?!?

Started by NoCforMe, May 12, 2024, 07:49:21 AM

Previous topic - Next topic

NoCforMe

Quote from: sudoku on May 12, 2024, 11:50:33 AMI did however need to fix the paths in your batch file. Not all of us have masm32 in our environment 'PATH' or however your setup is configured.
Some "fix". You used forward slashes instead of backslashes:
/masm32/bin/link /SUBSYSTEM:WINDOWS LoadImageTest LoadImageTest_resources
Doesn't work at all.
Assembly language programming should be fun. That's why I do it.

NoCforMe

Quote from: sinsi on May 12, 2024, 11:58:30 AMCheck your .rc file
I checked it. I've checked it like a thousand times. What do you think I've been doing here all this time, jerking off?
Can you be a little more specific?

Total contents of rsrc.rc (which has been renamed thanks to sudoku):
btmap 504 "fixed.bmp"OK, I didn't notice it was mispled.
Total confusion since sudoku waded in and posted umpteen versions, many with errors.
I FIXED IT.
It still doesn't fucking work.
Any more brilliant ideas?
Assembly language programming should be fun. That's why I do it.

zedd151

I'm dyslexic like that.  :biggrin:
Ok. Just remove that for your own path arrangement. It did work for me though, I'm surprised that it did actually.

Nevermind the batch file, just look at the rc file as sinsi also suggested.
Put the resource ID first, then resource type. Then the filename plus extension. :smiley:
Ventanas diez es el mejor.  :azn:

sinsi

Calm down and think. Doesn't a resource script usually go ID, Type, Data?

Your .rc
BITMAP 504 "Plus circle no border (14x14x16).bmp"

My .rc
504 BITMAP "Plus circle no border (14x14x16).bmp"

You should also check for a valid handle from LoadImage before you call GetLastError, as GetLastError returns whatever was left over.
🍺🍺🍺

zedd151

Quote from: sinsi on May 12, 2024, 12:08:22 PMCalm down and think.
:thumbsup:
504 BITMAP "Plus circle no border (14x14x16).bmp"

/* #define MANIFEST 24 */
/* #define IDR_XPMANIFEST1 1 */
/* IDR_XPMANIFEST1 MANIFEST "xpmanifest.xml" */
  :biggrin:
Ventanas diez es el mejor.  :azn:

NoCforMe

You, my friend, just nailed it.

Talk about dyslexic: I had (in another resource file)
bitmap 500 "Plus circle no border (14x14x16).bmp"
bitmap 501 "test 32x32.bmp"
bitmap 502 "test 48x48.bmp"
bitmap 503 "test 96x96.bmp"
bitmap 504 "test 128x128.bmp"
bitmap 505 "test 256x256.bmp"
bitmap 506 "test 64x200.bmp"
bitmap 507 "test 64x300.bmp"
bitmap 508 "test 64x400.bmp"
bitmap 509 "test 200x400.bmp"
bitmap 510 "test 200x500.bmp"
bitmap 511 "test 200x600.bmp"

#define MANIFEST 24
#define IDR_XPMANIFEST1 1
IDR_XPMANIFEST1 MANIFEST "xpmanifest.xml"

Too obvious, I guess.

Just to clear things up:
This had NOTHING to do with "BITMAP" vs "bitmap".
This had NOTHING to do with .nolist/.list.

OK, I guess the drama is over ...
Assembly language programming should be fun. That's why I do it.

zedd151

Was fun while it lasted though.  :greensml: never minding my own errors.  :tongue:
I always use upper case out of convention, I suppose. I just removed the list stuff cause it wasn't needed during testing...
Ventanas diez es el mejor.  :azn:

NoCforMe

Quote from: sinsi on May 12, 2024, 12:08:22 PMYou should also check for a valid handle from LoadImage before you call GetLastError, as GetLastError returns whatever was left over.
That's not the way I understand how that works.
GetLastError() will report the "The specified resource type cannot be found ..." in case of that error from LoadImage(). It will report "The operation completed successfully" in the case of success. So no need to check before calling it.
Assembly language programming should be fun. That's why I do it.

NoCforMe

Quote from: sudoku on May 12, 2024, 12:15:12 PMWas fun while it lasted though.  :greensml: never minding my own errors.  :tongue:
BTW, all I can say is that I absolutely hate your batch file. What, it closes my DOS command window that I had to steer to the right folder and everything?

Other than that, no problemo.
Assembly language programming should be fun. That's why I do it.

zedd151

Lemme guess, you run batch files by opening the command prompt and then opening the batch file? Just double click on the batch file, much easier. If it closes, it means assembly was successful, else it pauses for you to see the errors.  :cool:   To each, their own I suppose.
Ventanas diez es el mejor.  :azn:

NoCforMe

OK, there is one remaining mystery:
So I used completely wrong syntax in my resource file. And yet, somehow those bitmaps did end up in the .exe (use PE Explorer if you don't believe me). With the correct IDs, no less.
So how is it that the PE program could find them but not LoadImage()?
Probably because the actual resource entries were somehow malformed, and all that PE Explorer is doing is locating blocks of data that it thinks must be a resource without actually validating it.
Although PE Explorer was able to display the bitmaps correctly ...
Assembly language programming should be fun. That's why I do it.

NoCforMe

Quote from: sudoku on May 12, 2024, 12:20:30 PMLemme guess, you run batch files by opening the command prompt and then opening the batch file? Just double click on the batch file, much easier. If it closes, it means assembly was successful, else it pauses for you to see the errors.  :cool:  To each, their own I suppose.
I like to leave the command window open because I can do other things than just run batch files there. Don't like that whole having to "hit any key to continue" thing.

Instead of navigating to different folders in Explorer to work on different projects (well, I do that too, to open different source files), I use 4DOS's indispensible pushd/popd facility, where I can zip over to another folder, work on a project there, then popd to get back to where I was before.

So much nicer than the Windows cmd.exe.
Assembly language programming should be fun. That's why I do it.

zedd151

Sounds like a big mystery to be solved. Yes, the original exe did have the bitmap. Odd that rc.exe (or cvtres) did not complain about it.  Okay, so you're not using cmd.exe like I had thought. Interesting.
Ventanas diez es el mejor.  :azn:

sinsi

Quote from: NoCforMe on May 12, 2024, 12:15:43 PM
Quote from: sinsi on May 12, 2024, 12:08:22 PMYou should also check for a valid handle from LoadImage before you call GetLastError, as GetLastError returns whatever was left over.
That's not the way I understand how that works.
GetLastError() will report the "The specified resource type cannot be found ..." in case of that error from LoadImage(). It will report "The operation completed successfully" in the case of success. So no need to check before calling it.
Quote from: GetLastErrorsome functions set the last-error code to 0 on success and others do not.

Quote from: sudoku on May 12, 2024, 12:26:02 PMSounds like a big mystery to be solved. Yes, the original exe did have the bitmap. Odd that rc.exe (or cvtres) did not complain about it.
rc.exe just assumed that you knew what you were doing :biggrin: and used bitmap as the ID and 504 as the Type (see the "manifest" example, it uses 24 as the Type)



Stop masturbating so much, it makes you blind to your mistakes, obviously

🍺🍺🍺

zedd151

@sinsi:

1 24 "manifest.xml"Yes, 24 is the type.  :biggrin:
1 is the ID.
Ventanas diez es el mejor.  :azn: