• Advertisement
Sign in to follow this  

How to save a device context ?

This topic is 4046 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have some window in c++ with a 'frame' item placed in it. I am drawing stuff using SetPixel (hDC,x,y,COLORREF) I retrieve the DC with GetDC(getDlgItem(wnd,frame)) The drawing goes well, but whenever the window loses focus, or something get on top of the window, the drawing disappear. To be more specific, I have a proces going on, and during that I want to draw a graph of the process. so; while (process) x++; calc(y) SetPixel(x,y) I've tried the functions SaveDC and RestoreDC ( I saved after the process, and restored on messages ). RestoreDC always returned 0. I wonder, will this work at all? How could I make sure that what I draw with SetPixel(..) also stays drawns after it has been 'out of sight'?? Like a button or whatever also simply stays drawn, after minimalizing the window or whatever. Thanx in advance

Share this post


Link to post
Share on other sites
Advertisement
In my opinion, it would be best to draw the stuff again, what you want to draw!?

You could try just to place a UpdateWindow() call in the programms WM_PAINT message...

UpdateWindow calls the frame you want to draw. And within the frame(window), there is another WM_PAINT message where the stuff is drawn.

This is how I would do it..

Hopefully this was usefull to you.

Greeting
Alex

Share this post


Link to post
Share on other sites
Quote:
Original post by Don GL
Like a button or whatever also simply stays drawn, after minimalizing the window or whatever.

The button doesn't stay drawn. It draws itself again, as a result of the WM_PAINT message. Since it remembers its width, height, caption, etc., it can draw itself as many times as it wants, and be drawn the same each time. Learn from its example.

Share this post


Link to post
Share on other sites
I'd recommend using a bitmap section. That would allow you to save it, be good coding style, and probably be way faster than what you're doing.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement