|
-
Jan 3rd, 2002, 09:26 AM
#1
Thread Starter
Frenzied Member
Moving Command Buttons
Hi,
Is there a way to allow the user to move a command button around in a picture box for example. (or a form)?
-
Jan 3rd, 2002, 09:42 AM
#2
how about setting a right click popup menu to the button..then if they pick "move" from the menu... allow then to click another spot on the form..and set the top / left
or check for a special keycombo... like if they hold SHIFT and click and hold the button...allow a drag/drop.
but..in a nutshell, YES you can let the user move the button
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jan 3rd, 2002, 09:42 AM
#3
Sure, but be specific about what you want. Do u want the user to b able to drag it? Do you want it to move automatically?
-
Jan 3rd, 2002, 09:43 AM
#4
The Girraffes are coming...run for your haggises
Like this you mean:
VB Code:
Option Explicit
Dim intLeftGap As Integer
Dim intTopGap As Integer
Private Sub Command1_Click()
Load Form2
Form2.Show vbModal, Me
End Sub
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
intLeftGap = X
intTopGap = Y
End If
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
Command1.Left = X + Command1.Left - intLeftGap
Command1.Top = Y + Command1.Top - intTopGap
End If
End Sub
-
Jan 3rd, 2002, 09:52 AM
#5
Thread Starter
Frenzied Member
Thanks WokaWidget, that's exactly what I needed. I don't care about the Click event because the user will be only allowed to move the buttons around a picture box.
-
Jan 3rd, 2002, 09:52 AM
#6
ok here...
change the Drag mode of the command button to automatic
then in the Dragdrop event of the form.
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Source.Left = X
Source.Top = Y
End Sub
thats it
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jan 3rd, 2002, 09:54 AM
#7
Thread Starter
Frenzied Member
thanks geoff_xrx. However, the button will be placed according to the mouse_cursors's x and y properties as oppose to the buttons.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|