Thread: Flicker in window resize, controls

  1. #1
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465

    Flicker in window resize, controls

    I have several controls that need to be scaled when a window is to be resized. I am doing so using Begin/End/DeferWindowPos.

    Code:
    int ScaleWindowControls(HWND hwnd, int x, int y)
    {
        HWND chatwnd = ::GetDlgItem(hwnd, IDC_CHATTY);
        HWND mainwnd = ::GetDlgItem(hwnd, IDC_MAIN);
        HWND entrbtn = ::GetDlgItem(hwnd, IDC_BUTTON);
        
        if(!chatwnd || !mainwnd || !entrbtn)
            return 0;
        
        HDWP collection = ::BeginDeferWindowPos(3);
        
        collection = ::DeferWindowPos(collection, entrbtn, 0, x - 37, 
                                      y - 20, 36, 19, SWP_NOZORDER);
        
        collection = ::DeferWindowPos(collection, mainwnd, 0, 1, 0, x - 
                                      2, y - 22, SWP_NOZORDER);
        
        collection = ::DeferWindowPos(collection, chatwnd, 0, 1, y - 
                                      20, x - 40, y, SWP_NOZORDER);
            
        if(!::EndDeferWindowPos(collection))
        		return 0;
                
        return 1;
    }
    It has a considerable amount of flickering. I am wondering whether taking control over the messages sent, optimizations, or subclassing would help this problem.

  2. #2
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    The flickering could be caused by overlapping controls, or the parent window drawing the background first, then the controls drawing over the background. Try giving the parent window the WS_CLIPCHILDREN style, and giving the controls WS_CLIPSIBLINGS.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    if that doesn't work, try returning true from WM_ERASEBKGND messages...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    ... arjunajay's Avatar
    Join Date
    May 2005
    Posts
    203

  5. #5
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Word.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 06:57 PM
  2. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  3. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM