Event PasteDragDrop problem with files from compressed files

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by Paul Hasselfeldt
Version: 4.0.0283
Platform: .NET 3.5
Environment: Windows 7 (64-bit)
Avatar
Using the Drag and Drop QuickStart...

When dragging a file from windows explorer from within a zipped file the function call e.DataObject.GetDataPresent(DataFormats.FileDrop) always returns false.

When dragging files from an application like WinRAR that function succeeds, however the function e.DataObject.GetData(DataFormats.FileDrop) always returns an object that is null.

Thanks in advance for your help.

Comments (3)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Paul,

1) This question is probably better asked in a Microsoft forum since it is Windows that is populating the data object. Perhaps they pass another data format you can look for. But again that is better asked in the Microsoft general .NET forum.

2) Apps like WinRAR decide what data formats they support in drag/drop too, so your second question would be better asked to the WinRAR creators since we have no control over what they pass.

We use the standard .NET drag/drop mechanisms so you should be able to duplicate these things without our controls.


Actipro Software Support

Posted 14 years ago by Paul Hasselfeldt
Avatar
1) I have confirmed that this issue also occurs in a normal TextBox control drag/drop so I will submit the question to another forum.

2) I don't believe that this is a WinRAR issue because I can successfully implement a standard TextBox control DragDrop and it works. I think this is an issue with the PastDragDrop event not firing with e.Source == PasteDragDropSource.DragDrop.

Place a SyntaxEdeditor control "editor" on a form with the AllowDrop property enabled and the following code associated with the control PasteDragDrop event.

        private void editor_PasteDragDrop(object sender, ActiproSoftware.SyntaxEditor.PasteDragDropEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine(e.Source.ToString());
            if (e.Source == PasteDragDropSource.DragEnter)
            {
                if (e.DataObject.GetDataPresent(DataFormats.FileDrop))
                    e.DragEventArgs.Effect = DragDropEffects.All;
            }
            else if (e.Source == PasteDragDropSource.DragDrop)
            {
                object files = e.DataObject.GetData(DataFormats.FileDrop);
                if (files != null && (files is string[]) && (((string[])files).Length > 0))
                {
                    string filename = ((string[])files)[0];
                    editor.Text = filename;
                }
            }
        }
The "else if" statement never fires even though, on the DragEnter, the code reaches the line to set the "Effect".


However if you place a standard TextBox control "textBox1" on a form with the AllowDrop property enabled and the DragEnter and DragDrop events configured with the following

        private void textBox1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
                e.Effect = DragDropEffects.All;
        }

        private void textBox1_DragDrop(object sender, DragEventArgs e)
        {
            object files = e.Data.GetData(DataFormats.FileDrop);
            if (files != null && (files is string[]) && (((string[])files).Length > 0))
            {
                string filename = ((string[])files)[0];
                textBox1.Text = filename;
            }
        }
The text of the editor is successfully updated to the temporary file name produced in the unzip from WinRAR on drop of the file.

Thanks
-Paul

[Modified at 12/04/2009 05:04 PM]
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Paul,

Check this documentation topic out:
"SyntaxEditor Editing Features / Custom DataObject Support"

Specifically look at the Text property notes of the event args. It must be set to a non-null value in DragEnter if you want to allow drags of custom objects to continue. I think that is what you are missing.


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.