On Dec 31, 2006, at 3:44 PM, Wade Maxfield wrote:
2. How can I move a listbox (or any other control) at runtime by
allowing
the user to click and drag the control?
Add two properties to the containing window or a subclass of the
listbox:
MouseDownX as integer
MouseDownY as integer
In the listbox's MouseDown event put:
MouseDownX = X
MouseDownY = Y
Return true
In the listbox's MouseDrag event put:
me.Left = me.Left + (X - self.MouseDownX)
me.Top = me.Top + (Y - self.MouseDownY)
In the case of ListBox, above, you have a MouseDrag event to work
with, as shown. For other controls that don't have a MouseDrag event,
one approach is to lay on a Canvas control and drag it using the code
above in the Canvas's MouseDown and MouseDrag events, with code added
in MouseDrag to move the control along with it, for example:
PushButton1.Left = me.Left
PushButton2.Top = me.Top
A Canvas also facilitates drawing selection handles if you wish to do
so.
Best,
Jack
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>