(VB6)  Making drag and drop less sensitive

Posted on 2003-03-27
Medium Priority
Last Modified: 2008-11-29

I have an application which has a treeview and a file list box on it.  I have enabled OLE drag and drop between the two so I can move files around in the box, and drag folders willy nilly from place to place, thereby rearranging the collection of folders displayed.

My problem is that my drag and drop operations are extremely sensitive, sometimes to the point that when I click on a folder name, if my mouse continues to move past the folder I've just selected, it assumes I've started a drag operation, when that wasn't what I meant to do.

What I'd like is a way to pause the code that checks the mouse button state for about a half a second before it performs the check on the mouse button state.

It seems to me that there's a pause command I can insert into the code, but I can't seem to find it documented anywhere, and I'm probably having a brain cramp.  But my cramp is worth 50 points, so comment away.

Question by:Jzaltheral
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Accepted Solution

SilentRage earned 200 total points
ID: 8221841
no way dude, that's not the best plan.  I've had the same problem as you, and found this other solution.  First of all, you gotta make your drag and drop operation manual.  Then in your MouseDown event, save the X,Y in the tag of the control you're dragging.  Then, in the MouseMove event, check to make sure button = 1 and that you have a TAG value.  Extract the XY from the tag and compare it to the current XY.  If you have moved away from the original spot by 10 pixels or so, Start dragging.  Otherwise, dont' start dragging.

The result is that when you press the left mouse button over teh control - it won't drag until you actually move your mouse away from the original spot you clicked down on.

If you need example code just ask.  :)

Author Comment

ID: 8222217
Actually my problem is exactly the oppisite.  I want to NOT drag an item just because I moved the mouse a bit when I was trying to select an item (I'm a notoriously sloppy clicker, especially with my trackball) and when I select an item, the app starts dragging when I didn't mean it to.


Expert Comment

ID: 8225013
that's what I'm saying.  Don't make the slip amount only a little.  If you want, you can make it not start OLE drag until you mouse drag like 100 pixels away from the original mouse down point.

Author Comment

ID: 8226678
Ok...now I think I see what you're saying. At first blush, I didn't quite understand what you were getting at. Let me give that a try tonight when I get home for work.  I'll definately post here how it goes and if it works.


Author Comment

ID: 8232540

Good suggestion - that seems to be working the way I wanted much better now.  It's going to take some tweaking to get it exactly the way I want it, but you earned the points.

Thanks for the assistance.


Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question