Thread: Resize the window

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    Resize the window

    When you resize the window, does Windows invalidate the whole client area? I just wrote a program that writes to the client, and then I resized the window and...BANG...it was nothing. So, I guess I'll have to write an extra code tidbit in WM_PAINT to write it back to the client.

    --Garfield
    1978 Silver Anniversary Corvette

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    202

    memory HDC

    you should be able to make a HDC that is stored in the memory and then re-write it to the main HDC. There is a thread from a while ago that has instructions or search online for help. That should preserve whatever is written. The other choice that I know of is to eliminate the possibility to resize except this annoys people sometimes.

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Ummm...couldn't find the thread. Could you explain how to do it or could you link me to the thread? Thanks, I appreciate it.

    --Garfield
    1978 Silver Anniversary Corvette

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    202
    Create TWO HDC's exactly the same.
    Compatible with the HWND from the area you want to draw too and the same size as this area. [GetWindow() for the HWND and GetClientRect() for the size]. If in doubt create them the size of the screen.

    One is FrameBufferHDC. This is the HDC to which you will do all the drawing. Create the axis on this one, graph to this one and write text to this one.

    When ALL the drawing is finished, call a function that copies the FrameBufferHDC to the ScreenHDC. Do this with BitBlt() or if the screen has changed size, StretchBlt(). [I would get the BitBlt() then go on to the StretchBlt() later]. You will have an area, usually a rectangle that has been redrawn, get this to repaint by calling InvalidateRect(). This will send the WM_PAINT msg.

    Call the function [Repaint()] in response to a WM_PAINT msg.
    The HDC passed to it should be your ScreenHDC.

    As all the drawing is done to one HDC and the repaint from another you can be redrawing the graph AND repainting the screen at the same time.
    The paint contains NO calculations and ONE BitBlt() for speed. [BitBlt() is faster and much better than StretchBlt)]

    I use a factor, aprox 1.17, to correct the yScale, as the pixcells on the monitor are not square but rectangular. Remember that the Y screen cood go DOWN and the Y scale usually goes UP.

    PS make your HINSTANCE a global.


    and here is the thread I meant: http://www.cprogramming.com/cboard/s......HELP+PLEASE

  5. #5
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Thanks! I'll work on it.

    --Garfield
    1978 Silver Anniversary Corvette

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    That sounds familar....
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  7. #7
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Originally posted by novacain
    That sounds familar....
    What???
    1978 Silver Anniversary Corvette

  8. #8
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    Petzold's book says WM_SIZE is followed immediately by WM_PAINT message.

  9. #9
    Registered User
    Join Date
    Nov 2001
    Posts
    202
    yes novacain I copied it out of your exact message to me a few monthes ago (the student has become the teacher :-) )

  10. #10
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Originally posted by golem
    Petzold's book says WM_SIZE is followed immediately by WM_PAINT message.
    And...what do you mean?

  11. #11
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    Nothing, if your program works well.

  12. #12
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    I'm still not really following you, golem. Oh well.
    1978 Silver Anniversary Corvette

  13. #13
    Registered User
    Join Date
    Nov 2001
    Posts
    202
    Basically what golem is saying is that whenever windows sends you a WM_SIZE message it is immediatly followed by a WM_PAINT message. Much the same way that WN_CREATE does. That is why you are losing what your drawing it is automatically repainting when its size changes. Get it?

  14. #14
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Get it?
    Yup! Thanks, everyone!

    --Garfield
    1978 Silver Anniversary Corvette

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 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