Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Implementing asyncronous IDropTarget (Read 3530 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Implementing asyncronous IDropTarget

Hello all,

I am implementing an asyncronous IDropTarget in my DUI. I woud like to adhere SDK docs and do the Drop IDataObject processing asyncronously. It seems the correct way of doing this is to use playlist_incoming_item_filter_v2::process_dropped_files_async method. However, it seems a bit hard to use since I found that the IDataObject contains no IID_IAsyncOperation interface (when dragging items from a playlist). I found this fact by calling pDataObj->QueryInterface(IID_IAsyncOperation, (void **) &asyncOperation); which returns E_NOINTERFACE.

How to do async prosessing of Drop if the interface is not supported?

Thanks,

-kerpondile

Implementing asyncronous IDropTarget

Reply #1
Code: [Select]
virtual void process_dropped_files_async(interface IDataObject * p_dataobject,t_uint32 p_op_flags,HWND p_parentwnd,process_locations_notify_ptr p_notify) = 0;


playlist_incoming_item_filter_v2::process_dropped_files_async() manage for you the async creation of metadb handles contained in the IDataObject structure, and on completion will call
p_notify->on_completion() (in the main thread).

example:

Code: [Select]
class  dropped_items_process_locations_notify : public process_locations_notify {
public:
    dropped_items_process_locations_notify(controller_window::context_menu_action_t action) : m_action(action) { }
    void on_completion(const pfc::list_base_const_t<metadb_handle_ptr> & p_items) {
             // do something here
    }
    void on_aborted() {    }
private:
    controller_window::context_menu_action_t m_action;
};

HRESULT __stdcall controller_window::Drop(IDataObject * pDataObject, DWORD grfKeyState, POINTL pt, DWORD * pdwEffect) {
          ...
        service_ptr_t<process_locations_notify> completion = new service_impl_t<dropped_items_process_locations_notify>(action);
        t_uint32 flags = playlist_incoming_item_filter_v2::op_flag_background|playlist_incoming_item_filter_v2::op_flag_delay_ui;
        static_api_ptr_t<playlist_incoming_item_filter_v2>()->process_dropped_files_async(pDataObject, flags, *this, completion);
         ...
    
    return S_OK;
}

Implementing asyncronous IDropTarget

Reply #2
Code: [Select]
virtual void process_dropped_files_async(interface IDataObject * p_dataobject,t_uint32 p_op_flags,HWND p_parentwnd,process_locations_notify_ptr p_notify) = 0;


playlist_incoming_item_filter_v2::process_dropped_files_async() manage for you the async creation of metadb handles contained in the IDataObject structure, and on completion will call
p_notify->on_completion() (in the main thread).

example: ...



I understand this, and I've done something similar to you example. The problem is that I cannot change pdwEffect in the dropped_items_process_locations_notify and that's why I asked why isn't async processing of IDataObject supported?

For example, if the on_aborted is called,  I'd like to return DROPEFFECT_NONE

Implementing asyncronous IDropTarget

Reply #3
Then, you probably want to call playlist_incoming_item_filter::process_dropped_files_check_ex() in your DragEnter() implementation of  the IDropTarget interface to accept or reject dropped items, then use playlist_incoming_item_filter_v2::process_dropped_files_async() normally in Drop()...

process_dropped_files_check_ex() is fast, opposite to process_dropped_files_async() that can take some time to execute and which should IMHO only called in Drop().

 

Implementing asyncronous IDropTarget

Reply #4
Then, you probably want to call playlist_incoming_item_filter::process_dropped_files_check_ex() in your DragEnter() implementation of  the IDropTarget interface to accept or reject dropped items, then use playlist_incoming_item_filter_v2::process_dropped_files_async() normally in Drop()...

process_dropped_files_check_ex() is fast, opposite to process_dropped_files_async() that can take some time to execute and which should IMHO only called in Drop().


This what I have done and I guess I have no other choice, probably sufficient for my needs...Thanks!