Solved

How to redraw a DC after minimizing a Dialog?

Posted on 1998-11-11
5
378 Views
Last Modified: 2012-06-27
I'm writing an App that draws some lines on a STATIC control (simple graphics static control) with a black background. The problem is that after restoring the minimized Dialog, the frame appears without those lines.
I suppose that I have to process the WM_PAINT message but how can I know if the message is sent to redrawing the Dialog or the childwindow (the Static control)??
Is WM_PAINT also sent when hiding a window that was covering my application?
Any help would be greatly appreciated.
0
Comment
Question by:trillo
  • 2
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
cyrilbdt earned 100 total points
ID: 1177677
WM_PAINT is sent when window client area needs to be paint.
Draw your static control in OnPaint function.
There is a clip rgn, so don't worry if there is a window over your app dialog.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177678
>> Is WM_PAINT also sent when hiding a window that was covering my application?
If part or all of your window is covered and then is "revealed" in any way (another window moving, hiding, being destroyed) you will get a WM_PAINT message to lett you paint in the revealed area.   Whenever you get a WM_PAINT message, the DC created by BeginPaint() will clip drawing to only the vissible portion of your window.  Thus if another partly covers yours, you don't have to worry about it, If you try to draw on the arrea it covers, the information drawn will not appear.

>> I have to process the WM_PAINT message but how can I know if
>> the message is sent to redrawing the Dialog or the childwindow
>> (the Static control)
Both windows will get WM_PAINT messages as they need them.  But since you need to draw in the static control, you want to handle the paint message in the static control.  if you wnated to draw on the dialog, you would handle the dialog's paint message.

>>Draw your static control in OnPaint function.
That only applies to an MFC application.  If not MFC you need to "hook" the WM_PAINT message.  Same idea, different technique.
0
 
LVL 2

Author Comment

by:trillo
ID: 1177679
Thanks for your answers and comments...
One of the problems is that I'm NOT using MFC.
I don't know how to handle the WM_PAINT message to repaint my STATIC control. I supose I recieve this message at least two times: One for the dialog and the other for my STATIC... (or more WM_PAINT messages for other controls)... but how can I reject all WM_PAINT messages except tho one for the STATIC? Actually how can I recognize for which window or control is the message, with which parameter?
Or is my theory completely wrong?
Or is ther maybe an easier way to do this?
Remember I'm not using MFC.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177680
>> how can I recognize for which window or control is the message, with which parameter?
You don't need to.  Different windows have different window procedures.  The paint message for a static control is sent to the static window and is handled by its window procedure.  The paint message for a dialog window is sent to the dialog window and is handled by its window procedure.

It sounds like you need to do some basic windows research.  Get an introductory book or two on windows programming.
0
 
LVL 2

Author Comment

by:trillo
ID: 1177681
Thanks nietod, this was actually my first quwstion asked in EE and I didn't know that once a question was accepted, another one couldn't get some points.... I f I would have known I would have given tho points to you....
Actually I did subclass my static control changing it's windows procedure and it works fine. (First i thagut that WM_PAINT was something like WM_COMMAND where one of the paremeters is teh control ID)
Thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
  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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now