By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,965 Members | 1,136 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,965 IT Pros & Developers. It's quick & easy.

Drag and drop

P: 36
Hi

I have a box which I click to activate and then move around and click again to release it, works fine but I want to have drag and drop and the issue I have is when I press the button the on click event doesn't fire until I release it.

So my question is how do I know that the left mouse button was pressed within the box.

Many thanks
Emil
May 24 '09 #1
Share this Question
Share on Google+
8 Replies


ADezii
Expert 5K+
P: 8,679
@IT Couple
  1. Set the backStyle Property of the Box = Normal.
  2. Copy and Paste the following code with the proper Box Name to the MouseDown() Event of the Box. The Button Parameter indicates which Mouse Button was pressed.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Box16_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2. Select Case Button
    3.   Case acLeftButton
    4.     MsgBox "Left Mouse Button Pressed"
    5.   Case acRightButton
    6.     MsgBox "Right Mouse Button Pressed"
    7.   Case Else
    8.     'who cares
    9. End Select
    10. End Sub
  3. P.S. - The MouseDown() Event is fired prior to the Click() Event of the Box.
May 24 '09 #2

FishVal
Expert 2.5K+
P: 2,653
Emil,

just out of curiosity, how are you going to detect "Drop" this way?

Regards,
Fish.
May 25 '09 #3

NeoPa
Expert Mod 15k+
P: 31,709
@IT Couple
What type of control is this box?

Can you confirm you want to be able to treat this box like a standard window and drag&drop it anywhere within your form?
May 25 '09 #4

NeoPa
Expert Mod 15k+
P: 31,709
As a basic concept, I'd consider a timer routine which repaints the current position of the box every interval. This would be triggered by the MouseDown() event, and terminated by the Click() event.

Is this something you would feel comfortable with?
May 25 '09 #5

ADezii
Expert 5K+
P: 8,679
@NeoPa
I assumed, perhaps incorrectly, that a Box Control is the Rectangle in the Access Toolbox. When you create this Control on a Form, the Name assigned to the Control is always BoxXX.
May 25 '09 #6

P: 36
Hi

Thanks for the reply it will work for me perfectly

Regarding the questions... it currently is a rectangle box and to detect drop I will just use on click as it occures when the mouse button is released ;) I don't use time as I just use X, Y and mouse move to move the box.

Regards
Emil
May 25 '09 #7

FishVal
Expert 2.5K+
P: 2,653
@IT Couple
No problema, Emil.

I just didn't read your question carefully and assumed you mean dragging some data from one control to another.

Regards,
Fish.
May 25 '09 #8

P: 36
Hi Fish,

Yes later on I will grab certain data (presumelly use a different control) and once released on a scheduler calendar it will populate the data in the database, but that's phase 2 ;)

Regards
Emil
May 25 '09 #9

Post your reply

Sign in to post your reply or Sign up for a free account.