Thread: forcing window repainting after putting back caption

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    108

    forcing window repainting after putting back caption

    Hello,

    so I learned how to take off caption after CreateWindowEx:

    Code:
       DWORD styles;
    
       win32assert(thesquare->active, "square_setcaptionoff activity");
    
       styles = GetWindowLong(thesquare->hwnd, GWL_STYLE);
       styles &= ~(WS_CAPTION);
       SetWindowLong(thesquare->hwnd, GWL_STYLE, styles);
    following that code is repainting, which works fine. However,

    Code:
       styles = GetWindowLong(thesquare->hwnd, GWL_STYLE);
       styles |= WS_CAPTION;
       SetWindowLong(thesquare->hwnd, GWL_STYLE, styles);
    
       InvalidateRect(thesquare->hwnd, NULL, TRUE);
       SetWindowPos(thesquare->hwnd, NULL, 0,0,320,240, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER);
    The above code tries to put back the caption bar. It doesn't repaint for some reason though, you have to drag the window first for the caption bar to appear..

    This is how it's supposed to work from this tutorial.. I don't know why it doesnt work. Am I missing something? I thought the code is identical to the one from the tutorial, so it's strange and I'm stuck.

    Please help, cheers

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    108
    also, for some reason,
    Code:
       styles = GetWindowLong(thesquare->hwnd, GWL_STYLE);
       styles |= WS_CAPTION;
       SetWindowLong(thesquare->hwnd, GWL_STYLE, styles);
    
       msgbox_alert("bang");
    
       InvalidateRect(thesquare->hwnd, NULL, TRUE);
       SetWindowPos(thesquare->hwnd, NULL, 0,0,320,240, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER);
    calling a MessageBox function in between makes the title bar appear.. while the repaint code doesn't. Hrmm.. win32 is confusing..

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    108
    I fixed the problem : seems like you needed to put UpdateWindow() on the end. I can't believe how stupid I was.. sorry for bothering you all

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 04:10 AM
  2. dont want to use all params
    By stallion in forum Windows Programming
    Replies: 2
    Last Post: 02-18-2003, 08:10 AM
  3. no errors but still errors
    By Megatron in forum Windows Programming
    Replies: 7
    Last Post: 01-12-2003, 11:21 PM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM