Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8708981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:15:21+00:00 2026-06-13T04:15:21+00:00

I am attempting to write a slot machine Win32 App that uses images to

  • 0

I am attempting to write a slot machine Win32 App that uses images to display the result of the spins. I know how to display an image on a normal LRESULT CALLBACK frame, but i’m lost when it comes to displaying images on a dialog. Could anyone help me by explaining(in-depth) how i would go about displaying images? I really appreciate it.

My current Dialog callback:

BOOL CALLBACK DlgProc(HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
        case WM_INITDIALOG:         //dialog created
            g_hbmObject = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_OBJECT));
                                    //initialize slotmachine class
            Machine.Initialize(time(0));
            if(g_hbmObject == NULL) //test if object is loaded correctly
                std::cerr << "Could not load ball..";
        break;
        case WM_COMMAND:            //switch command
            switch(LOWORD(wParam))
            {
                case IDC_SPIN:      //slot machine spins
                                    //put spin function, decide what to display
                                    //do i put the display image command here? or where?
                break;
                case IDC_EXIT:      //exit button
                    DeleteObject(g_hbmObject);
                    EndDialog(hwnd, 0);
                break;
            }
        break;
        case WM_CLOSE:
        case WM_DESTROY:            //case program is exited
            DeleteObject(g_hbmObject);
            PostQuitMessage(0);
        break;
        default:
            return FALSE;
    }
    return TRUE;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:15:21+00:00Added an answer on June 13, 2026 at 4:15 am

    The following code registers a “REEL” window class: a control that displays a spinning reel for a slot machine. You can create multiple instances of it on a dialog using resource statements like:

    CONTROL         "",IDC_REEL1,"REEL",0,14,50,40,40
    CONTROL         "",IDC_REEL2,"REEL",0,70,50,40,40
    

    The reel spins endlessly, but you can easily add private messages to start and stop it.

    As explained in the comments, it expects a bitmap representing a reel with resource ID IDB_REEL.

    HBITMAP g_hbmpReel;
    
    LRESULT CALLBACK ReelWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        const int ReelTimerId = 5;
    
        switch (message)
        {
        case WM_CREATE:
            SetTimer(hWnd, ReelTimerId, 10, 0);
            break;
        case WM_DESTROY:
            KillTimer(hWnd, ReelTimerId);
            break;
        case WM_SIZE:
            SetWindowPos(hWnd, 0, 0, 0, 40, 40, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOREDRAW | SWP_NOZORDER);
            break;
        case WM_TIMER:
            if (wParam == ReelTimerId)
            {
                int offset = GetWindowLong(hWnd, 0);
                offset = (offset + 5) % 120;
                SetWindowLong(hWnd, 0, offset);
                InvalidateRect(hWnd, 0, FALSE);
            }
            break;
        case WM_PAINT:
            {
                PAINTSTRUCT ps;
                HDC hdc = BeginPaint(hWnd, &ps);
                HDC hdcReel = CreateCompatibleDC(hdc);
                HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcReel, g_hbmpReel);
                int offset = GetWindowLong(hWnd, 0);
                BitBlt(hdc, 0, 0, 40, 40, hdcReel, 0, offset, SRCCOPY);
                SelectObject(hdcReel, hbmpOld);
                DeleteDC(hdcReel);
                EndPaint(hWnd, &ps);
            }
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        return 0;
    }
    
    ATOM RegisterReel(HINSTANCE hInstance)
    {
        WNDCLASSEX wcex = {0};
    
        wcex.cbSize = sizeof(WNDCLASSEX);
    
        wcex.lpfnWndProc    = ReelWndProc;
        // Window data used to hold the position of the reel
        wcex.cbWndExtra     = sizeof(int);
        wcex.hInstance      = hInstance;
        wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
        wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
        wcex.lpszClassName  = L"REEL";
    
        // IDB_REEL is a 40x160 bitmap representing a reel with THREE 40x40 symbols.
        // The bottom 40x40 square should be the same as the topmost.
        g_hbmpReel = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_REEL));
    
        return RegisterClassEx(&wcex);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to write an iPhone App that automates actions on a certain website.
I am attempting to write an application that uses libCurl to post soap requests
I am attempting to write some Java code that takes an image from a
I'm attempting to write a program that uses json objects to communicate and am
So I'm attempting to write a Django reusable app that provides a method for
I'm attempting to write a small app that will do something similar to what
I am curretnly attempting to write a script in python that allows me to
I am attempting to write an Android app which will allow me to read
I am attempting to write a method that has an optional EventHandler Paramater. it
I have been attempting to write a VBA Script that can parse out other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.