Re: Drawing on DC

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance





thanks a lot Joseph, can you finally say me about a good guide to Windows
Drawing?

"Joseph M. Newcomer" wrote:

Actually, I do exactly what you describe: my display list has a Draw method and I invoke
that. I didn't want to overwhelm him, but the solution of having a draw method of the
display list is certainly the cleaner approach.
joe

On Sun, 19 Nov 2006 03:12:10 GMT, Dan Bloomquist <public21@xxxxxxxxxxx> wrote:



MarcoMB wrote:

Thanka a lot for your patience with me, i please you to understand i'm trying
to learn on myself Visual C++ studying on book etc, and it's not my true job,
i make it only for passion.So i tried to handle the static draw of my objects
in WM_PAINT message as you said, and it's ok, the solution was under my eyes
... i'm going to studing Scribble carefully following your advice...and i'll
consider all your help like gold...unfortunately i based my app on a sample
tutorial i found on book that to mantain simple learning based the object on
CObArray, but i've read what you say that it's going wrong with those type of
generic object, and use instead template class that accept only specified
type of data object like CArray.I'll try to modify my simple paint
app...thanks a lot again.

I have not looked at SRIBBLE in a while.

Joe has gotten you see that OnDraw is where it happens. The only reason
for drawing in OnMouseMove is that the mouse is captured and the window
is on top. That makes it simple to eliminate flicker and use little
processor time. The strokes are going into the container where it counts.

You may want to use typedefs. For instance in OnDraw you will see:

CTypedPtrList<CObList,CStroke*>& strokeList...

The more often you do this the more often You commit to the specific
container/method. In a header about drawing objects, (right after the
CStroke declaration in this case):

typedef CTypedPtrList<CObList,CStroke*> STROKELIST;

Here is why. In the example the doc is the container. What happens when
you want an independent generic container? You will soon have a class
that is just that and the doc is only about file io. At that the doc
could evolve to some 'project' io and know nothing about files. But you
will want to caompartmitize this stuff to make your work OO. So you will:

typedef CDrawingImage STROKELIST;

And CDrawingImageContainer does what the doc did at first.

What about the view? Same thing can apply. The view can become more
generic and if the STROKELIST is snapped in, mouse moves can be relayed
when enabled and:

void CScribbleView::OnDraw(CDC* pDC)
{
//if attached/enabled
strokeList.Draw( pDC );
//a one liner, and now it is windows portable.
}

Take a good look at OnDraw. The view really has nothing to do with
drawing. It is done with the DC. What if you want your stuff to work
with the WTL? It can without a breath.

I am not trying to overwhelm you. But this is what c++ is really about.
c++ is not an Object Oriented language, just an opportunity to program OO.

Here is a simple implementation example of a class that works with MFC,
WTL, and a plain old winmain:

https://secure.codeproject.com/opengl/EGA.asp
(the gagl class)

Start with what Joe wrote. It is about how the API works, and it applies
to all platforms as well as windows implementations.

Best, Dan.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

.



Relevant Pages

  • Re: Drawing on DC
    ... can you finally say me about a good guide to Windows ... for drawing in OnMouseMove is that the mouse is captured and the window ... The strokes are going into the container where it counts. ...
    (microsoft.public.vc.mfc)
  • Re: Drawing on DC
    ... The only reason for drawing in OnMouseMove is that the mouse is captured and the window is on top. ... The strokes are going into the container where it counts. ... It is about how the API works, and it applies to all platforms as well as windows implementations. ...
    (microsoft.public.vc.mfc)
  • Scratchbuilding notes
    ... Which is to say that it warps like a mother once you apply wet glue to it, or make significant cuts into or out of it. ... the thing that really makes or breaks a building such as this is the windows and doors. ... I used these to make a mechanical drawing, using pen & ink, which I then also scanned. ...
    (rec.models.railroad)
  • Re: Gotta love them
    ... I thought the only time there was anticipated to be poison gas was ... during the Gulf Wars and even then it was only suspected and never ... container and put everything in the "safe room". ...
    (soc.culture.jewish.moderated)
  • Re: Hints on Drawing in TASM
    ... Theres a few chapters there on speedy line drawing. ... For windows: Use DirectX backbuffer or a GDI BitmapSection to draw in. ... Today some people use Hardware line drawing, ...
    (alt.lang.asm)