[AccessD] A2K: Drag and Drop with Access

Stuart McLachlan stuart at lexacorp.com.pg
Mon Jun 9 20:55:39 CDT 2003


On 10 Jun 2003 at 9:45, Darren DICK wrote:

> Hi Arthur
> What I wanted was simply some of the functionality we get on screen when we go into design view for a form.
> In design view click on an object - Text Box, label, combo box, image control, whatever and you get the resize 
> handles. Grab the top left handle and you can move the whole control and get a shadow/ghost image of the 
> control as the cursor. Let go the mouse button and viola the control has been 'dragged and dropped'
> 
> I wanted something like that. It's for an ID card design app. User drags say...LastName control to bottom of card 
> design area. Same for FirstName controls but this time to the top and same for Image control but to the far right.
> 
> Simple:-) <VVBG>
> 
I
f all you wnat to do is move the control around withint the form, 
this will do let you do a Ctrl+LeftButton and drag the control 
around. ( It only moves Text0 - youi'll need to duplicate it for each 
control that you want to move or write a more generic routine, but 
this should give you the general idea):

Private movingText0 As Boolean

Private Sub Text0_MouseDown(Button As Integer, Shift As Integer, X As 
Single, Y As Single)
If Shift = acCtrlMask And Button = acLeftButton Then
    movingText0 = True
End If
End Sub

Private Sub Text0_MouseMove(Button As Integer, Shift As Integer, X As 
Single, Y As Single)
Dim NewX As Long
Dim NewY As Long
If moving Then
  NewX = Text0.Left + X
  NewY = Text0.Top + Y
  If NewX > 0 And NewX + Text0.Width < Me.Width Then
        Text0.Left = NewX
  End If
  If NewY + Y > 0 And NewY + Text0.Height < Me.Detail.Height Then
        Text0.Top = NewY
  End If
End If
End Sub

Private Sub text0_MouseUp(Button As Integer, Shift As Integer, X As 
Single, Y As Single)
If Shift = acCtrlMask And Button = acLeftButton Then
    movingText0 = False
End If
End Sub

-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System 
Support.





More information about the AccessD mailing list