November 24th, 2004

Why can’t you drop directly onto a taskbar button?

If you drag a object and drop it onto a taskbar button, you get an error message that says,

You cannot drop an item onto a button on the taskbar.

However, if you drag the item over a button without releasing the mouse button, the window will open after a moment, allowing you to drop the item inside the window.

Why doesn’t the taskbar let you drop directly onto a taskbar button?

Ideally, if the taskbar receives a IDropTarget::Drop, it could do something like this:

// imaginary code
IDropTarget *pdt;
if (SUCCEEDED(GetDropTargetFromWindow(hwndButton, &pdt))) {
  pdt->Drop(…);
  pdt->Release();
}

(Warning: I said “something like” this. Forwarding a drop is actually more complicated than this.)

The reason why the taskbar doesn’t do this is that there is no such function GetDropTargetFromWindow function. The taskbar can’t forward the drop operation even if it wanted to.

Why is there no GetDropTargetFromWindow function? I have no idea. You’ll have to ask the OLE folks. If I had to guess (and I know I have to because you folks will just keep badgering me until I come up with a guess), it’s because that would create the problem of how to prevent somebody from screwing with a program by grabbing its drop target and never releasing it.

Now of course people will criticize my explanation, so I’m going to say it again: I don’t know the answer. I’m just guessing. My guess is probably wrong.

Topics
Other

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.