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!
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.
Code:
DeleteObject (&bg_image);
Why are you passing the address of an HBITMAP to DeleteObject?
If you checked the return value of DeleteObject, does it return 0 or non-zero? If it is zero, then you would have discovered the problem is with this function.
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:
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.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio: FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...
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.
Bookmarks