简体   繁体   中英

How to right button drag with Win32 API?

I implemented the IDropTarget interface and the drag & drop (file from explorer) works well.

When I drag & drop a file with right mouse button, the context menu does not popup.

So I think it's my responsibility to show the context menu,

But in IDropTarget::Drop method, (grfKeyState & MK_RBUTTON) is always 0.

How can I know if the drag mouse button was right?

And is there a special method to show menu and receive the selection after the drop?

(I prefer the Win32 API way, I don't use MFC.)

I guess ( grfKeyState & MK_RBUTTON ) is always 0 because when the Drop() method is called, the mouse button is already released (you've just made the drop) - so naturally the keyboard/mouse state flags would indicate that it is indeed released.

What you can (and should , according to the documentation) do, is to decide ahead the course of action you take on Drop() when you're handling DropEnter() . I haven't tried it myself, but I'm quite sure that the MK_RBUTTON flag should be set there. You can check that flag when your drop target's DropEnter() method is being called, save it and then open the context menu yourself when Drop() is called. This is not the cleanest solution, but I don't know if there's a way to make Windows show a context menu for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM