Displaying a bmp in a dialog frame

I'm working on creating a 'Slot Machine' program using the Win32 API, but i dont have knowledge with displaying images on the dialog frame. I tried to research how to display bitmap images, but no luck. If anyone could enlighten me on how to go about doing this i would greatly appreciate it, thanks!
Use SS_BITMAP style on a static control. Lo get a bitmap handle use LoadImage or LoadBitmap.
Where would i place this control? Once the user clicks the spin button i want to display the result of the spin in pictures. Would i place this call under the button press?

                case IDC_SPIN:      //slot machine spins
                //place code here? Will it just refresh the dialog?
                case IDC_EXIT:      //exit button
                    EndDialog(hwnd, 0);

I remember someone on stackoverflow telling me i needed to use RECT and invalidateRect(), does that come into play at all? Thanks!
Last edited on
If you want to animate the spin, to show the "reels" spinning, you need to do your own drawing. If you're working the GDI, then the key call is BitBlt (or one of its 'Blt relatives, like StretchBlt)

And if you do your own drawing, then you'll need InvalidateRect() to force a redraw so the spinning works.

But if you just use WM_SETBITMAP to swap a SS_BITMAP-style static control's bitmap, then it might not be necessary (I'm not sure here. The rules might be different for a static control in a dialog and one you creates yourself as the child of a normal window? As you're using a dialog, I don't think it's required.)


PS This example shows how to load .bmp file and then render the loaded bitmap.

HOWTO: How To Use LoadImage() to Read a BMP File

If your bitmaps are small, you could store them in the app's resource section and load them from there, rather than a file. Or even create them in memory.
Last edited on
Topic archived. No new replies allowed.