Solved

How to redraw a DC after minimizing a Dialog?

Posted on 1998-11-11
5
381 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
c++ mixing int and strings in multi array 8 71
std::atomic with custom class 6 190
PDF library for Delphi 2 105
C++ mouse_event mouse look 7 70
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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.
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.

920 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

16 Experts available now in Live!

Get 1:1 Help Now