I thought this would be simple, but I was oh so wrong :0)
All I wanted to do was create about 30 labels on a form and code these
labels so that at run time I could move them around to get the right
positions on a form (actually inside a picture box) and then a text box
would give me the exact top, left (and width if it can be resized) of what
I've just set.
I can't even get the bloody label to move. I see the drag box, but when I
let go the label hasn't moved from it's original location!!
Is it possible??
Thanks
OK - this is pretty easy,
Set the DragMode of the label controls to Automatic ( 1)
and then trap the DragOver event in the picturebox.
Here you can update the textboxes with the label positions,
and also adjust the position of the label to move it.
Here is some sample code:
Sub Form_Load()
Label1.DragMode = 1
End Sub
Sub Picture1_DragOver( _
Source As Control, _
X As Single, Y As Single, _
State As Integer)
Text1.Text = Source.Left
Text2.Text = Source.Top
Source.Left = X
Source.Top = Y
End Sub
Or if you prefer you can capture the MouseMove event for the label
controls and move the labels there
I think this should meet your needs, but if you are looking for
something more - want to make this look smoother, add in resizing,
allow dragging shapes and images, support large scrollable / zoomable
canvas, support saving the layout to an image, printing it, etc, then
you might also want to look at our MetaDraw component
( www.MetaDraw.com). But for just simple need that you have of
dragging labels and getting the position, using the sample code above
should be enough.
Jeff Bennett,
* Bennet-Tec Information Systems, Inc
* www.Bennet-Tec.Com
RELIABLE Component Software
and Custom Software Development Services
TList™ / ALLText™ / MetaDraw™ / Web Signature™
=================================================
You will need to handle the mousedown/move/up events and move it yourself.
Or make it a picturebox (or similar) and use:
http://hashvb.earlsoft.co.uk/Dragging_windows
--
Dee Earley (dee.e...@icode.co.uk)
i-Catcher Development Team
iCode Systems