drawing surface issue... 
Author Message
 drawing surface issue...

hello:

i recently wrote a small whiteboard drawing application (similiar to ms
paint) in VB using GDI API calls.  the application for the most part works
fine, but i have one issue that i was wondering how people deal with:  i use
a VB picturebox as my drawing surface (of which i pass its handle to the API
calls), which works fine. the problem is when there is a window in front of
my drawing surface (typically from another program like the windows Task
Manager).  when this is the case, and a user draws, the portion of the
foreground window also blits to the whiteboard surface.

i understand why this occurs as the drawing surface is vulnerable when
drawing, but how do people tackle this issue?  also, dont some people use
metafiles for creating applications similiar to mine?  will this solve my
problem?  when is this better than using the GDI?

any help is much appreciated.
thanks,

Benjamin Callister
Vice President of Engineering, Tutor.com
Real Tutors, Real Results.
http://www.*-*-*.com/



Mon, 21 Mar 2005 23:46:04 GMT  
 drawing surface issue...

Quote:
> i recently wrote a small whiteboard drawing application (similiar to ms
> paint) in VB using GDI API calls.  the application for the most part works
> fine, but i have one issue that i was wondering how people deal with:  i
use
> a VB picturebox as my drawing surface (of which i pass its handle to the
API
> calls), which works fine. the problem is when there is a window in front
of
> my drawing surface (typically from another program like the windows Task
> Manager).  when this is the case, and a user draws, the portion of the
> foreground window also blits to the whiteboard surface.

> i understand why this occurs as the drawing surface is vulnerable when
> drawing, but how do people tackle this issue?  also, dont some people use
> metafiles for creating applications similiar to mine?  will this solve my
> problem?  when is this better than using the GDI?

Have you tried setting the AutoRedraw property of the picture box to true?
Make sure you're drawing to it's .hDC property and not to the underlying
Bitmap  through .Picture.Handle or anything of that sort.
I doubt applications would use a metafile to store this kind of drawing,
however you can set a DC to record GDI call to a metafile which you may be
thinking of perhaps?
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Tue, 22 Mar 2005 01:03:55 GMT  
 drawing surface issue...
thanks, Mike...
i am using the hDC and not the bitmap handle. as far as AutoRedraw is
concerned, i have to set it to FALSE when i do my drawing, and then back to
TRUE when i am done. that is the only way to actually draw, via a GDI call,
to the picturebox. the problem is during that time while i am drawing (when
AutoRedraw = FALSE) that the drawing surface is vulnerable.

any more thoughts?
thanks,
Ben



Quote:
> > i recently wrote a small whiteboard drawing application (similiar to ms
> > paint) in VB using GDI API calls.  the application for the most part
works
> > fine, but i have one issue that i was wondering how people deal with:  i
> use
> > a VB picturebox as my drawing surface (of which i pass its handle to the
> API
> > calls), which works fine. the problem is when there is a window in front
> of
> > my drawing surface (typically from another program like the windows Task
> > Manager).  when this is the case, and a user draws, the portion of the
> > foreground window also blits to the whiteboard surface.

> > i understand why this occurs as the drawing surface is vulnerable when
> > drawing, but how do people tackle this issue?  also, dont some people
use
> > metafiles for creating applications similiar to mine?  will this solve
my
> > problem?  when is this better than using the GDI?

> Have you tried setting the AutoRedraw property of the picture box to true?
> Make sure you're drawing to it's .hDC property and not to the underlying
> Bitmap  through .Picture.Handle or anything of that sort.
> I doubt applications would use a metafile to store this kind of drawing,
> however you can set a DC to record GDI call to a metafile which you may be
> thinking of perhaps?
> Hope this helps,

>     Mike

>  -- EDais --

>  - Microsoft Visual Basic MVP -
> WWW: Http://EDais.earlsoft.co.uk/





Tue, 22 Mar 2005 02:25:10 GMT  
 drawing surface issue...
<snip>
Quote:
> that is the only way to actually draw, via a GDI call,
> to the picturebox

<snip>

Nope..  Just call the .Refresh method when you're done, the AutoRedraw
method is nice because it _doesn't_ redraw until you explicitly tell it to,
that's why you can get near flicker-less drawing with a picture box unlike
other controls.  Have a look at the "Basic introduction to graphics
programming in VB" tutorial on my page which explains the use of the Picture
box and how to use it effectively with the GDI API.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Tue, 22 Mar 2005 02:37:33 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Drawing Surface/Video Mixing question

2. DirectDraw problem drawing text on surface

3. Drawing to VB PictureBox by getting surface DC

4. Transparent drawing on DirectDraw surfaces

5. drawing without a surface

6. DirectDraw Buffered Surface for a Primary Surface Flipping Chain

7. copying data from a DirectX8 surface to a DirectX 7 surface

8. Various issues with "Drawing Canvas"

9. Draw rotated text on a form --- font issues

10. Drawing functions(formulas) to draw graphics Like Fxtools.vbx

11. Where can I find a good Owner Drawn Combo and Owner Drawn TextBox

12. how to draw japanese text on a directdraw surface??

 

 
Powered by phpBB® Forum Software