Sky Software Homepage LogicNP Software Knowledge Base And FAQ

 
Contact Product Support    SearchSearch      Subscribe to the RSS feed for this forum

HOWTO: Prevent certain files from being dropped in FolderView

 
Subscribe to the RSS feed for this forum  Forum Index -> FolderView ActiveX Control
View previous topic :: View next topic  
Author Message
Support



Joined: 18 Jul 2005
Posts: 731

Posted: Fri Apr 24, 2009 11:33 am    Post subject: HOWTO: Prevent certain files from being dropped in FolderView

To prevent certain files from being dropped in FolderView, use the following code in the OnOleDragOver event:
[C++]
Code:
void CFdrViewVCDlg::OnOnOleDragOverFolderviewctrl1(LPDISPATCH Data, long FAR* effect, long Button, long Shift, long x, long y, long State, LPDISPATCH Node)
{
// exit if no data
if (Data==NULL)
  return;

CFOVDataObject data;
data.AttachDispatch(Data,FALSE);

// retrieve files being dragged
VARIANT  var = data.GetFiles();
SAFEARRAY* arr = var.parray ;

BSTR* draggedFiles;
SafeArrayAccessData(arr,(void**)&draggedFiles);

// get first file in array
CString draggedFile = draggedFiles[0];

// convert to lowercase for comparison
draggedFile.MakeLower();

// if files is from "c:\" drive, dont allow it to be dropped
if(draggedFile.Find("c:\\",0) != -1)
{
  *effect = FOVDragDropNone ;
}

SafeArrayUnaccessData(arr);
VariantClear(&var); 
}


[VB6]
Code:
Private Sub fldrVw_OnOleDragOver(ByVal Data As FolderViewControl.IFOVDataObject, effect As FolderViewControl.FOVDragDropEffects, ByVal Button As FolderViewControl.FOVMouseButtons, ByVal Shift As FolderViewControl.FOVKeys, ByVal x As Long, ByVal y As Long, ByVal State As Long, ByVal Node As FolderViewControl.ITreeNode)

' exit if no data
If Data Is Nothing = True Then Exit Sub

' retrieve files being dragged
Dim draggedFiles() As String
draggedFiles = Data.Files

' get first file in array
Dim firstfile As String
firstfile = draggedFiles(0)

' convert to lowercase for comparison
firstfile = LCase(firstfile)

' if files is from "c:\" drive, dont allow it to be dropped
If Mid(firstfile, 1, 3) = "c:\" Then
effect = FOVDragDropNone
End If

End Sub
Back to top
Display posts from previous:   
Forum Index -> FolderView ActiveX Control All times are GMT
Page 1 of 1

 
Jump to:  


Powered by phpBB © 2001, 2005 phpBB Group