Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This is easily the most helpful website I've ever used, and this is the best forum with the quickest response time bar none...."

Geography

Where in the world do Tek-Tips members come from?
stanlyn (Programmer)
7 May 12 17:53
Hi,  

Using VFP9sp2, I need some pointers on the layout of a drag & drop VFP application.

The application is an "Accounts Payables" module that contains images of invoices.  The images will be scanned into an "InTray" which would contain invoices for multiple vendors.  I plan to use a "seperator" page to indicate all the pages that pertains to a single multi-page invoice during the scanning process.  At this point they have not been assigned to any AP record.

I want to drag those images into its related vendor treeview folder node, while renamng the image and creating the AP record all in the same drop process.

Another option I'd like to do is... lets say that the left side of the form contains the data for an invoice such as InvDate, amount, and terms, as well as an drop area that would receive the images dragged in from the InTray.  What vfp object would I use for the drop area.  Also note that this all needs to be done inside the vfp app, and not from explorer.

I've been playing around with the OLE drag & drop pems a bit.

Anyone done this sort of stuff before?

Also note that this destined to SQL server a little later on...

Any ideas, suggestions are highly encouraged.

Thanks, Stanley
clipper01 (Programmer)
7 May 12 18:55
if u are ready to spend about 150usd , the shell megapack from http://www.ssware.com/ is superb ,loads of VFP examples , have used it in lots of projects
stanlyn (Programmer)
7 May 12 23:46
Hi clipper01,

Looks good, however I don't see any vfp examples...

I've spent the last 30 minutes trying to tie together the folder and file viewers together with no luck.  I've tried:

thisform.FolderV.FileView = thisform.FileV.WindowHandle
thisform.FolderV.FileView = thisform.FileV.Name
thisform.FolderV.FileView = thisform.FileV

Any idea?
 
OlafDoschke (Programmer)
8 May 12 1:43
There are OLE and native drag & drop samples in the foxpro samples. One way to go there is Task Pane -> Solution Samples

search for drag.

Try "Fun with OLE drag&drop" and especially the the editbox with the caption "Drop Files here from Windows Explorer".

Look at the source code of that sample form by clicking on the icon at the right side of the Task Pane/Solution Samples search result entry.

You talk of dragging from an "InTray". Well, what is it? Some source control embedded in UI of your scanner program showing the latest image scans, or just some specific folder with image files?

Bye, Olaf.
MikeLewis (Programmer)
8 May 12 3:30
Stanley,

What you are describing is definitely possible, but your question is a bit too general.

If you have no idea where to start with drag-and-drop, you should read the Help topics first. There's plenty of information there, as well as in the samples that come with VFP.

If you have already tried doing drag-and-drop but have got stuck, let us know what specific difficulties you are having.

One initial tip: VFP supports two systems for drag-and-drop. The one that you should focus on is called OLE Drag and Drop (the other is "native" drag and drop, which is very limited, and does not support dropping outside the original container).

Also, you asked what control you should use to receive the dragged invoices. Based on what you've told us so far, I'd say a Container control would be appropriate.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 

clipper01 (Programmer)
8 May 12 4:44
Stanley, yr correct , no VFP sample , but the chm help file has all u need ,be glad to send any help.

Here is a "Hello World " example, in a few lines of code , you have a full explorer interface active in yr VFP form

1) create a form and drag a FolderView and Fileview object on
2)*** in the Init of the form
thisform.FolderView.rootfolder="c:\"
thisform.refresh


3) *** FolderView event      OnAfterNodeSelect
LPARAMETERS node
thisform.FileView.currentfolder=this.selectednode.path
thisform.refresh

4) ** sample FileView event     OnItemClick
LPARAMETERS item, x, y
messagebox (upper(this.firstselecteditem.path))


regards Sean M
clipper01 (Programmer)
8 May 12 5:43
follow-up to previous

1) u first added objects called FolderView FileView
2) now add objects FolderView2 , FileView2
3) edit the init and event handlers to do similar  for these
4) now just drag/drop from folder to fileview or folder to folder or fileview to fileview

That I think is more or less what u spec'ed

there may be some way to do what Mike/Olaf are talking about , but I suspect that is just dropping from a regular explorer control which is not what u need ( plus , it seems with ole/vfp to be very problematic to drop anything other than plain text).

If this is going to make a sale of your project , it will be a very cheap spend to buy the shell controls
OlafDoschke (Programmer)
8 May 12 6:20
Stanlyn,

reading your initial post a little closer.

I still don't understand what your drag source is, but you say "this all needs to be done inside the vfp app, and not from explorer".

As of that: If you're still interested in doing drag&drop without a third party add on, Mike is still right in recommending to concentrate on ole drag&drop, as that is supported both for native VFP controls and ActiveX controls you may use as treeview.

You ask what control to use as a drop target, but you say you want the user to drag images to a treeview folder node, then you have your drop target already, don't you?

Another reason to use ole drag&drop with such a treeview, as that must be an ActiveX Treeview, foxpro has no native treeview. Whatever is your vendor folder treeview node can be your drop target. Any VFP control and more so any ActiveX control offers the OleDragDrop methods and properties. You're not limited to anything in that respect.

Sean is right, that the main thing you can easily drag&drop are texts, but with oledrag&drop you can put whatever you like inside the oDataObject parameter. Using a format as "VFP Source Object", this can even be a VFP object, a control reference (eg THIS inside OleDragStart), a form, a record scattered to an object via NAME clause or whatever. And what you put into the oDataobject via oDataObject.SetData() in OleDragStart will be received in OleDragDrop.

Putting in the image file name would be sufficient, wouldn't it? Knowing that in the drop and knowing the node dropped on you know the image, the vendor and you can Move the image file, add a record referencing the moved image file and also display it as a node (depending on the capabilites of the control you use).

Bye, Olaf.
MikeLewis (Programmer)
8 May 12 6:22

Quote:

If this is going to make a sale of your project , it will be a very cheap spend to buy the shell controls

I really don't think Stanley needs to buy any third-party controls. The built-in drag-and-drop is flexible enough to do what he wants - including dropping on a treeview, which is one of his possible requirements.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 

clipper01 (Programmer)
8 May 12 6:31
Hi Mike , Stanley has it seems, downloaded the trial version. Not sure what he bills per day , but this little spend will save a lot of days work , if he wants to implement what he has described, believe me :).  His call , I guess !!
MikeLewis (Programmer)
8 May 12 7:02
Clipper,

Fair enough. Let's see what he says.

Mike
 

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 

OlafDoschke (Programmer)
8 May 12 11:50
clipper,

I certainly agree, that a third party control could amortise fast. Last time I did drag&drop I used oDataObject successfully, using collection objects in it, which by my own definition of my own custom drag&drop protocol had a first item always denoting what kind of data to find, so I could easily decide in the Drop event, whether to accept or deny processing the dragged data, even more so, if there was not one of my self defeined collection objects in the drag data.

This way it was easy to drag&drop different node types in and out of a treeview.

It took me a while, though. I will check, whether the shell megapack controls make that easier. I doubt the drag&drop process itself is done so much differently, even though there certainly is potential even in the plain normal ole drag&drop, strting from as easy as only setting OleDragMode automatic up to as complicated as needing code in most Ole Drag&Drop events.

Controls, which automatically do the things you want from the drag operation are certainly easier to use.

At the point it comes to do things like Stanley wants, it's hardly done with an automatic mode of some control, whioch most probable is DBF unaware:

-drag those images into its related vendor treeview folder node, while renaming the image and creating the AP record all in the same drop process.

You need code in a Drop event to do this, and you need code in dragstart to put the data in you need at the drop event. And that's about all you need to program with ole drag&drop anyway.

The only thing activex controls can deliver on top of that rather is functionality to show somethings as the ideal drag sources or targets for your type of data.

If it's files, actually that could be as easy as a webbrowser control you navigate to a path. It's just beyond me to easily define the look of the webbrowser from detail list to image previews.

Bye, Olaf.
clipper01 (Programmer)
8 May 12 12:23
intersting take , Olaf. U might be interested to download the shell pack , it integrates seamlessly with the VFP form , has a very complete set of events.methods etc. I've used it in lots of projects, paid for itself many times over ( the hello world code I sent to Stanley is a quick kick-off) . Be interested to know your comparison to vfp ole

sean m
stanlyn (Programmer)
8 May 12 12:31
Hi Olaf,

>> You talk of dragging from an "InTray". Well, what is it? Some source control embedded in UI of your scanner program showing the latest image scans, or just some specific folder with image files?

The InTray most likely will be a folder on the OS, unless someone presents a better way...  Just remember that I'm in the exploration phase of this project, looking for all the options and the difficulty of implementing each.  These brain storming sessions, followed by my researching them will help narrow the spec...

So brain storm away,
Stanley
stanlyn (Programmer)
8 May 12 12:42
Hi Mike,

> What you are describing is definitely possible, but your question is a bit too general.

Mike, its general because I'm fishing on ideas on hoe to implement this...

 
I have played around with the OLE version and can see this as part of the solution.

> Also, you asked what control you should use to receive the dragged invoices. Based on what you've told us so far, I'd say a Container control would be appropriate.

OK, Olaf's reference to the solutions samples refers to an editbox.  So far, I've not looked at it, but would assume that either would work.  I'm actually wondering what PEMs would be involved on the container or editbox that recieved the dragged images.?  Please explain...  The answer may be in the solution samples that I haven't got to yet.

Thanks, Stanley   
stanlyn (Programmer)
8 May 12 12:49
Hi Sean,

> Here is a "Hello World " example, in a few lines of code , you have a full explorer interface active in yr VFP form.

Yes, I've gotten that far and it does seem easy enough with plenty of PEMS.  BTW, I was unable to get the 3rd component "shcombobox" to work.  What does it do and is it important?

And, what property contains the currently selected node?

Thanks,
Stanley  
stanlyn (Programmer)
8 May 12 12:52
To All,

> it seems with ole/vfp to be very problematic to drop anything other than plain text).

Is this true?

Thanks, Stanley

 
stanlyn (Programmer)
8 May 12 13:02
Hi Sean,

> Not sure what he bills per day , but this little spend will save a lot of days work , if he wants to implement what he has described, believe me :).  His call , I guess !!

Purchasing the 3rd party controls is NOT a problem, and this one actually is very usefully in other areas as well, plus no royalties...

I will be purchasing this at the end of the trial, so we can count this as in our toolkit for this project if needed...

Thanks, Stanley
 
clipper01 (Programmer)
8 May 12 13:07
stanley ,

the currently selected node is got from the folderview selectedNode object. This returns a TreeNode object , this is where u manipulate anything u want. Go to the CHM help file and look up the TreeNode reference.  

So the path to current node is folderView.SelectedNode.Path

I've not used the combobox control, it's  mainly a drive-selection dialog , but u have that anyhow in the folder control

 
stanlyn (Programmer)
8 May 12 13:18
Hi Olaf,

> At the point it comes to do things like Stanley wants, it's hardly done with an automatic mode of some control, whioch most probable is DBF unaware:

> -drag those images into its related vendor treeview folder node, while renaming the image and creating the AP record all in the same drop process.

> You need code in a Drop event to do this, and you need code in dragstart to put the data in you need at the drop event. And that's about all you need to program with ole drag&drop anyway.

Yes, that sums it up what I was thinking, and thanks for the clarity.  However, at this point, I may be overlooking something by not having my spec correct.  By encouraging any and all ideas on creating a stunning intutive interface for this AP app, I hope to settle on a "well thought out" spec.  So please, lets continue talking.

Thanks, Stanley
stanlyn (Programmer)
8 May 12 13:24
Sean,

>it integrates seamlessly with the VFP form , has a very complete set of events.methods etc.

Yes, I'm impressed so far, at least from an explorer point of view, as that is why I've decided to buy.  

I'm sure that any of the needed vfp code would run nicely in its pems.  Correct??

Thanks, Stanley
stanlyn (Programmer)
8 May 12 13:34
Sean,

When I try......

thisform.text1.Value = thisform.foldV.SelectedNode.Path
thisform.text1.refresh

it is displaying the previously selected node's name.  Its always one node behind, unless you click it twice to change its name.  In that case it is correct even without changing the name.

I'm expecting the textbox to display the name of the selected treeview node.  

Any idea?  
stanlyn (Programmer)
8 May 12 13:36
Sean,

I have the code above in the foldV's click event...

Stanley
 
stanlyn (Programmer)
8 May 12 13:45
Sean,

And what is the property that contains the name of the selected filename in the FileView control in both
1. single selected file mode, and
2. multi-selected file mode?

thisform.text1.value=?????

How would multi-selected files be referenced and processed in the drop event?  

Thanks, Stanley

 



 
clipper01 (Programmer)
8 May 12 14:11
Stanley , the help CHM file is stuffed with examples of " How do I do this/that/other"  . The sample code is VB but is easy to convert to vfp , see below. So , go to Help , Developers guide and dig in ... best way to learn it .

e.g. to enumerate through multi-selected files ...

Dim x As FileViewControl.ListItem
Set x = FileView1.FirstSelectedItem
While x Is Nothing = False
Debug.Print x.DisplayName
Set x = FileView1.NextSelectedItem
Wend


 
clipper01 (Programmer)
8 May 12 18:23
Stanley , one final item ... ideally you would probably like to drag MULTIPLE items from Inbox to Target. You can do that , but it will be very tricky to do " some kind of processing " with each of the individual items. As second best , you can disallow multiple items drag from the Inbox ( set AllowMultipleSelection property to false, drag single items ,  and use the OnAfterItemAdd event of the Target folder , to do any of the code to rename ,add to AP tables etc. Should do the biz , I think
TamarGranor (Programmer)
9 May 12 16:28

Quote:


> it seems with ole/vfp to be very problematic to drop anything other than plain text).

Is this true?

I've done it, and the hard part is understanding how the pieces fit together. Once you get it, it's not bad.

I know I've written about this, but I can't figure where other than in the Hacker's Guide. (I'm sure I wrote a more detailed piece.)

Tamar

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close