Hi, i cant get the background image work:



.ELSEIF uMsg==WM_PAINT ;
mov eax, hWnd ;
.IF eax == h_Dlg
invoke BeginPaint,hwndRichEdit,addr ps
mov hdc,eax
invoke CreateCompatibleDC,hdc
mov hMemDC,eax
invoke SelectObject,hMemDC,hBitMap
invoke GetClientRect,hwndRichEdit,addr rect
invoke BitBlt,hdc,0,0,rect.right,rect.bottom,hMemDC,0,0,SRCCOPY
invoke DeleteDC,hMemDC
invoke EndPaint,hwndRichEdit,addr ps ;
.ENDIF


	.ELSEIF uMsg == WM_INITDIALOG  	

;mov eax,hWnd
;mov h_Dlg,eax
invoke LoadBitmap,hInstance, ADDR DB_Bitmap
mov hBitMap,eax


I cant see anything from my picture.


Greets
Posted on 2003-12-21 10:41:40 by Bubu-Boy
just some ideas..

1) Have you subclassed the richedit ? I think you should paint inside the WM_PAINT of the subclassing procedure, without any IF .

2) mmm are hWnd or h_Dlg a local variables ? If yes, that's the reason, local variables are lost inside a window procedure.

B7
Posted on 2003-12-21 12:32:26 by Bit7
i have both! Subcallsing and global variables.

But what now?
I have the feeling that its to few.
The bmphandle ist right.

Do i neet or set mor options?


Greets!
Posted on 2003-12-21 12:37:21 by Bubu-Boy
ok, i think it's just some code mistake...

Sorry, i don't have much time to try the code myself it, but just try some other ideas..

1) i don't see the reason of creating the compatibleDC at every WM_PAINT it's just a weaste of resource. Create it in WM_INITDIALOG. Just leave the select object inside the WM_PAINT and don't Delete the compatible DC inside the WM_PAINT. Do it in a WM_CLOSE.

2) i don't see any rason of the .IF inside the WM_PAINT

try these suggestions, hope help.

B7
Posted on 2003-12-22 12:13:18 by Bit7
Hi :)
This might work...
Inside window procedure for subclassed richedit control (NOT dialog box):


local rect:RECT
local bitmap:BITMAP
local ps:PAINTSTRUCT

mov eax,uMsg
.IF eax == WM_PAINT
invoke GetClientRect,hWnd,addr rect
invoke GetObject,hBitMap,addr bitmap,sizeof bitmap
mov eax,bmHeight
neg eax
.if ! sign?
mov bmHeight,eax
.endif
invoke BeginPaint,hwndRichEdit,addr ps
invoke CreateCompatibleDC,eax
mov hMemDC,eax
invoke SelectObject,hMemDC,hBitMap
invoke StretchBlt,ps.hdc,0,0,rect.right,rect.bottom,hMemDC,0,0,bitmap.bmWidth,bitmap.bmHeight,SRCCOPY
invoke DeleteDC,hMemDC
invoke EndPaint,hwndRichEdit,addr ps
xor eax,eax
ret
.ELSEIF eax == WM_ERASEBKGRND
;Prevents flicker... unless we're not painting the whole surface.
xor eax,eax
ret
.ENDIF

I would also recommend to put uMsg in eax (so it has to be read only once, and smaller code).
Try as well to use resource IDs instead of resource names, it's faster and using strings to do the same as a DWORD is bloating your code.
At your dialog box procedure: (uMsg in eax)
	.ELSEIF eax == WM_INITDIALOG  	

invoke LoadBitmap,hInstance,IDB_BITMAP1
mov hBitMap,eax

Somewhere else:
IDB_BITMAP1 equ 100	;You can use any other number

And at your resource script:
#define IDB_BITMAP 100

IDB_BITMAP BITMAP DISCARDABLE "MyBitmap.bmp"

It's not the optimal way to do it, but IMHO it should work. If it does, try creating the memory DC and getting the bitmap info only once (faster).
Posted on 2003-12-23 17:16:30 by QvasiModo
**** all! <-- not "fuck all!", but "**** all!"

I didnt get email notification and was quite disappointed, but now i see your helped me! Thanks!

I did what you said, but nothing changed. I cant see any picture, when i want to write something only strokes(||| || ||||) appears.

Do i neet a speyify option in my dialog? or for the richedeitcreation ?

It is possible to set the picture transparent?

Something else its possible to load an extern bitmap? - as i tray at the beginning, or have it to bee a resource identifer


Thank you all:stupid:
Posted on 2003-12-26 02:58:50 by Bubu-Boy

**** all! <-- not "fuck all!", but "**** all!"

I didnt get email notification and was quite disappointed, but now i see your helped me! Thanks!

I did what you said, but nothing changed. I cant see any picture, when i want to write something only strokes(||| || ||||) appears.

Do i neet a speyify option in my dialog? or for the richedeitcreation ?

It is possible to set the picture transparent?

Something else its possible to load an extern bitmap? - as i tray at the beginning, or have it to bee a resource identifer


Thank you all:stupid:

:)
My mistake, remove the xor eax,eax/ret and call the default window procedure instead.
If that doesn't work, try painting the image on WM_ERASEBKGND instead.
If that doesn't work either (and if no one points out a cleaner solution :grin: ) take a look at this thread, and try to use the same approach for a richedit instead of a treeview:

http://www.asmcommunity.net/board/showthread.php?threadid=13691&highlight=treeview+with+a+background

As for the external file, yes, you can load the bitmap from anywhere. The masm32.lib library comes with some picture loading functions that you might find handy, they load jpg and gif files into an hbmp handle.
Posted on 2003-12-26 11:09:05 by QvasiModo