I'm trying to draw a icon or a bitmap in a button... I have set BS_OWNERDRAW style to the button and í'm handling WM_DRAWITEM message but a cannot draw icon or bitmap i don't know why... I'm using pure windows API. I tried with DrawIcon, DrawIconEx, BitBlt...
First off you English is fine. Next, do you know that you are opening the image file correctly? Have you checked "GetLastError()" for any error codes? Are you getting compile errors? Linker errors? Or is the icon just not rendering?
Ok sorry that was my bad using LoadImage() because i was trying to load from a file and i didn't put LR_LOADFROMFILE sorry thank you guys for your time.
i am also trying to make a bitmap a button but im still a bit confused, i dont know how to use any of functions mentioned already. i am a beginner and i have never done buttons before. could you post some sample code?
I have made the button but need to insert the bitmap
The above assumes that you have registered your icon in your resource file and that you have set your button to BS_ICON in your resource file. For example --
IDI_ICON ICON "myicon.ico"
then when you put your button further below in your resource file --
If not, then adapt it to what I've showed you above. As long as you have an ID to the button, as in your code above, i.e., IDC_BUTTON5, and as long as you have registered your icon, as I have demonstrated, then you should have zero problem adapting it to work. You should also set the BS_ICON flag in your CreateWindow() function if you insist on making your button that way.
You have to use YOUR OWN HINSTANCE variable and YOUR OWN HWND variable in those places!!!
Instead of using CreateWindow(), why don't you try following my instructions to the letter, which means using the RESOURCE file to indentify your icon and to create your button. Then use the code I supplied to set the icon on the button.
As I said, I do this ALL THE TIME with the EXACT SAME CODE as given you.