Repaint the Device Context

I'm using a Win32 app. If I would like to repaint the DC on a particular event, what instructions should I use?

case WM_PAINT:
     hdc = BeginPaint(hWnd, &ps);
     GetClientRect(hWnd, &rt);
     DrawText(hdc, szHello, strlen(szHello),
          &rt, DT_CENTER);

     MessageBox(hWnd, "The DC was repainted",
          "Repainting", 0);

     EndPaint(hWnd, &ps);
     break;

case WM_KEYDOWN:
     {
     char szMensaje[30];
     itoa(wParam, szMensaje, 10);

     // ******
     // Here I would like to send the repaint message
     // but PostMessage(hWnd, WM_PAINT, 0, 0)
     // doesn't do anything
     // ******
                   
     }
     return DefWindowProc(hWnd, message,
          wParam, lParam);
     break;

Any help would be appreciated
LVL 4
fcnatraSoftware...Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vadikCommented:
RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE) or
InvalidateRect.... but in my case your's code is working fine.Sorry for my English.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fcnatraSoftware...Author Commented:
RedrawWindow works alright. thanks.

The code is supposed to work fine, but it doesn't. Nevertheless, if I use PostMessage, the MessageBox in the WM_PAINT section shows, but the window is not repainted, unless I change the windows' size.

I'll use RedrawWindow.
0
vadikCommented:
If this is right answer give me my points pls :)))
0
PlanetCppCommented:
try SendMessage, also try

InvalidateRgn(hWnd,NULL,false);
UpdateWindow(hWnd);
0
fcnatraSoftware...Author Commented:
Sorry vadix, yesterday I clicked on the link to give you the points, but I didn't finish the steps.

So, here you have 'em.

   ABRACADABRA PATA DE CABRA
   LOS PUNTOS PARA VADIX QUIERO CONJURAR
   PARA QUE ESE EXPERTO QUE RESUELVE DUDAS
   SI UN DIA TIENE ALGUNA, PUEDA PREGUNTAR.

   CHUN!!!!!!!   50 points 4 U

   Thanks. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.