1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC graphicshandler;
PAINTSTRUCT ps;
static HBITMAP mypicture;
BITMAP bitmappic;
HDC graphicshandler2;
switch (message) /* handle the messages */
{
case WM_CREATE:
//Load the image:
mypicture = (HBITMAP) LoadImageW(NULL, L"blue_ball.bmp",
IMAGE_BITMAP, 0, 0, LR_LOADTRANSPARENT);
break;
case WM_PAINT:
graphicshandler = BeginPaint(hwnd, &ps);
//Create a new graphic handler, based on the previous:
graphicshandler2 = CreateCompatibleDC(graphicshandler);
//Load mypicture into this new graphic handler:
SelectObject(graphicshandler2, mypicture);
//Read the size of mypicture:
GetObject(mypicture, sizeof(bitmappic), &bitmappic);
//Finally draw the image at 50-50 screen coordinates:
BitBlt(graphicshandler, 50, 50, bitmappic.bmWidth, bitmappic.bmHeight, graphicshandler2, 0, 0, SRCCOPY);
|