Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

transparant Rectangle shape with borders

Status
Not open for further replies.

safra

Technical User
Jan 24, 2001
319
NL
Hi,

I need a 'draggable' rectangle shape that is transparant and only shows borders. The dragging part will be controlled by the mouse position.

I am not sure which component to use. my first thought was a rectangle TShape but I can't get figure out how to make it transparant and, besides that, I can't get it to show on top of the form. It is always displayed below for example a DBGrid, even when I select 'Bring to front' form the right-click menu.

What should I use for this?

Thanks,
Raoul
 
It is fairly easy to create a draggable rectangle using the Canvas.Rectangle procedure.

Why do you need to create a rectangle on top of a DBGrid?

Andrew
 
Thanks Andrew, I will look at that.

What I am trying to do is make the DBGrid 'dynamic' and add an table update option that is executed upon an a click and drag action. The user clicks on a row then the rectangle shape should appear to highlight the selected row. When user moves the mouse upwards/downwards over the grid, the rectangle should follow the mouse movement. Upon MouseUp the rectangle should disappear.

My first thought was that I need some sort of rectangle shape to create the visual effect but I am only into delphi for 2 weeks or so. Perhaps there is an easier and more common way to do this?

Raoul
 
I imagine that using the dbgrid itself (look on for custom components ) would be easier than what you're trying now.

If you do want to use TShape, set the brush.style:=bsclear (you can do it in the object inspector). We do this in a lot of places, but we aren't trying to do it on top of a grid.

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Thanks Brian, in the mean time I did figure out how to make the tshape transparant (the way you suggested) but I still can't figure out how to place it on top of all other components. No matter which component it overlaps it is always positioned below other components?

I looked for a custom dbgrid component that does what I need but have not found it so far.

I also looked at canvas.rectangle and tried some things but the rectangle just does not appear on the form?

Form1.Canvas.Pen.Color := clblue;
Form1.Canvas.Rectangle(50,50,200,20);

I have this in the FormShow procedure. Nothing there??

Raoul


 
You appear to be correct. I am able to draw on a TImage placed on the form, but I can't bring it in front of a grid.

I can't seem to draw a rectangle on the form.canvas either.

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Hum, and what about the tshape? Can you figure out how to place this on top of the dbgrid?

If not, are there any other options I have to create the highlight effect on DBgrid rows?

Thanks,
Raoul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top