views:

555

answers:

4

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?

A: 

A quick web search found this.

Seems to be exactly the style of program you're looking for, with the source available too.

I'll not go into more detail as it's explained pretty well here

Chris Clarke
Thanks for your answer, but this didn't help. The example you linked to hides and re-shows all the windows, which causes a lot of flashing around. Taskbar Shuffle, by contrast, seems to be able to just change the order of the buttons full-stop.
Timwi
+1  A: 

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.

Aardvark
+2  A: 

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.

Timwi
A: 

> Seems to be exactly the style of program you're looking for

It's a complete bullshit (with hardcoded windows classes !!)

The rigth and official method is to use Win32 COM. See MSDN

Your answer is not useful. "Use COM" is too unspecific. "See MSDN" is also too unspecific. You should provide direct links to the relevant information, or include the information directly in your answer.
Timwi
I guess he means ITaskbarList, but I does not provide a way to set the order, only to add/remove/activate
Anders