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 FileView

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



Joined: 18 Jul 2005
Posts: 731

Posted: Fri Apr 24, 2009 5:31 am    Post subject: HOWTO: Prevent certain files from being dropped in FileView

To prevent certain files from being dropped in FileView, use the following code in the OnOleDragOver event:
[C++]
Code:
void CFilViewVCDlg::OnOnOleDragOverFileviewctrl1(LPDISPATCH Data, long FAR* effect, long Button, long Shift, float X, float Y, long State, LPDISPATCH Item)
{
 // exit if no data
 if (Data==NULL)
  return;
 
 CFIVDataObject 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 = FIVDragDropNone ;
 }
 
 SafeArrayUnaccessData(arr);
 VariantClear(&var);
}

[VB6]
Code:
Private Sub FileView1_OnOleDragOver(ByVal Data As FileViewControl.IFIVDataObject, effect As FileViewControl.FIVDragDropEffects, ByVal Button As FileViewControl.FIVMouseButtons, ByVal Shift As FileViewControl.FIVKeys, ByVal x As Single, ByVal Y As Single, ByVal State As Long, ByVal Item As FileViewControl.IListItem)

' 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 = FIVDragDropNone
End If

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

 
Jump to:  


Powered by phpBB © 2001, 2005 phpBB Group