Page 1 of 1
How to load frames from BMP in C++ using HBITMAP?
Posted: Sat Sep 08, 2018 12:36 pm
I don't understand how to load frames from BMP in C++ using HBITMAP function, i'm have all frames and code to load HBITMAP frames but i load showing me black screen how to fix this?
Re: How to load frames from BMP in C++ using HBITMAP?
Posted: Mon Sep 17, 2018 3:08 am
From the snippet i would guess your not updating the original hdc - your stretching image in hdc2 to hdc4 - which is fine, then your calling UpdateLayeredWindow but the destination hdc is set to null (2nd parameter) so its not doing anything, so normal windows drawing continues and as your supposed to be handling it and nothing is updated you get a black rectangle. So try to set that 2nd param to hdc.
Also are the w and h values correct? where are they from? global variables? ideally you might get those from a call to GetClientRect or from the size of the loaded bitmap with GetObject perhaps. Depends on how you setup the whole thing and if this is a separate control or is it for the main dialog/window?
If its a separate control you would call GetClientRect to get your bounding dimensions of where you can draw and to match the CreateCompatibleBitmap size - which would match the size of the control's window. Then your StretchBlt would make sense to stretch the loaded bitmap (or frames) to the size of the control's window dimensions.
Hope that helps. More code might help narrow down some of that stuff to help tailor the answer to your required solution