I can't figure out how I would be able to enumerate the files/folders dropped onto a menu item in the WM_MENUGETOBJECT event. Do I have to implement the interface for iDropTarget myself or use the riid and pvObj items of the MENUGETOBJECTINFO structure somehow?
This isn't really a v2 specific question but that's why I typically try to use. The code I've been playing with:
Code: Select all
OnMessage(WM_MENUGETOBJECT := 0x124, "GetObject")
m := MenuCreate()
m.Add("Drop on Me!", "Dropped")
m.Add("Drag Me!", "Dropped")
menuInfo := BufferAlloc(16+3*A_PtrSize)
NumPut("UInt", 16+3*A_PtrSize, menuInfo)
NumPut("UInt", 0x10, menuInfo, 4)
NumPut("UInt", 0x20000000 | 0x40000000, menuInfo, 8) ; MNS_DRAGDROP and MNS_MODELESS, the latter is required
DllCall("SetMenuInfo", "Ptr", m.handle, "Ptr", menuInfo)
F4::m.show()
Dropped(path, *) {
MsgBox("Dropped!")
}
GetObject(wParam, lParam, msg, hWnd) {
global m
static paths := [A_Desktop, A_MyDocuments]
flags := NumGet(lParam, "UInt")
pos := NumGet(lParam, 4, "UInt")
hMenu := NumGet(lParam, 12, "Ptr")
riid := NumGet(lParam, 20, "Ptr")
pInt := NumGet(lParam, 28, "Ptr")
if (hMenu != m.handle) {
ToolTip("Our menu")
return 1
}
if (flags & (0x2 | 0x1)) {
return 0
}
ToolTip(ridd "`n" pInt)
return 1
}
DoDrop(*) {
Msgbox("Dropped")
}