Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Repaint the Device Context

Posted on 2003-02-25
5
Medium Priority
?
259 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
  • 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

577 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