MFC: Clear Client Area

This is a discussion on MFC: Clear Client Area within the Windows Programming forums, part of the Platform Specific Boards category; I am begginer with MFC im writing a small program where you can draw lines freely in the Client Area.. ...

  1. #1
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483

    MFC: Clear Client Area

    I am begginer with MFC im writing a small program where you can draw lines freely in the Client Area.. and i have a menu with only 1 option.. lol

    Its "Clear" Its suppose to clear w/e the user has drawn..

    right now i have it to post a WM_PAINT message but it doesn't seem to do anything... How ever if you do something to cause Windows to send a WM_PAINT message to the program it clears it..

    for example when you drag another window over it, or when you resize it..

    So how do i Clear the Client Area?

    EDIT:
    Forgot to mention im drawing something everytime WM_PAINT is called.. and thats whats causing it not to clear the Client area.. i tried without drawing anything and it works perfectly..
    Last edited by mrafcho001; 06-27-2005 at 10:15 AM.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    You could always paint via CClientDC. Instantiate a new CClientDC and pass in the view. Get the client area via GetClientRect().

    Kuphryn

  3. #3
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    The short answer is InvalidateRect(hwnd,0,TRUE); in the handler for "Clear" menu option;

    However you have other problems such as "How do I keep the window from clearing when I minimize or resize?" If you have the MS Visual studio, there is a MFC tutorial that comes with it called scribble which is a simple drawing tutorial like what you are doing. I'd recommend you work through it. I believe it's online to at msdn.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client - Server TCP/IP MFC app..... Help!
    By amedinadiaz in forum C++ Programming
    Replies: 0
    Last Post: 10-26-2005, 11:57 AM
  2. Client not receiving FD_CLOSE notification message?
    By dp_76 in forum Networking/Device Communication
    Replies: 2
    Last Post: 05-22-2005, 11:08 PM
  3. socket newbie, losing a few chars from server to client
    By registering in forum Linux Programming
    Replies: 2
    Last Post: 06-07-2003, 11:48 AM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. Clearing the client area
    By Isometric in forum Windows Programming
    Replies: 15
    Last Post: 01-29-2002, 09:07 PM

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