tags:

views:

331

answers:

3
+3  A: 

Each clickable tag doesn't necessarily have to be its own control. It just has to be a region that you can detect being clicked.

Suppose you represent each area as a Windows region. You can figure out how wide each one should be based on its text with the TCanvas.TextExtent function. Then create a region with a function like CreateRectRgn. For rounded corners, try CreateRoundRectRgn instead. You can test for mouse events in each region with the PtInRegion function. You can paint borders around them with FrameRgn. The last obstacle is to draw them on the screen so they'll all fit. You're creating the regions and you know their widths, so assign tags to a row until you run out of space, and then start the next line.

Rob Kennedy
thank you for the hint Rob. Do you have any advises if I want these tags to be able be be repositioned via drag and drop?For example, drag the second tag on line 2 and drop on the beginning of line 1.Thank you.
Edwin
Detect mouse-down and enough mouse-move events to differentiate between a drag and a click, and then call `SetCapture` to go into "drag" mode. Handle mouse-move events while waiting for a mouse-up event, at which point you can re-order the tags. (This whole question is an overview question. If you have specific questions about anything, please start a *new* question, where people can respond without having to cover a half-dozen different issues in a single answer.)
Rob Kennedy
+7  A: 

When you are on a recent Delphi version use a TFlowPanel and some appropriate controls for the tags. A simple TButton or a TLinkLabel should do for that.

Uwe Raabe
Thanks Uwe, unfortunately, I use D7. Upgrading is not currently an option.
Edwin
+1  A: 

There are two possible solutions to custom alignment in Delphi 7. You can make your own flowpanel by deriving from TCustomPanel and override the AlignControls( )-method, or you can set alignment to alCustom and handle the OnAlignPosition-event.

I guess I would have gone for the TCustomPanel-derivative option. TFlowPanel in form Delphi 2007 uses that option- I have to admit, though, that I have never tried either my self...

Vegar
thank you for the hint, Vegar :)
Edwin