LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Drag and Drop files

Solved!
Go to solution

Hello all,

I have problems with file drag and drop on CVI2015/Win10.

 

First of all, it doesn't work ! I enable EnableDragAndDrop() but then I never receive EVENT_DROPPED in my panel callback. I also tried catching EVENT_DROP without success (what's the difference ?)

 

Also if I call EnableDragAndDrop right after loading the panel, and before doing various resize and property changes on the panel, I get a general protection fault during the resize !

 

Also the documentation is incorrect. It says "Refer to toolbox\msgdemo.cws for an example of using the GetDragAndDropData function." but this project is nowhere to be found.

 

And finally, with GetDragAndDropData(), how do you know the number of files on which to iterate ?

0 Kudos
Message 1 of 3
(3,163 Views)
Solution
Accepted by topic author gdargaud

@gdargaud wrote:

Hello all,

I have problems with file drag and drop on CVI2015/Win10.

 

First of all, it doesn't work ! I enable EnableDragAndDrop() but then I never receive EVENT_DROPPED in my panel callback. I also tried catching EVENT_DROP without success (what's the difference ?)


According to the documentation EVENT_DROP and EVENT_DROPPED apply to splitters, tabs, and trees. You need to catch EVENT_FILESDROPPED for your panel(see EnableDragAndDrop).

 

Also if I call EnableDragAndDrop right after loading the panel, and before doing various resize and property changes on the panel, I get a general protection fault during the resize !

Are you doing the resize/property changes programatically? Can you send the code that causes the GPF?

Also the documentation is incorrect. It says "Refer to toolbox\msgdemo.cws for an example of using the GetDragAndDropData function." but this project is nowhere to be found.

In my installation msgdemo.cws is located in c:\Users\Public\Documents\National Instruments\CVI2015\samples\toolbox. Does clicking on Open example button work? If not you might need to repair your installation.

Open example.png

 

And finally, with GetDragAndDropData(), how do you know the number of files on which to iterate ?

You have to iterate on fileList which is returned in the first parameter until a null pointer. Code snipped extracted from msgdemo example:

int CVICALLBACK MainPanelCB (int panel, int event, void *callbackData,
                             int eventData1, int eventData2)
{
    int   numFiles = 0;
    char* filename;
    char** pfilenames;
    
    switch (event)
        {
        case EVENT_FILESDROPPED:  
            /* Cycle through each file dropped into the panel and display it */
            /* if its a bitmap.                                              */
            GetDragAndDropData (&pfilenames, NULL);
            while ((filename = pfilenames[numFiles]))
                {   
                numFiles++;
                ...
                /* Free the memory for this string */
                free (filename);    
                }
            
            /* Free the memory for the list of strings */
            free (pfilenames);    
            break;
        }

 

 

0 Kudos
Message 2 of 3
(3,138 Views)

Hello Constantin,

msgdemo.cws is not listed in the NI example finder, and it's not in the usual C:\Program Files (x86)\National Instruments\CVI2015\toolslib\toolbox but after a long search I indeed found it in C:\Users\Public\Documents\National Instruments\CVI2015\samples\toolbox. Why isn't it in the Example Finder ? Grrr, I hate Win10.

 

I had found the dragdrop.prj example (also not in NI example finder, but on NI website). It ran fine.

 

My IDE was behaving a bit weird, so it may have been the cause of the crashes when trying it in my own prog. I haven't tried again simply because... it won't compile on Linux and that's where the production software will run. So that's that. I'll look for a Linux solution when I have the time, but it's not a priority for now.

0 Kudos
Message 3 of 3
(3,131 Views)