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 3342056
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:47:38+00:00 2026-05-18T00:47:38+00:00

I have done some tests with QueryPerformanceCounter and got strange results. It seems that

  • 0

I have done some tests with QueryPerformanceCounter and got strange results.
It seems that my simple program refreshes slowly (about 40ms) when it doing nothing, but when I put RedrawWindow with RDW_INVALIDATE message it refreshes and works very fast (about 1ms)

Please look at the examples:

{…}

double PCFreq = 0.0;
__int64 now = 0, start = 0;

LARGE_INTEGER li;

PCFreq = double(li.QuadPart)/1000;

AllocConsole( );  
freopen("CONOUT$", "wb", stdout);

double delay;

while (GetMessage (&messages, NULL, 0, 0))
{
        QueryPerformanceCounter(&li);    
        now = li.QuadPart;

        if ( double(now - start) / PCFreq >= 40)
        {
                **// painting !!!**

         cout <<  double(now - start) / PCFreq << "\n";
         start = now;
        }

        // !!!!!!
        **RedrawWindow(hwnd, NULL, NULL, RDW_VALIDATE);** 

        TranslateMessage(&messages);
        DispatchMessage(&messages);

    }

    FreeConsole( );   

{…}

When the RedrawWindow(hwnd, NULL, NULL, RDW_VALIDATE); is in main loop I can obtain exacly 40ms or even 5ms, but without RedrawWindow(hwnd, NULL, NULL, RDW_VALIDATE); the condition if ( double(now – start) / PCFreq >= 40) is entering no faster than 45-50 ms….

My question is:
How can I avoid RedrawWindow(hwnd, NULL, NULL, RDW_VALIDATE); function but keep fast refreshing. When Iam using RedrawWindow(hwnd, NULL, NULL, RDW_VALIDATE); my interface (buttons, windows) not displays.

THANKS!

  • 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-18T00:47:39+00:00Added an answer on May 18, 2026 at 12:47 am

    GetMessage does not return unless there is a message in the message queue. By calling RedrawWindow, you are putting a Message in the queue every single iteration of the loop. Use PeekMessage instead of GetMessage:

    while (true)
    {
        if (PeekMessage(&messages, NULL, 0, 0, PM_REMOVE))
        {
            if (messages.message == WM_QUIT)
                break;
            TranslateMessage(&messages);
            DispatchMessage(&messages);
        }
    
        // Do your stuff here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have done some learning on struts based on one project that i got.Now
I have done some tests, and I have find out that after_create is called
I am working on some test program for SpringData MongoDB , I have done
Have done some research and found some stuff that may be helpful. I would
I have done some searches looking for information about how to do logging with
I have done some research on the above and found that I am able
I am researching UDID alternatives, and OpenUDID seems interesting. I have done some testing
Why JSON? I have done some tests today, and the request time for both
I have done some tests in jmeter which produces an xml report in the
I have two kinds of Unit tests (not integration test). Because of some strange

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.