CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2005
    Location
    algiers, Algeria
    Posts
    132

    [RESOLVED] flick when subclassing Edit control

    Hi all,

    could you please help me to remove flick when i subclass an Edit control, this my code:

    Code:
    LRESULT CALLBACK WindowProcedureEdit(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        RECT lpRect;
    
        HDC hDC;
            
        HBRUSH hBrush,oBrush;
        
        if(message == WM_PAINT)
        {
    
            GetClientRect(hwnd, &lpRect);
            hBrush = CreateSolidBrush(RGB(255,255,255));
            oBrush = CreateSolidBrush(RGB(250,0,0));
    
            hDC = GetDC(hwnd);
            FillRect(hDC,&lpRect,hBrush);
            FrameRect(hDC,&lpRect,oBrush);
            
            ReleaseDC(hwnd, hDC);
    
            DeleteObject(hBrush);
            DeleteObject(oBrush);
            return 0L;
        }
        if(message == WM_ERASEBKGND)
        {
            return 1L;
        }
        return CallWindowProc(g_oldEditProc, hwnd, message, wParam, lParam);
    }

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: flick when subclassing Edit control

    In respond to WM_PAINT message you have to use BeginPaint/EndPaint functions, not GetDC/ReleaseDC
    Please, read MSDN articles:
    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured