I've been trying to figure out how bitmaps are drawn in Windows for a few days now, and I found this code:
Don't tell me that in order to draw a bitmap in a window, I have to redraw it every single time my app gets a WM_PAINT message!
I obviously can't do that in Blitzplus, because it intercepts all the messages, and automatically runs a program in a special loop that disallows drawing commands whenever someone for example, moves a scrollbar!
Augh... someone please tell me this is not the case and that there is an object I can create in a window like a button that is always there and that I don't have to redraw manually!
case WM_PAINT: { HDC dc = GetDC(hWnd); HDC memDC ; HBITMAP memBitmap = LoadBitmap(hInstance,MAKEINTRESOURCE(IDB_BITMAP_ONE)); HBITMAP oldBitmap ; memDC = CreateCompatibleDC(dc) ; oldBitmap = (HBITMAP)SelectObject(memDC,memBitmap) ; BITMAP bm; GetObject(memBitmap, sizeof(BITMAP), (LPVOID)&bm); if (memDC != NULL) { StretchBlt(dc,0, 0, m_nClientWidth, m_nClientHeight, memDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY) ; } SelectObject(memDC,oldBitmap) ; } break; you need to provide this code with the size of the window, put this code somewhere under before this code after the. RECT rect; GetClientRect(hWnd,&rect); m_nClientWidth = rect.right-rect.left; m_nClientHeight = rect.bottom - rect.top; Also the code assummes that you have a bitmap with name IDB_BITMAP_ONE to be drawn.
Don't tell me that in order to draw a bitmap in a window, I have to redraw it every single time my app gets a WM_PAINT message!
I obviously can't do that in Blitzplus, because it intercepts all the messages, and automatically runs a program in a special loop that disallows drawing commands whenever someone for example, moves a scrollbar!
Augh... someone please tell me this is not the case and that there is an object I can create in a window like a button that is always there and that I don't have to redraw manually!