CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Threaded View

  1. #1
    Join Date
    Apr 2011
    Posts
    9

    Painting Gremlins and weird bitblt stuff

    So I'm trying to write a relatively basic blackjack programming for learning purposes. It seems like something really odd is happening when WM_PAINT is called. It works fine until I introduce an if statement. Doing a watch the correct values pass, it goes through the whole function, watch it hit BitBlt and nothing draws. Take out the if statement and it draws just fine.

    Code:
    case WM_PAINT:
    {			
    	PAINTSTRUCT ps;		
    	HDC hdc = BeginPaint(hwnd, &ps);			
    	DrawTable(hwnd, ps, hdc);
    	//if (cardsDealt > 0)
    		DrawCard(hwnd, ps, hdc);			
    	EndPaint(hwnd, &ps);
    	break;
    }
    
    case IDC_DEALBUTTON:
    {
    	cardsDealt = 1;
    	ShowWindow(hWndDealButton, SW_HIDE);
    }
    
    void DrawCard(HWND hwnd, PAINTSTRUCT ps, HDC hdc)
    {	
    	HDC hdcMem = CreateCompatibleDC(hdc);
    	BITMAP bm;
    	GetObject(cardbmp, sizeof(bm), &bm);
    	HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, cardbmp);
    	BitBlt(hdc, 0, 750, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
    	SelectObject(hdcMem, hbmOld);
    	DeleteDC(hdcMem);
    	EndPaint(hwnd, &ps);
    }
    I'm sure the code is probably sloppy as I'm pretty new to this, so any recommendations on that end would be appreciated as well, but mainly just trying to figure out why the BitBlt won't paint for me. Thanks in advance.
    Last edited by ovidiucucu; April 19th, 2011 at 04:06 AM. Reason: Added [CODE] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured