Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7695607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:34:56+00:00 2026-05-31T21:34:56+00:00

I want to show on the screen some value, that are changeable. I have

  • 0

I want to show on the screen some value, that are changeable. I have following code

void CMainWnd::OnPaint()
{
    CPaintDC dc(this);
    CRect rcText( 0, 0, 500 ,500 );

    wchar_t text[36];       
    unsigned int num = server->GetNumClients(num);
    wsprintf(text, L"Number of connected clients: %d", num);

    dc.DrawText(text, &rcText, DT_LEFT);
    CFrameWnd::OnPaint();
}

 void CMainWnd::OnTimer(UINT timerID)
 {
     SendMessage(WM_PAINT, 0, 0);
 }

It draws text when window appears. But in next calls when text is different the text on the screen didn’t change. Using the debugger I can see that OnPaint was called, text has been changed, but on my window text remains the same. GetLastError() returns 0. I think I’m missing something important how DrawText works. I tried to call UpdateWindow() in the end, but nothing changed. For some reason screen is not updates..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:34:58+00:00Added an answer on May 31, 2026 at 9:34 pm

    You should not send a paint message directly, but instead invalidate the area to be repainted (InvalidateRect(&area) ) and let the system handle it. By only sending a paint, you don’t get anything because the system says ‘There’s no area that needs painting, so for efficiency I won’t bother’ – or rather, the clip area that constrains painting will be empty (no update area). By invalidating an area you tell the system that that area needs repainting, so the next paint call will have a valid clip area and you will see a change.

    (Better to use wsprintf_s() with the buffer size – in fact, as you appear to be using MFC use CString and CString::Format() instead – and you should not call the base class OnPaint() (it has no effect, since when the CPaintDC goes out of scope it clears any update area).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code for a basic start screen, But i want to change
I want to show a welcome screen as well as some basic tutorials of
I want to show a div that serves as a loading screen when invoking
I want to design a splash screen that can show the current loading process
I want to show a Profile screen for my users. It must have three
I'm creating an application that uses an ImageSwitcher to show some images. I want
I want to show some information in the middle of a call in that
I want to show a dialog (kind of splash screen) when my application is
I have a console application which screen scrapes some data, and now I need
I used to show a splash screen which in background load some data from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.