Thread: Multi-BMP Loading Problem!(PLEASE HELP!)

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question Multi-BMP Loading Problem!(PLEASE HELP!)

    I am working onskinning my own window, instead of those same old dull regular windows. I made a BMP for the title bar, minimize button, and close button. I need help, though. I try this:


    void DrawTBar(HDC hdc)
    {
    HDC hdcMemory;
    hdcMemory = CreateCompatibleDC(hdc);

    SelectObject(hdcMemory, dBar);
    BitBlt(hdc, tBarX, tBarY, ((514 - 26) - 26) - 26, bm.bmHeight, hdcMemory, 0, 0, SRCPAINT);

    DeleteDC(hdcMemory);
    }
    void DrawMBtn(HDC hdc)
    {
    HDC hdcMemory;
    hdcMemory = CreateCompatibleDC(hdc);

    SelectObject(hdcMemory, dBar);
    BitBlt(hdc, mnX, mnY, mn.bmWidth, mn.bmHeight, hdcMemory, 0, 0, SRCPAINT);

    DeleteDC(hdcMemory);
    }
    void DrawCBtn(HDC hdc)
    {
    HDC hdcMemory;
    hdcMemory = CreateCompatibleDC(hdc);

    SelectObject(hdcMemory, dBar);
    BitBlt(hdc, csX, csY, cs.bmWidth, cs.bmHeight, hdcMemory, 0, 0, SRCPAINT);

    DeleteDC(hdcMemory);
    }



    Then in WM_PAINT:


    case WM_PAINT:
    PAINTSTRUCT ps;
    PAINTSTRUCT ps2;
    PAINTSTRUCT ps3;
    HDC hdcWindow;
    HDC hdc2;
    HDC hdc3;

    hdcWindow = BeginPaint(hwnd, &ps);

    DrawTBar(hdcWindow);

    EndPaint(hwnd, &ps);

    hdc2 = BeginPaint(hwnd, &ps2);

    DrawMBtn(hdc2);

    EndPaint(hwnd, &ps2);

    hdc3 = BeginPaint(hwnd, &ps3);

    DrawCBtn(hdc3);

    EndPaint(hwnd, &ps3);
    break;



    It only loads the title bar image. How do I load multiple bitmaps?

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Use a frame buffer.

    Your paint is the problem as it is not the right hdc / paintstruct.

    I posted a paint function before and mentioned the memory you are loosing with incorrect use of selectobject().

    Work it out, I think you will learn more from discovering a way through.
    Last edited by novacain; 12-18-2001 at 01:09 AM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    Isn't here a little mistake?

    BeginPaint validates update region and clears client window area by a brush stored in WNDCLASS. Three subsequent BeginPaint () calls therefore are unnecessary, only the last call has sense.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Actually I think only the first.

    After that the update region is now valid and so no more paint will take place.

    Problem is to get all the regions, that need a redraw, to draw at the same time.

    Or to find the correct hdc to draw onto.
    Last edited by novacain; 12-18-2001 at 02:28 AM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    Hmm, it might be the first.

    While there is no invalid area, BeginPaint () does no clearing.
    Seems it was my mistake.

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    The BeginPaint validates the update region. Further calls will fail.

    Try putting all the draw functions in the same paint. Not the correct way do to a paint but may fix the problem.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BMP Loading Structs
    By IdioticCreation in forum C++ Programming
    Replies: 4
    Last Post: 07-05-2007, 12:42 PM
  2. how come... (bmp loading)
    By Homunculus in forum Windows Programming
    Replies: 4
    Last Post: 03-21-2006, 09:00 PM
  3. OpenGL, loading BMP Textures?
    By Zeusbwr in forum Game Programming
    Replies: 12
    Last Post: 12-09-2004, 05:16 PM
  4. Loading BMP to a DirectDrawSurface
    By phatslug in forum Game Programming
    Replies: 1
    Last Post: 07-18-2002, 04:15 PM
  5. Loading BMP without WM_PAINT?
    By SyntaxBubble in forum Windows Programming
    Replies: 3
    Last Post: 01-10-2002, 10:59 PM