Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / June 2008



Tip: Looking for answers? Try searching our database.

how to pass a drawing area limitation?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Boris Danner - 02 Jun 2008 08:45 GMT
I'm writing a grid control which does the main work to draw
the grid lines into a picturebox and handles cursor
movement, scrolling, and so on. The cell content itself
should be drawn by the calling application, so I am looking
for a fast way to pass something like a viewport of the
picturebox in a control_cellpaint event. If I pass the
picturebox itself the app can overwrite the whole
picturebox, if I pass a separate bitmap and copy this one
back into the grid's bitmap this would probably take too
much time if a full screen grid with hundreds of cells has
to be repainted.

Is there another way to pass a drawing destination like a
picturebox and a rectangle where the host app is limited to
draw in?
Schmidt - 02 Jun 2008 12:14 GMT
> I'm writing a grid control which does the main work to draw
> the grid lines into a picturebox and handles cursor
[quoted text clipped - 11 lines]
> picturebox and a rectangle where the host app is limited to
> draw in?

Why not pass the hDC of the PictureBox?
To avoid possible Overdrawing of already painted
areas, you could wrap your Event with these Calls:

IntersectClipRect PicBox.hDC, ..., ...
   RaiseEvent OwnerDrawnCell PicBox.hDC, x, y, dx, dy
SelectClipRgn PicBox.hdc, 0

Olaf
Boris Danner - 02 Jun 2008 17:50 GMT
> Why not pass the hDC of the PictureBox?
> To avoid possible Overdrawing of already painted
[quoted text clipped - 3 lines]
>    RaiseEvent OwnerDrawnCell PicBox.hDC, x, y, dx, dy
> SelectClipRgn PicBox.hdc, 0

I'm not familiar with these two API calls, but if
IntersectClipRect defines a rectangle where the next
drawings are limited to take place (and SelectClipRgn sets
it back to the complete PicBox area), why should the region
described once more in the event parameters? I want exactly
to avoid this, else I could simply pass the PicBox itself
with x,y,dx,dy and trust that the calling app would be so
kind to draw only inside the rectangle.
newsreader - 02 Jun 2008 21:17 GMT
Try the links in:    www.vb32.com

>> Why not pass the hDC of the PictureBox?
>> To avoid possible Overdrawing of already painted
[quoted text clipped - 11 lines]
> trust that the calling app would be so kind to draw only inside the
> rectangle.
Schmidt - 03 Jun 2008 03:57 GMT
> > Why not pass the hDC of the PictureBox?
> > To avoid possible Overdrawing of already painted
[quoted text clipped - 12 lines]
> with x,y,dx,dy and trust that the calling app would be so
> kind to draw only inside the rectangle.

Hmm, maybe you are after SetViewPortOrg then,
if you want to let the client-app draw with relative
cell-coords.
But setting such an overdraw-limitation, (which clips
any drawn user-content to the current cell) is not a
bad "protection"-idea - since the user could use *any*
GDI-Call, even if the call itself does *not* support
separate clipping-rects in its params as e.g. ExtTextOut.

Your choice.

Olaf
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.