Moveable graphic objects

  • Thread starter Thread starter Ulf Hansen
  • Start date Start date
U

Ulf Hansen

Hi!

I wonder if anybody here can advise me in creating moveable graphic objects
in an Access form (objects which can be moved in form view, not in design
view). And when you move the object with the mouse, it will be "snapped" to
an underlying field in the form, and you can move the object(s) to other
fields in the same form. The fields in the form are bound to fields in a
table, so when the object is moved, the underlying table will be updated.

Is this possible?

TIA
Ulf Hansen
 
Hmmm. I have done this but no longer have the code available. So if nobody
comes up with anything more concrete... the way that I did it was....

A form level boolean variable identifying whether a control can move.
MouseUp and MouseDown on the control toggle that switch on or off.
The MouseMove event of the form moves the control to a position specified by
the event parameters if the boolean variable is set to allow it.

Hopefully I've remembered that right. I remember having some issues
translating the X & Y parameters of MouseMove into the correct position, and
the control that I was moving was just a rectangle - not sure if you're
going to have other problems working with text boxes. And I didn't do any
'snapping' so you're on your own there.

Good luck.
 
Thought I'd have a quick play to see what I could come up with... and this
works at a basic level.... just a form with a single rectangle control
called recBox.

Option Compare Database
Public AllowMove As Boolean

Private Sub Form_Load()
AllowMove = False
End Sub

Private Sub recBox_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
AllowMove = True
End Sub

Private Sub recBox_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If AllowMove Then
Me.recBox.Left = X + Me.recBox.Left
Me.recBox.Top = Y + Me.recBox.Top
End If
End Sub

Private Sub recBox_MouseUp(Button As Integer, Shift As Integer, X As Single,
Y As Single)
AllowMove = False
End Sub

Beats me why you need to add the Left and Top parameters in MouseMove....
but you get something very strange if you don't.
 
Thanks again. I'll try this out.

Ulf

Rob Oldfield said:
Thought I'd have a quick play to see what I could come up with... and this
works at a basic level.... just a form with a single rectangle control
called recBox.

Option Compare Database
Public AllowMove As Boolean

Private Sub Form_Load()
AllowMove = False
End Sub

Private Sub recBox_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
AllowMove = True
End Sub

Private Sub recBox_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If AllowMove Then
Me.recBox.Left = X + Me.recBox.Left
Me.recBox.Top = Y + Me.recBox.Top
End If
End Sub

Private Sub recBox_MouseUp(Button As Integer, Shift As Integer, X As
Single,
Y As Single)
AllowMove = False
End Sub

Beats me why you need to add the Left and Top parameters in MouseMove....
but you get something very strange if you don't.
 
Back
Top