Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I was trying to change the order of quick launch button on XP using C++, and my code looks like this:
    HWND hDesktop = GetDesktopWindow();
HWND hTray    = FindWindowEx( hDesktop , 0, _T("Shell_TrayWnd")   , NULL );
HWND hReBar   = FindWindowEx( hTray    , 0, _T("ReBarWindow32")   , NULL );
HWND hToolbar = FindWindowEx( hReBar    , 0, _T("ToolbarWindow32") , NULL );
int Count = SendMessage(hToolbar, TB_BUTTONCOUNT, 0, 0);
TBBUTTON tButton;
SendMessage(hToolbar, TB_MOVEBUTTON, Count-1, 0);
SendMessage(hTray, TBN_TOOLBARCHANGE, NULL, NULL);

IF there are less than 3 buttons in the quick launch toolbar, the code works just fine, but when there are more than 3 buttons, the order will change for a while, and remains the same after you clicking the little arrow button at the right of the 3 showing quick launch buttons.
Can anyone please tell me why this happen? and how I can fix it to make work for more than 3 buttons?
Posted

I can't help but wonder if this is a limit of 3 buttons, or if this limit is the number of buttons that are visible in the quick-launch bar?

That is to say, I'm wondering if the window created when you click the arrow-button isn't destroyed then recreated on request after some period of time has elapsed since last use. If this was the case, I'd presume Windows would load the icons up in the same order that has been specified already by the user (by dragging them into their preferred position)
 
Share this answer
 
Comments
ericchan1336 11-Jul-11 22:30pm    
hi, enhzflep
I think 3 is the defalut limits of number of the buttons that are visible in the quick launch bar.
enhzflep 11-Jul-11 23:08pm    
Hi Eric,
yes, that's right. My suggestion is to change the size of the quick-launch bar so that 4, 5 or 6 (for example) buttons are visible.
After doing this, I would try again to change the position of icon 4, 5 or 6 to see if that sticks.

My thoughts are that the ones that are visible in the toolbar will retain the position you give them with this piece of code, while the others that are displayed in the pop-up window will revert to their original positions.

The aim of this test would be to determine if the number 3 is an arbitrary limit or if the behaviour (i.e going back to original position) is a result of the icon not remaining visible when the pop-up window is destroyed.
Simon.
I've done further research, finding that the icons are re-instated to the original order whenever the ^ button is pressed to see hidden quick-launch options.
That is to say, this code works just fine with 3, 5, 10 quick-launch short-cuts, provided that they are all visible on the taskbar.

It seems that as I suspected, pressing the ^ button causes windows to reload all of the short-cuts and their order. This includes both visible and hidden icons. Without researching any other previous attempts to obtain this functionality, I'd be inclined to think that the order will be stored in the registry or some other file somewhere. It seems a worthy topic to look into.

---

AH-HAH!!! - Found it. The task-bar's look and feel (including the QL toolbar) are controlled by registry keys. They're not so friendly to look at immediately, as they appear to be an ascii representation of the hex-value of each char in the key, though I imagine that they shouldn't be too hard to deal with.


Have a look here [^]to see a discussion about how to set up the QL bar in a pre-determined way for first-time installs. Ignore the registry-hive stuff and just concentrate on the idea of making a change, exporting the correct key and repeating the process. A quick comparison of the two versions of the same key should shed some light on which parts of the key you need to concentrate on.

Best regards & good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900