?
Solved

Repaint the Device Context

Posted on 2003-02-25
5
Medium Priority
?
253 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:fcnatra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
vadik earned 200 total points
ID: 8018253
RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE) or
InvalidateRect.... but in my case your's code is working fine.Sorry for my English.
0
 
LVL 4

Author Comment

by:fcnatra
ID: 8018396
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
 
LVL 1

Expert Comment

by:vadik
ID: 8018527
If this is right answer give me my points pls :)))
0
 
LVL 6

Expert Comment

by:PlanetCpp
ID: 8019298
try SendMessage, also try

InvalidateRgn(hWnd,NULL,false);
UpdateWindow(hWnd);
0
 
LVL 4

Author Comment

by:fcnatra
ID: 8023605
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question