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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:45:40+00:00 2026-05-18T19:45:40+00:00

I have a problem with WM_PAINT. Basically I want WM_PAINT to be called after

  • 0

I have a problem with WM_PAINT. Basically I want WM_PAINT to be called after a user WM_COMMAND, but for some reason it’s called anyway in the main function.

 case WM_PAINT:
    {
     createFont();
     PAINTSTRUCT ps;
     HBRUSH hbruzh = CreateSolidBrush(RGB(0,0,0));
     HDC hdz = BeginPaint(hWnd,&ps);
     string s = "Memory Address";

     SelectBrush(hdz,hbruzh);
     SelectFont(hdz,hf);
     TextOut(hdz,0,0,s.c_str(),s.length());
     EndPaint(hWnd,&ps);

     DeleteObject(hbruzh);
     DeleteObject(hdz);

     break;
    }




int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
               LPSTR lpCmdLine, int nCmdShow)
{
    HWND hWnd;
    WNDCLASSEX wc;
    ZeroMemory(&wc, sizeof(WNDCLASSEX));
 hThisInstance = hInstance;
 LoadLibrary("Riched20.dll");

 wc.cbSize = sizeof(WNDCLASSEX);
 wc.style = CS_HREDRAW | CS_VREDRAW;
 wc.lpfnWndProc = WindowProc;
 wc.hInstance = hInstance;
 wc.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU);
 if(!(wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_MYICON)))) {
  HRESULT res = GetLastError();

 }
 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
 wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
 wc.lpszClassName = TEXT("Testcpp");
 RegisterClassEx(&wc);

 hWnd = CreateWindowEx(NULL, 
       wc.lpszClassName,
       TEXT("uTest"),
       WS_OVERLAPPEDWINDOW,
       300,
       200,
       450,
       300,
       NULL,
       NULL,
       hInstance,
       NULL);
 ShowWindow(hWnd,nCmdShow);

 MSG msg;
 while (GetMessage(&msg, NULL,0,0)) {
  TranslateMessage(&msg);
  DispatchMessage(&msg);

 }


 return msg.wParam;
}

According to MSDN, WM_PAINT is only called automatically after either UpdateWindow() or ReDrawWindow(), or when you SendMessage with it as message. I do none, however. I basically only want to call WM_PAINT after a user interaction, not before… is there any way to fix this? What is causing this? (I guess its some bizare side-effect I cant find documentation for >.<)

  • 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-18T19:45:41+00:00Added an answer on May 18, 2026 at 7:45 pm

    WM_PAINT is called any time your window needs to be redrawn. That’s what it’s for. Showing the window, resizing the window, restoring the window from minimized state, bringing the window to the front after it’s been covered by another window, minimizing another app that was covering up your window… these are just a few of the things that will send a WM_PAINT.

    I think you’re trying to use WM_PAINT for something it’s not intended for.

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

Sidebar

Related Questions

I have problem with fancybox. I want to write a function that will run
I have problem with $_POST data. Some fields are missing from input form when
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names
I like to write a modeless dialog based app, but I have a problem.
I've had this problem for a while now but I have to remedy it
I am facing a weird problem. I have got a file called in which
I have a problem with MouseEvents on my WinForm C# application. I want to
I have an interesting (but frustraring) problem. I have an application which uses the
I have problem with copying sdf file to WM emulator. My solution structure MyApp.DataLayer

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.