Thread View: comp.os.ms-windows.programmer.graphics
3 messages
3 total messages
Started by Adge
Fri, 22 Mar 1996 17:21
Drawing from any procedure
Author: Adge
Date: Fri, 22 Mar 1996 17:21
Date: Fri, 22 Mar 1996 17:21
26 lines
1316 bytes
1316 bytes
I am programming in ms Visual C++ v.4.0 under Win95, and am trying to persuade it to allow me to draw graphics to a window from a procedure other than OnPaint or OnDraw. I have tried using CPaintDC(this); , but this gives an access violation. It used to be possible under Borland Pascal for win but I can't work out how to do it under visc++ Can anyone help ? Regards Adge ---------------------------------------------------------------------------- Adrian Davis, 4th Year Engineering Electronics Beng (hons) Meng. A.P.M.Davis@warwick.ac.uk ---------------------------------------------------------------------------- Back by popular request : When God designed the human body, why did he put the ignition so near the exhaust ? ---------------------------------------------------------------------------- Warwick Uni Fencing Club (suaao) WWW - http:/www.csv.warwick.ac.uk/~suaao/ ----------------------------------------------------------------------------
Re: Drawing from any procedure
Author: David Byrden
Date: Sat, 23 Mar 1996 02:54
Date: Sat, 23 Mar 1996 02:54
15 lines
1090 bytes
1090 bytes
esuvx@csv.warwick.ac.uk (Adge) wrote:
>I am programming in ms Visual C++ v.4.0 under Win95, and am trying to
>persuade it to allow me to draw graphics to a window from a procedure other
>than OnPaint or OnDraw.
>
>I have tried using CPaintDC(this); , but this gives an access violation.
First, you must tell us this; is your program multithreaded, and
are you trying to draw in a thread other than the one that is allowed use
MFC? I don't have the answer for you, but I know we need that information.
David
Re: Drawing from any procedure
Author: John Grant
Date: Sun, 24 Mar 1996 23:17
Date: Sun, 24 Mar 1996 23:17
30 lines
1720 bytes
1720 bytes
In article <4iuni1$oep@lily.csv.warwick.ac.uk> esuvx@csv.warwick.ac.uk (Adge) writes: > >I am programming in ms Visual C++ v.4.0 under Win95, and am trying to >persuade it to allow me to draw graphics to a window from a procedure other >than OnPaint or OnDraw. > >I have tried using CPaintDC(this); , but this gives an access violation. > >It used to be possible under Borland Pascal for win but I can't work out >how to do it under visc++ > >Can anyone help ? If you respond to WM_PAINT, then you are provided with an HDC (presumably your OnPaint does the BeginPaint/EndPaint stuff for you). If you wish to draw at any other time, you need to obtain an HDC, i.e. with GetDC(). Do your drawing and then ReleaseDC(). However, there is a very good reason for doing *ALL* of your drawing at WM_PAINT. Consider what happens if you draw something anytime you want (i.e. not at WM_PAINT). Your picture looks fine, right? Ok, now what happens if your app is covered/uncovered by a dialog box or another app? That generates WM_PAINT and you will draw part of the picture, but not the part that you drew separately. Remember that you must be prepared to paint any or all of your picture at any time at WM_PAINT. -- John A. Grant jagrant@emr1.emr.ca Airborne Geophysics Geological Survey of Canada, Ottawa
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads