forcing window repainting after putting back caption

This is a discussion on forcing window repainting after putting back caption within the Windows Programming forums, part of the Platform Specific Boards category; Hello, so I learned how to take off caption after CreateWindowEx: Code: DWORD styles; win32assert(thesquare->active, "square_setcaptionoff activity"); styles = GetWindowLong(thesquare->hwnd, ...

  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, 07:10 AM
  3. no errors but still errors
    By Megatron in forum Windows Programming
    Replies: 7
    Last Post: 01-12-2003, 10: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, 09:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21