Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    BFM_DRAGRECEIVE

    Cinema 4D SDK
    sdk c++
    2
    3
    533
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • WickedPW
      WickedP
      last edited by

      Hi folks,

      is it possible to get the number of files in a drag operation, before the execution of each one individually?

      case BFM_DRAGRECEIVE:
      {
      	KillEvents();
      
      	if(msg.GetData(BFM_DRAG_FINISHED).GetBool())
      	{
      		/* Custom handle function */
      		Handle_FileDrag(msg);
      	}
      
      	return SetDragDestination(MOUSE_NORMAL);
      }
      

      I'm currently getting multiple executions for a single drop. This isn't too much of an issue for a dozen or so files, but I'm concerned about many hundreds to 10's of thousands. The main issue is that I have to do a redraw for this operation. Is there a way around this?

      WP.

      wickedp.com

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by m_adam

        Hi @WickedP there is nothing built-in to change this behavior.

        The best workaround would be to add everything to a array/queue and then within a timer consume this queue at once. The most efficient way to do it to avoid any sync issue would be that BFM_DRAGRECEIVE start a timer and then within the Timer you do the redraw.

        So something like that (this is pseudo code that will not compile)

        class MyDialog:
        
            maxon::BaseArray<String> draggedFiles;
            maxon::Spinlock draggedFilesLock;
        
        
        void Timer(const BaseContainer& msg)
        {
            draggedFilesLock.Lock();
             // process all DragFiles.....
            draggedFilesLock.Unlock();
            SetTimer(0); // We do not want any other thick to happen.
        }
        
        case BFM_DRAGRECEIVE:
        {
        	KillEvents();
        
        	if(msg.GetData(BFM_DRAG_FINISHED).GetBool())
        	{
        	draggedFilesLock.Lock();
                SetTimer(0); // Cancel the current timer
                SetTimer(1000); // Execute the timer in 1sec, this give enough time to process all other drop operation
                draggedFiles.Append(msg) iferr_return; // Add the filename to the array
                draggedFilesLock.Unlock();
        	}
        
        	return SetDragDestination(MOUSE_NORMAL);
        }
        

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • WickedPW
          WickedP
          last edited by

          Thanks @m_adam,

          I had to jump through a bunch of hoops with this one, because I put the queue process into a progress dialog so that for large file arrays there's an indicator of progress. Otherwise it just appears to hang and the user won't know why. But this made it tricky when the timer is also used because of the different thread contexts involved with the timer, the progress dialog and everything else on the main thread. But with a bit of care, it seems to work.

          Thanks again,

          WP.

          wickedp.com

          1 Reply Last reply Reply Quote 0
          • First post
            Last post