If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

[RESOLVED] A little help! WM_PAINT + BMP

Hiho,

I just want to put a background image in my app, apparently works well but not, after a few clicks to resize it, my pc slow down, and I do not see the problem or may be my code wrong...accept help and suggestions! && light my way!

Re: A little help! WM_PAINT + BMP

Originally Posted by v_nom70

Hiho,

I just want to put a background image in my app, apparently works well but not, after a few clicks to resize it, my pc slow down, and I do not see the problem or may be my code wrong...accept help and suggestions! && light my way!

You should really check your return values for those functions you're calling. You're just assuming they work without seeing if any of them return an error.

Re: A little help! WM_PAINT + BMP

BITMAP is just a structure intended to get bitmap info. This is not a GDI object, so DeleteObject(&bm) makes no sense. The deleted object should be HBITMAP bg_image. But with this you have another problem: you never unselect it prior to deleting hdc_src. However you must do that:

Re: A little help! WM_PAINT + BMP

Do you really need to load your image in response to EVERY windows message you get? (hint – no, you don’t).
Since you only attempt to delete this HBITMAP while processing WM_PAINT message, all other ones are leaking.

Re: A little help! WM_PAINT + BMP

2 OP:
You should not (must not!) send WM_PAINT message (in response on the WM_SIZE)
Instead you should (if you really need to) call InvalidateRect which will cause Windows to send WM_PAINT message to your window.