BITMAPS in WM_PAINT

This is a discussion on BITMAPS in WM_PAINT within the Windows Programming forums, part of the Platform Specific Boards category; I am trying to remake minesweeper (with some tweaks). I got to as far as placing all the images on ...

  1. #1
    Registered User CrissyCrisCris's Avatar
    Join Date
    Aug 2009
    Posts
    13

    BITMAPS in WM_PAINT

    I am trying to remake minesweeper (with some tweaks). I got to as far as placing all the images on the window, but in minesweeper when you click down anywhere the smily faces changes. I am working on that right now in my program. This is what I have so far...

    Code:
    ...
    WM_LBUTTONDOWN:
         bClick = true;
         break;
    WM_LBUTTONUP:
         bClick = false;
         break;
    WM_PAINT:  
    ...
         if (!bClick)
              SelectObject(hdc, LoadImage(NULL, "C:\\Program Files\\Minesweeper7\\Skins\\Default\\Idle.bmp", IMAGE_BITMAP, 26, 26, LR_LOADFROMFILE));
         else
              SelectObject(hdc, LoadImage(NULL, "C:\\Program Files\\Minesweeper7\\Skins\\Default\\Active.bmp", IMAGE_BITMAP, 26, 26, LR_LOADFROMFILE));
         BitBlt(hdc, rWindowRect.right / 2 - 12, 12, 26, 26 , hdcmem, 0, 0, SRCCOPY);
    ...
    http://i130.photobucket.com/albums/p...ntitled-44.jpg

    It either draws one bitmap or the other. It would not switch between the bitmaps. Anyway around it?

    I probably won't visit this page for a few days and I'm afraid I won't be able to find it after I come back, so please email me at CrissyCrisCris@hotmail.com if you have a solution.

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Assuming the rest of your drawing and DC creation is correct, assuming you used a variable with enough scope (static or global), ignoring the probable GDI leaks and that the drawing code should not be in the WM_PAINT handler, the issue appears to be that you are selecting the image into the wrong DC.

    You need to SelectObject() the image into the memDC (not into the paint DC) and then BitBlt the image from the memDC to the right spot on the paint DC.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Drawing bitmaps efficiently
    By scwizzo in forum Windows Programming
    Replies: 28
    Last Post: 06-30-2009, 09:25 PM
  2. DX9 Not Displaying Bitmaps
    By Sentral in forum Game Programming
    Replies: 9
    Last Post: 01-31-2006, 05:35 AM
  3. MFC: Multiple clicks shows multiple bitmaps - how?
    By BrianK in forum Windows Programming
    Replies: 0
    Last Post: 06-20-2004, 08:25 PM
  4. using standard bitmaps in the toolbar editor
    By Kibble in forum Windows Programming
    Replies: 0
    Last Post: 12-23-2002, 08:43 PM
  5. Displaying bitmaps on a dialog
    By minesweeper in forum Windows Programming
    Replies: 2
    Last Post: 05-15-2002, 04:11 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21