News:

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

Main Menu

Problems loading bitmap from resource

Started by xandaz, November 01, 2020, 11:44:49 PM

Previous topic - Next topic

Greenhorn

Hi xandaz,

is hIml != NULL ?

Is the loaded bitmap compatible to the ImageList (24bit) ?
Have you tried ILC_COLOR32 instead of ILC_COLOR24 ?

Kind regards
Greenhorn
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

xandaz

   hIml is valid. the problem is very likely to be the FLAGS on ImageList_Create. I'm checking that. thanks

xandaz

   Hey...tried all thw flags. dosent work. It only works the previous way. Loading image from file. Could it be because it's a UNICODE app?

xandaz

    These lines of code work perfectlly. I feel like cracking my head about this. Damn OS's have these gliches makes a guy go crazy.
                invoke  ImageList_Create,32,32,ILC_COLOR32,9,18
                mov     hIml,eax
                mov     ecx,9
                lea     esi,mdicreate
                cld
loop_1:
                push    ecx
                invoke  LoadImage,0,esi,IMAGE_BITMAP,32,32,LR_LOADFROMFILE
                invoke  ImageList_AddMasked,hIml,eax,0
loop_2:         
                lodsw
                or      al,al
                jnz     loop_2               
                pop     ecx
                loop    loop_1

jj2007

Quote from: xandaz on November 04, 2020, 06:35:46 AM
    These lines of code work perfectlly

lodsw? Sure it isn't lodsb?

Quote from: xandaz on November 04, 2020, 06:18:07 AMCould it be because it's a UNICODE app?

What do you see in the debugger? Are you passing the correct string, i.e. Ansi for LoadImageA or Unicode for LoadImageW?

xandaz

    no. like i said it's working, those are unicode strings pointed by esi.

xandaz

   Hey thank you guys. Like i said: it's working perfectlly using LoadImage/LR_LOADFROMFILE. Doesn't work with LoadBitmap,hInstance,resource_number. Why the hell is that?

xandaz

    Hey guys again. I got it to work with LoadImage and LR_SHARED Flag set. Problem solved. Thanks a lot guys.

Greenhorn

Try to use LR_CREATEDIBSECTION in LoadImage flags if you load from EXE/DLL.
ILC_COLOR32 creates a DIB section in ImageList_Create.

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadimagew
https://docs.microsoft.com/en-us/windows/win32/controls/ilc-constants

Kind regards
Greenhorn
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

Mikl__


Vortex

Hi xandaz,

You could also try the bitmap from file method :

http://masm32.com/board/index.php?topic=4642.msg49923#msg49923

xandaz