Hi all,

the guys from masmforum advised me to start using RadASM since i have troubles putting a picture into a dialogbox.
Started with RadASM 3 hours ago and i must say i really like it. I've read the 6 tutorials on the RadASM page, but none can help me solve my problem.

Here's the issue:

This is how my program should look like (the picture placed at least).

I've did above in VB, it's just an empty GUI. I've done the same thing with RadASM now by selecting the Image button, created a square, choose bitmap as type, and selected the image.

In the designer it looks great, but when i assemble the program it doesn't show the picture.
I understand that i probably have to use LoadImageA or LoadBitmap to solve this issue, but i can't get it to work.

Any help would be highly appreciated.

btw, i'm using masm.
Posted on 2006-05-26 16:50:27 by white scorpion
White Scorpion,
Hi, how are you?  I haven't talked to you in a while.  Anyway, I am attaching my Calculator program.  If you run it, click Information, then About - it will show a dialog box that has a picture in it.  Study the source.

hth,
Paul
Attachments:
Posted on 2006-05-26 18:02:56 by PBrennick
It's been a while indeed. I'm fine but terribly busy...
I hope you are fine as well!

i just found the solution to my problem (finally...):

.elseif uMsg==WM_PAINT
        invoke LoadBitmap,hInstance,501
        mov hBitmap,eax
        invoke BeginPaint,hWnd,ADDR ps
        mov hdc,eax
        invoke CreateCompatibleDC,hdc
        mov hmem,eax
        invoke SelectObject,hmem,hBitmap
        invoke GetClientRect,hWnd,ADDR rc
        invoke BitBlt,hdc,5,5,rc.right,rc.bottom,hmem,0,0,SRCCOPY
        invoke DeleteDC,hmem
        invoke EndPaint,hWnd,addr ps
        xor eax,eax   
        ret

That was what i was missing.
Nevertheless i'm still interested in your calculator  ;)


Just took a look at your calculator and i'm keeping it for future reference. it is a great resource for some other problems i had in the past that are still unresolved (clickable link, image on button, etc).
Posted on 2006-05-26 18:06:06 by white scorpion
Leakage :shock:

You should Load your Bitmap at the start and DeleteObject it at the end of the program.

To correct this reorganize your code as follows:

.elseif uMsg==WM_INITDIALOG
invoke LoadBitmap,hInstance,501
mov hBitmap,eax
.elseif uMsg==WM_CLOSE
invoke DeleteObject, hBitmap
.elseif uMsg==WM_PAINT
invoke BeginPaint,hWnd,ADDR ps
mov hdc,eax
invoke CreateCompatibleDC,hdc
mov hmem,eax
invoke SelectObject,hmem,hBitmap
invoke GetClientRect,hWnd,ADDR rc
invoke BitBlt,hdc,5,5,rc.right,rc.bottom,hmem,0,0,SRCCOPY
invoke DeleteDC,hmem
invoke EndPaint,hWnd,addr ps
;xor eax,eax ;probably not needed as there is a
;ret ;xor eax,eax | ret at the end of the wndproc anyway
.endif


The code in your current condition loads the same bitmap every iteration of WM_PAINT and doesn't free the handle.
Posted on 2006-05-26 18:50:57 by JimmyClif
I see what you mean..
Thanks for pointing it out, i will correct it right away  :lol:
Posted on 2006-05-27 05:09:15 by white scorpion
Well, instead of painting the image on WM_PAINT, you can just assign the image to the static control. It can easily be done both at design time and at runtime.

See the attached example.
Attachments:
Posted on 2006-05-28 11:54:19 by Morris
I see what you mean..

Thanks for the example.
Can you tell me what's the advantage of doing it like this?
Posted on 2006-05-28 14:54:40 by white scorpion
I am not sure if this is what you need but it shows how to paint
images on a form with transparent background.

PS: you can even download it here: http://www.masmwizard.com/projects.php

Zcoder....
Attachments:
Posted on 2006-05-29 00:18:25 by Zcoder

Thanks for the example.
Can you tell me what's the advantage of doing it like this?

Well, assigning a bitmap to a static control has one advantage - the control is responsible for painting the bitmap, not you. To be honest, I do not know if it has any performance advantages (ie. if the control paints the bitmap faster or not)
Posted on 2006-05-29 01:59:48 by Morris