Link to home
Start Free TrialLog in
Avatar of trillo
trillo

asked on

How to redraw a DC after minimizing a Dialog?

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.
ASKER CERTIFIED SOLUTION
Avatar of cyrilbdt
cyrilbdt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nietod
nietod

>> 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.
Avatar of trillo

ASKER

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.
>> 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.
Avatar of trillo

ASKER

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