Solved

How to redraw a DC after minimizing a Dialog?

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

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…
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…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

752 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