MFC newbie --- simple problem

This is a discussion on MFC newbie --- simple problem within the Windows Programming forums, part of the Platform Specific Boards category; hi ! I just started doing some MFC programming and have been using the MFC appwizard for starters and this ...

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    91

    MFC newbie --- simple problem

    hi !

    I just started doing some MFC programming and have been using the MFC appwizard for starters and this is my first MDI app

    I am trying to redraw the entire screen ...... is there a function which can clear out the entire view ... that means wipe everything that is shown on the screen ....
    Last edited by gemini_shooter; 04-02-2006 at 09:42 AM.

  2. #2
    Registered User
    Join Date
    Apr 2005
    Posts
    30
    Do you know much of the Win32 API? If you're learning MFC, from what I've heard, knowing some of the API will help you when you need to do something that the API can do, but MFC can't. Although I dont personally know any MFC, I know the Win32 API, and I'd redraw the screen using something like UpdateWindow or InvalidateRect

    If you want to redraw the entire screen, I'd probably Invalidate the entire window rect which will cause the whole area to be redrawn. Like this:

    Code:
    InvalidateRect(hWnd, NULL, TRUE);
    UpdateWindow(hWnd);
    If theres an easier way to do it in MFC, I'll let someone else post that
    Last edited by TheDan; 04-02-2006 at 11:17 AM.

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    91
    well I am aware of the InvalidateRect function ... the problem is it calls the OnDraw() function which I don't want since this call will be made from a switch statment in OnDraw .... so it will jump into an infinite loop ..... I just need a function which can wipe put what i drew on the screen previously ...... any clues

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    I just started doing some MFC programming and have been using the MFC appwizard for starters and this is my first MDI app

    I am trying to redraw the entire screen ...... is there a function which can clear out the entire view ... that means wipe everything that is shown on the screen ....
    The call to Invalidate doesn't quite call OnDraw. The invalidate messages are put onto a queue for latter processing and your OnDraw will return before they are processed.


    To update the screen, however, you want to use the methods defined in the CDC* pDC passed into the OnDraw method. Something like
    Code:
    COLORREF color = RGB(100, 100, 100);
    CBrush brush(color);
    CRect clientRect;
    
    GetClientRect(&clientRect);
    pDC->FillRect(&clientRect, &brush);
    ought to work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  2. simple JPEG problem
    By the bassinvader in forum C Programming
    Replies: 6
    Last Post: 10-05-2006, 05:45 PM
  3. Simple Gets() problem
    By akira181 in forum C++ Programming
    Replies: 17
    Last Post: 05-25-2006, 03:28 AM
  4. problem with MFC application
    By Micko in forum Windows Programming
    Replies: 1
    Last Post: 07-12-2004, 05:36 PM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 02:57 PM

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