Thread: Wm_paint

  1. #1
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120

    Unhappy Wm_paint

    I have a window and its client area is filled with a bitmap patterned brush. It also contains several transparent static controls which I am using as frames for bitmap images.

    I can paint the client area with the brush and paint the images into the static controls with no problem, however, when the WM_PAINT message is sent to my window it only manages to repaint the client area and not the bitmaps inside my static controls

    My code looks like this:
    --------------------------------------------

    case WM_PAINT:
    {
    PAINTSTRUCT ps;
    HDC hdc = BeginPaint(hwnd, &ps);

    PaintTableMat(hdc, hwnd);
    EndPaint(hwnd, &ps);

    ShowDeal();
    }
    break;

    --------------------------------------------

    PaintTableMat() and ShowDeal() are the functions to paint the background and the framed images; they both work fine outside of the WM_PAINT context but ShowDeal() (the function to paint the images into the static controls) doesnt work here and it leaves the screen with grey rectangles where the images should be!

    Hmf

    I'm guessing that the static controls need to process their own WM_PAINT messages(?!) but I really don't have a clue, I would be very grateful if anyone could help!

    thanks for listening

    dom

  2. #2
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    Look up GetWindowLong in MSDN it should do what you want. You can get the WndProc for the static controls and replace them with your own.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Also could be that the HDC returned from BeginPaint() is that of the invalidated area (from a UpdateWindow() or InvalidateRect() ) and does not include the statics client area.

    A frame buffer system could work better. All drawing is done to a HDC buffer. A copy is kept and updated when the drawing is finished.

    On a WM_PAINT msg the copy is drawn to the screen. At no stage is the buffer drawn to the screen. This means that the paint is smooth, fast and that the whole area does not have to be invalidated to draw correctly. It also means that the screen can be redraw while there is drawing going on to the buffer in the background.

    Use this to find the area to redraw in your WM_PAINT _before_ the call to BeginPaint() validates the drawing area.
    Code:
    GetUpdateRect(hWnd, &theRect, 0);
    if (IsRectEmpty(&theRect))
    {
        GetClientRect(hWnd,&theRect);
    }
    "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

  4. #4
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120

    Talking THANKS!

    Thanks guys! It is now daylight and (07:47) I've just managed to fix it!

    I set the WndProc of the static controls to the same one as the main window an it worked. (It took me so long cos I had to figure out how to do that, I've only been doing API for a couple of days).

    Anyways,

    much gratitude ;-)

Popular pages Recent additions subscribe to a feed