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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:13:01+00:00 2026-05-14T20:13:01+00:00

on WM_PAINT i do the following: //RectF mNameRect; //WCHAR* mName; //HWND mWin; // this

  • 0

on WM_PAINT i do the following:

//RectF mNameRect;
//WCHAR* mName;
//HWND mWin; // this is the window handle
{
PAINTSTRUCT ps;

HDC hdc = BeginPaint(mWin, &ps);
Graphics g(hdc);
g.Clear(Color::White);

StringFormat stringForm;
stringForm.SetLineAlignment(StringAlignmentCenter);
stringForm.SetAlignment(StringAlignmentCenter);

// set the rectangle to the size of the whole window

mNameRect.Width = static_cast<float>(size.cx);
mNameRect.Height = static_cast<float>(size.cy);

g.DrawString(mName, -1, &mNameFont, mNameRect, &stringForm, &mNameBrush);

EndPaint(mWin, &ps);
}

In XP this works fine, the mName is displayed in the middle of the window. However on Vista the text doesn’t move, it stays in its location no matter how I resize the window. the g.Clear(Color::White) doesn’t seem to do any difference. The text doesn’t even change position when the window is hidden behind another window and on focus needs to be repainted again.

How do I make mName change position in Vista?

Edit:
The paint code gets called via WM_PAINT and via WM_SIZE in the following manner:

// WndProc function
switch (msg){
    case WM_SIZE:
    // intentionally call paint when WM_SIZE is triggered
    case WM_PAINT:
        paint();
    break;
  • 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-14T20:13:02+00:00Added an answer on May 14, 2026 at 8:13 pm

    You are explicitly calling your paint() function when the window is resized. However, your window is not invalidated, so it could be that the system is restricting your painting efforts to the region marked “dirty”.

    Instead of calling paint() directly, it is better to use InvalidateRgn to trigger a repaint. This will cause a WM_PAINT to be sent which will be handled by your application in the normal way. As a bonus, you can also tell InvalidateRgn to erase the background for you

    InvalidateRgn(hWnd, NULL, TRUE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to make a screenshot of program window using WinAPI & C#? I sending
I know that WM_PAINT tells a window that it needs to repaint itself entirely,
I scroll the parent window by invalidating and redrawing all the content inside WM_PAINT
I'm drawing text on window at WM_PAINT message, is there any way i can
I created a window with the following flags to overlay a d3d application: WS_EX_TOPMOST
I'm kinda new to this area, so.. I made the following code, as far
What is the opposite of WM_ACTIVATE (Window deactivation message)?
I have an ATL app where I want to handle WM_POWERBROADCAST . I have
I try to create 2 buttons inside my app case WM_CREATE:{ hWnd =CreateWindowEx(NULL, LBUTTON,
This is a more concrete question that is connected with my previous one. I

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.