X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
> Drag And Drop Files (feedme), Any Version    
post Sep 15 2011, 12:19 PM

UtterAccess Editor
Posts: 9,934
Joined: 7-December 09
From: Staten Island, NY, USA

There's two demos here. The FeedMe demo is additional functionality to the DragDrop stuff. The DragDrop has the real work in it. The GUI class is required for the FeedMe functoinality. The latest version at the time of this post is included in the FeedMe demo.
This demo shows how to implement dragging and dropping of files from windows explorer into your application.
Included in the zip file is a complete documentation of the DragDrop functionality, starting with simple usage and covering most aspects that the average user might come across.
I've seen two demos of this before: one which utilizes a subform as the "drop area", and one that does not. Myself and at least one other (thanks Alan) experienced problems when attempting to use the drag/drop API functionality in a standalone form: the only way to successfully implement it with the few examples to be found is to setup the drop area as a subform.
The problem is with a callback function from the API that clogs up the VBA project. The callback function required for drog/dropping has to process every system message sent to the window we're using. In the other demos I looked at, hook into the callback is placed when the form is opened and removed when the form is closed. This means that throughout the life of the (standalone) form, that callback is running rather madly: so much that better than 90% of the time it was crashing Access.
When used in a subform, and the hook is placed at the open of the subform and removed at the close of the subform, the behavior is much better. For whatever reason, subform window callbacks do not seem to run unless the mouse is placed over the subform. The general result is a satisfactory implementation of drop/dropping: the subform callbacks are not enough to crash Access. Just don't open the subform as a standalone form, unless you want to crash Access.
When I initially set out to use drag/srop functionality, it was intended to drop a file into a textbox that would enter said file into the system. At the time, I wasn't aware of the subform implementation, and set out to find a way to keep Access from crashing. The solution I came to, the one posted here, works to drop files into a specified control on a standalone form.
The means I used to obtain this was to remove the hooking from the form's open/unload events, and instead have the hook only active while the cursor is over the control that takes the file. This works well as a standalone form implementation, but there is one minor quirk:
The form, either standalone or sub, needs to be registered to accept drag/dropped files. When this form is registered, dragging files anywhere over the form results in the cursor changing from the standard pointer to the dragging icon. This is misleading in the standalone/control implementation as it more or less tells the user that they can drop the files anywhere on the form, but in fact they can only drop them into the control. I cannot think of any workaround to this, but you may or may not view it as a dealbreaker.
In retrospect, using the subform implementation with a sub just large enough to enclose the required control may be a preferable method of handling it: then the user will only see the drag/drop icon in a valid drop area, though loading a subform, depending on how many, will add considerably to the form's load time.
One major advantage to using the MouseOver event to hook into the callback rather than a form's open/close (or load/unload) is that we can now implement drag/drop capabilities one more than one open form at a time. Because the callback needs to be in a standard module, it becomes quite difficult to maintain instancing directives on it. While the message callback does utilizes the form's Handle, I don't know that I'd trust it enough to have two subforms open at once and have the function continuously running and able to keep everything sorted. Using the MouseOver of a control (or the Detail section of a subform) ensures that the callback only has to handle one window at a time.
DragDrop FeedMe
The DragDrop FeedMe demo contains the same drag/drop code as the DragDropAPI demo, but this one has functionality that hides the Access window and pops up a small form so the user can drag files into it without having to work around the Access app or resize it to get files:
The V2 FeedMe includes a class module and demo for it to select a variety of different settings and options. The GUI and modDragDrop modules are required and included in the demo. I haven't done much for documentation on it yet, but there's not really a lot to document on it. The class provides properties and one method, set them as desired, and that's about it.
V2 Demo Snapshot:
Attached File  FeedMe_SS.gif ( 90.88K )Number of downloads: 1168


(please see this post for a minor bug fix where previous files aren't properly cleared - thanks Detire!)
Attached File  DragDrop_v1.0.1_Documentation__Revision_0_.pdf ( 70.01K )Number of downloads: 811
Attached File  DragDrop_v1.0.1.zip ( 132.21K )Number of downloads: 912

Attached File  DragDrop_FeedMe_v2.0.zip ( 96.11K )Number of downloads: 788
Attached File  DragDrop_FeedME_v2.0_Acc2010_32___64bit.zip ( 209.52K )Number of downloads: 752

Older versions:
Attached File  DragDropAPI.zip ( 49.43K )Number of downloads: 382
Attached File  DragDrop_FeedMe.zip ( 33.74K )Number of downloads: 323

Revisions of DragDrop:
'V1.0.1 2011-09-29
'  Modifications from original:
'    - Added link resolution
'    - Added DragDropRemoveDuplicates()
'  Known Bugs
'    - Link resolution doesn't seem to work on
'      some .lnk files.
'      You can modify pfGetShortcutTargets to
'      turn off shortcut target resolution and
'      always return .lnk or .URL files.
Go to the top of the page

Posts in this topic

Custom Search
RSSSearch   Top   Lo-Fi    19th October 2018 - 06:03 AM