1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
case WM_PAINT:
{
W=ThisFormsWIDTH; // 800
H=ThisFormsHEIGHT; // 500
HDC hdcSource; // I think that this is where I first put the bitmaps.
HDC hdcDest; // I think that this looks like the a (?) front buffer,
// but why do I have to draw to it each time to get it to work?
// Why can't I just draw everything to a (another?) back buffer
// and then when it is all done, just draw that to
// a front buffer?
// This is sooooo difficult !
hdcDest = BeginPaint(MAIN_WINDOW, &ps); // Begin paint
// Why does the BeginPaint have to be here instead
// of later when this all done in back buffer(s)?
hdcSource = CreateCompatibleDC(GetDC(nullptr)); // Create a Memory Device Context
HBITMAP bmpWindow_Full_Background = (HBITMAP)LoadImage(nullptr,
L"Window_Full_Background_40_40.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject(hdcSource, bmpWindow_Full_Background);
StretchBlt(hdcDest, 0, 0, W, H, hdcSource, 0, 0, 100, 100, SRCCOPY);
HBITMAP bmpWindowTopBackPanel = (HBITMAP)LoadImage(nullptr,
L"window_top_center_BACK_PANEL_40_40.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject(hdcSource, bmpWindowTopBackPanel);
StretchBlt(hdcDest, 0, 0, W, 18, hdcSource, 0, 0, 40, 40, SRCCOPY);
HBITMAP bmpWindowTopCenter = (HBITMAP)LoadImage(nullptr,
L"window_top_center_40_40.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject(hdcSource, bmpWindowTopCenter);
StretchBlt(hdcDest, (W/2)-20, 0, 40, 40, hdcSource, 0, 0, 40, 40, SRCCOPY);
HBITMAP bmpWindowTopLeft = (HBITMAP)LoadImage(nullptr,
L"window_top_left_40_40.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject(hdcSource, bmpWindowTopLeft);
BitBlt(hdcDest, 0, 0, 40, 40, hdcSource, 0, 0, SRCCOPY);
HBITMAP bmpWindowTopRight = (HBITMAP)LoadImage(nullptr,
L"window_top_right_40_40.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject(hdcSource, bmpWindowTopRight);
BitBlt(hdcDest, (W - 40), 0, 40, 40, hdcSource, 0, 0, SRCCOPY);
HBITMAP bmpWindowBottomLeft = (HBITMAP)LoadImage(nullptr,
L"window_bottom_left_40_40.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject(hdcSource, bmpWindowBottomLeft);
BitBlt(hdcDest, 0, (H - 40), 40, 40, hdcSource, 0, 0, SRCCOPY);
HBITMAP bmpWindowBottomRight = (HBITMAP)LoadImage(nullptr,
L"window_bottom_right_40_40.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject(hdcSource, bmpWindowBottomRight);
BitBlt(hdcDest, (W - 40), (H - 40), 40, 40, hdcSource, 0, 0, SRCCOPY);
HBITMAP bmpWindowBottomCenter = (HBITMAP)LoadImage(nullptr,
L"window_bottom_center_40_40.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject(hdcSource, bmpWindowBottomCenter);
StretchBlt(hdcDest, (W/2)-20, (H - 40), 40, 40, hdcSource, 0, 0, 40, 40, SRCCOPY);
HBITMAP bmpWindowLeftCenter = (HBITMAP)LoadImage(nullptr,
L"window_left_center_40_40.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject(hdcSource, bmpWindowLeftCenter);
StretchBlt(hdcDest, 0, (H/2)-20, 40, 40 , hdcSource, 0, 0, 40, 40, SRCCOPY);
HBITMAP bmpWindowRightCenter = (HBITMAP)LoadImage(nullptr,
L"window_right_center_40_40.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject(hdcSource, bmpWindowRightCenter);
StretchBlt(hdcDest, W-40, (H/2)-20, 40, 40, hdcSource, 0, 0, 40, 40, SRCCOPY);
HBITMAP bmpWindowCenter = (HBITMAP)LoadImage(nullptr,
L"window_center_40_40.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject(hdcSource, bmpWindowCenter);
StretchBlt(hdcDest, (W/2)-20, (H/2)-20, 40, 40, hdcSource, 0, 0, 40, 40, SRCCOPY);
HBITMAP bmpWindowFloating001 = (HBITMAP)LoadImage(nullptr,
L"window_title.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject(hdcSource, bmpWindowFloating001);
BitBlt(hdcDest, 10, 10, 10, 10, hdcSource, 0, 0, SRCCOPY);
EndPaint(MAIN_WINDOW, &ps); // End paint
DeleteDC(hdcDest);
DeleteDC(hdcSource); // Delete a Memory Device Context
DeleteObject(bmpWindow_Full_Background);
DeleteObject(bmpWindowTopBackPanel);
DeleteObject(bmpWindowTopCenter);
DeleteObject(bmpWindowTopLeft);
DeleteObject(bmpWindowTopRight);
DeleteObject(bmpWindowBottomLeft);
DeleteObject(bmpWindowBottomRight);
DeleteObject(bmpWindowBottomCenter);
DeleteObject(bmpWindowLeftCenter);
DeleteObject(bmpWindowRightCenter);
DeleteObject(bmpWindowCenter);
DeleteObject(bmpWindowFloating001);
break;
}
| |