Drawing rubberband OVER controls 
Author Message
 Drawing rubberband OVER controls

I've tried various ways to draw a {*filter*}band selection box.
My form has lots of controls, images, and so on, and I need
to get the {*filter*}band to show on top of these, around the
screen area selected.  As far as I can see, VB always draws
graphics on the first layer, so the {*filter*}band is never 'on
top'.  Can anyone point me in the right direction?

--
Pieter A. Hintjens



Fri, 31 Oct 1997 03:00:00 GMT  
 Drawing rubberband OVER controls

Hintjens) says:

Quote:

>I've tried various ways to draw a {*filter*}band selection box.
>My form has lots of controls, images, and so on, and I need
>to get the {*filter*}band to show on top of these, around the
>screen area selected.  As far as I can see, VB always draws
>graphics on the first layer, so the {*filter*}band is never 'on
>top'.  Can anyone point me in the right direction?

It can get complex. Firstly, you will want to set ClipControls on the form
to False. This should let you draw over the controls. However, you will then
find that if any control repaints itself, e.g if you press a button, then
any graphics methods on top of the control will be erased. Because a control
repaint involves a child window, you will not be notified via a form paint
event. This means if you want the graphics to be persistent over child
controls, you may need to repaint each time the child control gets clicked
etc.

A related problem then involves form repaints. When you get a form paint
event, you may wish to redraw graphics. However, you will find that the
child windows over which your graphics are drawn may repaint themselves
AFTER the form paint event terminates. Thus, your graphics appear
momentarily and then get erased.

To combat this, you need to walk through your form's controls collection at
the start of a form paint event, and call the Windows API, UpdateWindow, for
each one. (well, each one with an .hWnd property, that is). This will force
the children to process any pending paints immediately. You can now scribble
over them all without them erasing your hard work.

Finally, you may want to redraw only the area of your form that was
invalidated. When a paint occurs, it may be because some other window was
moved over your form's client area. If your graphics methods are extensive
then you may want to optimise speed by only drawing in the invalidated area.
You can use the API function GetClipBox to get the invalidation rectangle
(in pixels) that is relevant for this paint event.

In your case, you may not hit many of these problems if the {*filter*}-band box
or line only has to exist briefly. However, ClipControls is definitely the
key to the problem. There are some other tricks of the trade, such as
exploiting the WS_CLIPCHILDREN and WS_CLIPSIBLINGS window styles, but I
suggest you start here and see how it goes. Best of luck.



Sat, 01 Nov 1997 03:00:00 GMT  
 Drawing rubberband OVER controls

Quote:

> Path:
> I've tried various ways to draw a {*filter*}band selection box.
> My form has lots of controls, images, and so on, and I need
> to get the {*filter*}band to show on top of these, around the
> screen area selected.  As far as I can see, VB always draws
> graphics on the first layer, so the {*filter*}band is never 'on
> top'.  Can anyone point me in the right direction?

> --
> Pieter A. Hintjens

I think you need to look at the PatBlt API. Are you trying to do this
from within a VB program or from within a custom control ?
Steve.


Sat, 01 Nov 1997 03:00:00 GMT  
 Drawing rubberband OVER controls
Pieter,

I've done this sort of thing before.  The best way I found was  to
use the SDK calls in the 'Ellipse and Polygon Functions' section.

There is a Rectangle call which allows you to draw a rectangle object
anywhere on the application.  I used the mouse events in VB to call
this routine with the coordinates of my {*filter*}-band box.  If you take
this approach, you will also need to look at the creating a Brush
and setting it's attributes etc.

Have a look in the online SDK guide with VBpro.

Good Luck,Steve



Sun, 02 Nov 1997 03:00:00 GMT  
 Drawing rubberband OVER controls

Quote:

>  I've tried various ways to draw a {*filter*}band selection box.
>  My form has lots of controls, images, and so on, and I need
>  to get the {*filter*}band to show on top of these, around the
>  screen area selected.  As far as I can see, VB always draws
>  graphics on the first layer, so the {*filter*}band is never 'on
>  top'.  Can anyone point me in the right direction?

First off, I don't know.  BUT!-I have heard about doing it, and you can do it using the Windows API.  I think I
saw it in the MSKB.  Check Ftp.Microsoft.Com.

John Reynolds
================================================
Multimedia Programming

================================================



Fri, 07 Nov 1997 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Rubberband Arc or Rubberband Curve

2. RubberBand UserControls

3. Rubberband Line

4. Rubberband Rectangle in ACCESS-Form via WinApi

5. RubberBand TextBox

6. RubberBand TextBox

7. Rubberband Line with ScrollBar

8. ?! Rubberband always at the background ?!

9. How To? - Draw "rubberband" selection rectangle

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. put drawing object inside another drawing object

 

 
Powered by phpBB® Forum Software