Solved

DataObject

Posted on 1998-07-26
6
769 Views
Last Modified: 2012-06-21
I have a listview control which displays all the files in a selected directory (very much like the Window's Explorer).  I would like to add OLE drag functionality to this control but I am not sure how to do this.  Ideally, I would like to use, in the OLEStartDrag event,  

Data.SetData listview.SelectedItem.Key, vbCFFiles

since each item's key represents the path and name of the files.  However, when I do this I receive an error message or the like.  From the help file, I assume that this has something to do with a bstr variable(?) and the vbCFFiles format.  Since I am new to VB, I am not sure what this is all about and how to specify the vbCFFiles format with the data that I have.  If anyone knows how to do this and solve my OLE drag problem, please let me know.  More points await.

Thanks in advance, showme
0
Comment
Question by:showme
[X]
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
  • 4
6 Comments
 

Author Comment

by:showme
ID: 1466754
Edited text of question
0
 

Author Comment

by:showme
ID: 1466755
Edited text of question
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1466756
Try this:
Data.Files.Add listview.SelectedItem.Key
AllowedEffects = vbDropEffectCopy

0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Author Comment

by:showme
ID: 1466757
Mike,
I tried the code you submitted but I received an error number 5 from the common controls DLL when I started to drag.  Let me know if there is another way.  

Thanks again, showme
0
 
LVL 6

Accepted Solution

by:
anthonyc earned 200 total points
ID: 1466758
here is a small example that works..  Place a listview and a textbox on your form, and set the textbox's OLEDROPMODE to Manual.


Option Explicit

Private Sub Form_Load()
    ListView1.ListItems.Add , "c:\winnt\notepad.exe", "c:\winnt\notepad.exe"
End Sub

Private Sub ListView1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button And vbLeftButton And (Not ListView1.SelectedItem Is Nothing) Then
        ListView1.OLEDrag
    End If
End Sub

Private Sub ListView1_OLEStartDrag(Data As ComctlLib.DataObject, AllowedEffects As Long)
    Data.Files.Add ListView1.SelectedItem.Key
    Data.SetData , vbCFFiles
    AllowedEffects = 3

End Sub

Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
    Text1.Text = Data.Files(1)
End Sub

0
 

Author Comment

by:showme
ID: 1466759
Tried the code and it worked fine.  Thanks, Anthony!  If you have the chance can you explain why your code worked and the other didn't?  Does it have something to do with the line;

Data.SetData , vbCFFiles

Thanks again, showme
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 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