Thread: MFC question...

  1. #1
    Registered User
    Join Date
    Sep 2003

    Question MFC question...

    I have a problem to write an MFC application that will display whatever the user types in the client area. Also I need to restore (repaint) everything when user minimize the window.

    Right now I am using the code from the book that allows user to enter one char and to restore the same one but I dont know how to that for more lines. New line should start when user press enter.

    // Process a WM_CHAR message.
    afx_msg void CMainWin::OnChar(UINT ch,
                                  UINT count, UINT flags)
      CClientDC dc(this);
      dc.TextOut(1, 1, "   ", 3); // erase previous char
      wsprintf(str, "%c", ch);
      dc.TextOut(1, 1, str, strlen(str));
    // Process a WM_PAINT message.
    afx_msg void CMainWin::OnPaint()
      // If we use CClientDC instead we will have a LOT of paint messages.
      CPaintDC dc(this);
      // this line redisplays the last character
      dc.TextOut(1, 1, str, strlen(str));
    this is what i'm using so far (copy/paste from the book)

    everything will help

  2. #2
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Instead of using a char* you should change it to using CString (MFC) or string (STL) that way in the OnChar() function you could do variable += ch to add the char on the end of the string.
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. MFC check box question
    By MyglyMP2 in forum Windows Programming
    Replies: 2
    Last Post: 03-09-2009, 05:47 PM
  2. MFC simple question
    By dole.doug in forum Windows Programming
    Replies: 5
    Last Post: 09-26-2008, 06:11 AM
  3. Window Resize question (MFC)
    By IfYouSaySo in forum Windows Programming
    Replies: 2
    Last Post: 11-16-2005, 12:34 PM
  4. MFC UI question
    By naruto in forum Windows Programming
    Replies: 1
    Last Post: 04-21-2005, 10:10 PM
  5. MFC Dialog App Screen Refresh Question
    By Scotth10 in forum Windows Programming
    Replies: 2
    Last Post: 10-18-2002, 02:07 PM