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

  • Home
  • SEARCH
  • 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 6473867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:31:03+00:00 2026-05-25T06:31:03+00:00

I’m still a beginner in programming GUI using c++ winapi32, and I found something

  • 0

I’m still a beginner in programming GUI using c++ winapi32, and I found something strange.
Here’s a part of my code:

        InvalidateRect(hwnd,&rect, true);
        //Sleep(delay);
        MessageBox(hwnd, "Blahblah!", "blahblah",MB_OK | MB_ICONINFORMATION);
        InvalidateRect(hwnd,&rect, true);
        //Sleep(delay);
        MessageBox(hwnd, "Blahblah!", "blahblah",MB_OK | MB_ICONINFORMATION);

I use Invalidaterect to repaint a part of my windows, and what I’m trying to do is to repaint the windows every 1 second or so to make the changes apparent to the user’s eyes. The strange part is that Sleep seems to not affect my windows if it’s not followed by MessageBox command, while in fact I dont want to have any MessageBox command for every repainting because it’s too disturbing.

I’ve tried 1000,2000, even 10000 for the delay.
The windoes did freeze with the sleep, but the apparent repainting is only done 1x in the last Sleep command…

This code is a part of, say, void A(). And void A() is called by void B().

       //Message loop
       if(turn == 0)
       {
       B();
       }           

Is there any alternative that I can do to fix this problem?

Oh yeah, I use MS Visual C++ 2008 Express by the way

Thanks in advance for any help regarding this matter 🙂

  • 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-25T06:31:03+00:00Added an answer on May 25, 2026 at 6:31 am

    The important thing is, that InvalidateRect doesn’t draw anything. It only schedules the window content to be drawn (enqueues a WM_PAINT message into the message queue). The actual drawing doesn’t happen until you return to the message loop and the window actually gets to process the paint message. So after the last Sleep/MessageBox you finally return from your function to arrive at the message loop again and in the message loop you finally get the WM_PAINT message that represents the actual paint event and process this message to redraw the window’s content.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm making a simple page using Google Maps API 3. My first. One marker
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.