Quantcast
Channel: CodeGuru Forums - C++ and WinAPI
Viewing all articles
Browse latest Browse all 583

A little help! WM_PAINT + BMP

$
0
0
Hiho,

I just want to put a background image in my app, apparently works well but not, after a few clicks to resize it, my pc slow down, and I do not see the problem or may be my code wrong...accept help and suggestions! && light my way!

Code:

        //Warnings 0
        //GetLastError No Error

        RECT rc;
        GetClientRect (wp_hwnd, &rc);
        HDC hdc_dst = GetDC (wp_hwnd);
        HDC hdc_src = CreateCompatibleDC (hdc_dst);
        HBITMAP bg_image = LoadBitmap (GetModuleHandle(NULL), MAKEINTRESOURCE (IDM_BGBMP));
        BITMAP bm;
        PAINTSTRUCT ps;


        switch (wp_msg)
        {
        case WM_PAINT:
                BeginPaint (wp_hwnd, &ps);
                GetObject (bg_image, sizeof (bm), &bm);
                SelectObject (hdc_src, bg_image);
                StretchBlt (
                        hdc_dst,
                        0,0,
                        rc.right, rc.bottom,
                        hdc_src,
                        0, 0,
                        bm.bmWidth, bm.bmHeight,
                        SRCCOPY);

                DeleteObject (&bg_image);
                ReleaseDC (wp_hwnd, hdc_dst);
                DeleteDC (hdc_src);
                DeleteObject (&bm);
        EndPaint(wp_hwnd, &ps);
                break;

        case WM_SIZE:
                SendMessage (wp_hwnd,WM_PAINT,0,0);
                break;


Viewing all articles
Browse latest Browse all 583

Trending Articles