Skip to main content

 none
No Window Update of program client area from row 256 to 511 on Vista RRS feed

  • Question

  • A win32 sdk application compiled by C++ 2005 Express does not update its client window in row 256 to 511 (and multiples).
    Platform:
    Windows Vista Business
    Compiler: VC++ 2005 Express with SP1 but without SP1 for Vista (installer tells "Wrong Platform")
    or VC6. May also be compiled on a different machine.

    The application uses SetPixelV to set the pixel in the update region.
    This is slow, but worked (so far) on all 32bit windows version (WIN 95 - WIN XP).

    The following sample program is an extract of the program. On my computer, the screen behind the client window is shown from row 256 to row 511 of the client window. Row 0 to 255, the program output set by SetPixel is shown.

    Thank you in advance,
    Harald

    /***************************************************************************//**
        @file vista_test.c
        @date 2007-06-21
        @author Harald Oehlmann

        @brief    Vista test application
        
    *******************************************************************************/


    // -----------------------------------------------------------------------------
    // >>>>> H E A D E R  F I L E S
    // -----------------------------------------------------------------------------
    #include <windows.h>
    #include <commdlg.h>
    #include <stdlib.h>
    //------------------------------------------------------------------------------
    // >>>>> PaintMainWindow
    //------------------------------------------------------------------------------
    static void PaintMainWindow( HWND hWnd )
    {
        PAINTSTRUCT sPaint;
        HDC hDC;
        int RowCur;
        int ColCur;
        //--------------------------------------------------------------------------
        // >>> Paint
        //--------------------------------------------------------------------------
        hDC = BeginPaint(hWnd, &sPaint);
        if (NULL == hDC)
        {
            return;
        }
        //--------------------------------------------------------------------------
        // >> Loop over update Rows
        //--------------------------------------------------------------------------
        for (RowCur = sPaint.rcPaint.top ; RowCur < sPaint.rcPaint.bottom; RowCur++)
        {
            //------------------------------------------------------------------
            // >> Loop over update Cols
            for (
                ColCur = sPaint.rcPaint.left ;
                ColCur < sPaint.rcPaint.right ;
                ColCur++)
            {
                unsigned char GreyLevel;
                GreyLevel = (unsigned char) ((RowCur + ColCur) % 256);
                // > Problem: If ColCur >= 256 && ColCur < 512 no pixel is set
                SetPixelV( hDC, ColCur, RowCur, RGB( GreyLevel, GreyLevel, GreyLevel) );
            }
        }
        //--------------------------------------------------------------------------
        EndPaint(hWnd, &sPaint);
    }
    //------------------------------------------------------------------------------
    // >>>>> WndProc
    //------------------------------------------------------------------------------
    LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
        if (Message == WM_PAINT)
        {
            PaintMainWindow(hWnd);
            return 0;
        }
        return DefWindowProc(hWnd, Message, wParam, lParam);
    }
    //------------------------------------------------------------------------------
    // >>>>> MyRegisterClass
    //------------------------------------------------------------------------------
    static ATOM MyRegisterClass( HINSTANCE hInstance )
    {
        WNDCLASSEX wcex;

        wcex.cbSize = sizeof(WNDCLASSEX);

        wcex.style            = CS_SAVEBITS;
        wcex.lpfnWndProc    = (WNDPROC)WndProc;
        wcex.cbClsExtra        = 0;
        wcex.cbWndExtra        = 0;
        wcex.hInstance        = hInstance;
        wcex.hIcon            = NULL;
        wcex.hCursor        = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
        wcex.hbrBackground    = NULL;
        wcex.lpszMenuName    = NULL;
        wcex.lpszClassName    = "VISTA_TEST";
        wcex.hIconSm        = NULL;

        return RegisterClassEx(&wcex);
    }
    //------------------------------------------------------------------------------
    // >>>>> InitInstance
    //------------------------------------------------------------------------------
    static BOOL InitInstance( HINSTANCE hInstance, int nCmdShow )
    {
        //--------------------------------------------------------------------------
        HWND hWnd;
        //--------------------------------------------------------------------------
        // > Create main window
        //--------------------------------------------------------------------------
        hWnd = CreateWindow(
            "VISTA_TEST",
            "Vista_Test",
            WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
            CW_USEDEFAULT, 0,
            CW_USEDEFAULT, 0,
            NULL, NULL, hInstance, NULL);
        //--------------------------------------------------------------------------
        if (!hWnd)
        {
          return FALSE;
        }
        //--------------------------------------------------------------------------
        ShowWindow(hWnd, nCmdShow);
        UpdateWindow(hWnd);
        BringWindowToTop(hWnd);
        //--------------------------------------------------------------------------
        return TRUE;
    }
    //------------------------------------------------------------------------------
    // >>>>> WinMain
    //------------------------------------------------------------------------------
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
        //--------------------------------------------------------------------------
        MSG msg;
        //--------------------------------------------------------------------------
        // Initialize global strings
        MyRegisterClass(hInstance);
        //--------------------------------------------------------------------------
        // Perform application initialization:
        if (!InitInstance (hInstance, nCmdShow ))
        {
            return FALSE;
        }
        //--------------------------------------------------------------------------
        // >> Main message loop
        //--------------------------------------------------------------------------
        while (GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        //--------------------------------------------------------------------------
        return msg.wParam;
    }

    Wednesday, August 29, 2007 10:02 AM

Answers

  • Harald,

    You forgot to mention that this is only an issue under the Vista Basic and Windows Classic theme. Your sample works fine under Aero. If you just want something that works, then use FillRect instead of SetPixel:

                RECT rPix;
                rPix.left=ColCur;
                rPix.top=RowCur;
                rPix.right=rPix.left+1;
                rPix.bottom=rPix.top+1;
                HBRUSH hCol=CreateSolidBrush(RGB( GreyLevel, GreyLevel, GreyLevel));
                FillRect(hDC,&rPix,hCol);
                DeleteObject(hCol);

    It will be interesting to see if Vista SP1 addresses this bug.



    Wednesday, August 29, 2007 9:24 PM

All replies

  • Harald,

    You forgot to mention that this is only an issue under the Vista Basic and Windows Classic theme. Your sample works fine under Aero. If you just want something that works, then use FillRect instead of SetPixel:

                RECT rPix;
                rPix.left=ColCur;
                rPix.top=RowCur;
                rPix.right=rPix.left+1;
                rPix.bottom=rPix.top+1;
                HBRUSH hCol=CreateSolidBrush(RGB( GreyLevel, GreyLevel, GreyLevel));
                FillRect(hDC,&rPix,hCol);
                DeleteObject(hCol);

    It will be interesting to see if Vista SP1 addresses this bug.



    Wednesday, August 29, 2007 9:24 PM
  • Thank you, Donal,
    unfortunately, I also observe it in the Aero Theme (the Vista default theme).
    Another observation: the dialog designer of VC++6 shows also the bug. When the visual placement grid is activated and shown, it is only shown up to row 256.

    I will try your proposal.
    Thanks,
    Harald
    Tuesday, September 4, 2007 5:14 PM
  • The workaround works for me. I have implemented it in my application with a check for Vista without service pack.
    Thank you,
    Harald
    Thursday, September 6, 2007 2:37 PM
  • This problem has apperently not been fixed yet...  We draw grid dots using SetPixel, and some customers have complained that there were "white stripes" in the grid. I can reproduce this using "Vista Basic" and "Windows Classic" themes. There is no problems using the Aero theme.
    Tuesday, June 2, 2009 11:26 AM
  • The problem still exists even on Vista SP2, however it seems to have been fixed in Windows 7. I have never been able to repeat it with Aero Glass active on Vista but it always happens when Aero Glass is off.
    Tuesday, June 2, 2009 2:34 PM