Reputation: 66573
There are a few freeware tools out there (e.g., Taskbar Shuffle, XNeat, etc.) which have the ability to change the order of the buttons on the taskbar, without actually closing or opening any windows. Unfortunately, none of them appears to be open-source.
What are the API calls required to change the order of buttons in the taskbar?
Upvotes: 7
Views: 2959
Reputation: 66573
The answer is to use TB_MOVEBUTTON
in a call to SendMessage()
, as described in the WinAPI documentation here.
The first parameter to SendMessage()
(hWndControl
) needs to be a reference to the toolbar that contains the taskbar buttons. This is non-trivial to retrieve, but the CodeProject entry referred to in Chris Clarke's answer has all the code required to retrieve this handle.
wParam
and lParam
need to be set to the button ID of the button to move, and the position to move it to, respectively. These IDs are the idCommand
field in the TBBUTTON
structure that represents each button; how to retrieve these structures for the buttons can also be taken from the above CodeProject entry.
Upvotes: 6
Reputation: 8561
The fact that the Windows API does not expose methods to rearrange taskbar buttons is intentional. There is no supported way to do this.
See this article (and the ones it links to) for the thinking behind why the shell developers don't expose this functionality.
However, resourceful people have devised hacks the accomplish this (see the other answers). I suspect these methods will fall apart as Windows evolves (Windows 7, 64bit, etc...). Don't be surprised when these techniques stop working.
Upvotes: 1