Getting windows in left to right taskbar order

Hi,
I was playing with the EnumWindows() and EnumDesktopWindows()
functions to get a list of open windows to populate a list box but
both of them enumerate windows in the Z-order. I want the list box to
be populated in left to right order of the windows seen on the
taskbar. Is there a way to make either of these functions return
windows in that order or to sort the list box once it has been filled?

Thanks in advance,
Ashish.

0
8/4/2007 5:33:32 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
948 Views

Similar Articles

[PageSpeed] 53

<ashish.sadanandan@gmail.com> ha scritto nel messaggio 
news:1186205612.295233.142190@m37g2000prh.googlegroups.com...

> I was playing with the EnumWindows() and EnumDesktopWindows()
> functions to get a list of open windows to populate a list box but
> both of them enumerate windows in the Z-order. I want the list box to
> be populated in left to right order of the windows seen on the
> taskbar. Is there a way to make either of these functions return
> windows in that order or to sort the list box once it has been filled?

Hi,

If you use the Spy++ tool, you can find that the taskbar window that hosts 
the buttons (i.e.: the buttons associated to windows), is a window of class 
"ToolbarWindow32" ("ToolbarWindow32" is one of the Windows common controls, 
also called "toolbar".).

So, the first step is to access this toolbar window (i.e. get its handle 
HWND).
You may start with GetDesktopWindow, then do sequential calls to 
FindWindowEx to navigate the windows hierarchy (as found with Spy++): 
Shell_TrayWnd ->
  ReBarWindow32 ->
    MSTaskSwWClass ->
      ToolbarWindow32     <--- the taskbar toolbar window

e.g.

HWND hDesktop = GetDesktopWindow();
HWND hShellTray = FindWindowEx( hDesktop, NULL, _T("Shell_TrayWnd"), NULL );
HWND hReBar = FindWindowEx( hShellTray, NULL, _T("ReBarWindow32"), NULL );
....

So you finally get the 'HWND hToolbar' for the toolbar.
Then, using this handle, you can send messages to the toolbar and 
communicate with it.

You can send a TB_BUTTONCOUNT message to get the count of the buttons in the 
toolbar, and then you can send TB_GETBUTTON messages (e.g. in a for loop, 
index = 0,1,...count-1) to enumerate the buttons, and fill your list in 
left-to-right order.

Note #1:
It seems that there is an undocumented Win32 API function called 
GetTaskmanWindow, that helps accessing the taskbar. But it is undocumented, 
so I would prefer not using that. Moreover, I don't even know if it is 
defined in Windows Platform SDK header files, so you may also use an 
explicit call to GetProcAddress from the User32.dll to get a pointer to that 
function and call it.

Note #2:
I've found that Windows shell implements a COM interface called 
ITaskbarList, that exposes methods that control the taskbar, but I don't 
know it  well and don't know if it exposes also methods for enumerations...


Giovanni



0
8/4/2007 9:40:02 AM
Note that taskbar windows do not have a 1:1 correspondence with actual programs.  For
example, I have one that tells me that I have three copies of VS, six copies of IE, two
copies of NotePad, 7 copies of Explorer, 3 copies of Remote Desktop, etc., so you cannot
safely assume that each taskbar object represents exactly one application.
						joe

On Sat, 4 Aug 2007 11:40:02 +0200, "Giovanni Dicanio" <giovanni.dicanio@invalid.it> wrote:

>
><ashish.sadanandan@gmail.com> ha scritto nel messaggio 
>news:1186205612.295233.142190@m37g2000prh.googlegroups.com...
>
>> I was playing with the EnumWindows() and EnumDesktopWindows()
>> functions to get a list of open windows to populate a list box but
>> both of them enumerate windows in the Z-order. I want the list box to
>> be populated in left to right order of the windows seen on the
>> taskbar. Is there a way to make either of these functions return
>> windows in that order or to sort the list box once it has been filled?
>
>Hi,
>
>If you use the Spy++ tool, you can find that the taskbar window that hosts 
>the buttons (i.e.: the buttons associated to windows), is a window of class 
>"ToolbarWindow32" ("ToolbarWindow32" is one of the Windows common controls, 
>also called "toolbar".).
>
>So, the first step is to access this toolbar window (i.e. get its handle 
>HWND).
>You may start with GetDesktopWindow, then do sequential calls to 
>FindWindowEx to navigate the windows hierarchy (as found with Spy++): 
>Shell_TrayWnd ->
>  ReBarWindow32 ->
>    MSTaskSwWClass ->
>      ToolbarWindow32     <--- the taskbar toolbar window
>
>e.g.
>
>HWND hDesktop = GetDesktopWindow();
>HWND hShellTray = FindWindowEx( hDesktop, NULL, _T("Shell_TrayWnd"), NULL );
>HWND hReBar = FindWindowEx( hShellTray, NULL, _T("ReBarWindow32"), NULL );
>...
>
>So you finally get the 'HWND hToolbar' for the toolbar.
>Then, using this handle, you can send messages to the toolbar and 
>communicate with it.
>
>You can send a TB_BUTTONCOUNT message to get the count of the buttons in the 
>toolbar, and then you can send TB_GETBUTTON messages (e.g. in a for loop, 
>index = 0,1,...count-1) to enumerate the buttons, and fill your list in 
>left-to-right order.
>
>Note #1:
>It seems that there is an undocumented Win32 API function called 
>GetTaskmanWindow, that helps accessing the taskbar. But it is undocumented, 
>so I would prefer not using that. Moreover, I don't even know if it is 
>defined in Windows Platform SDK header files, so you may also use an 
>explicit call to GetProcAddress from the User32.dll to get a pointer to that 
>function and call it.
>
>Note #2:
>I've found that Windows shell implements a COM interface called 
>ITaskbarList, that exposes methods that control the taskbar, but I don't 
>know it  well and don't know if it exposes also methods for enumerations...
>
>
>Giovanni
>
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
8/4/2007 4:13:07 PM
On Aug 4, 3:40 am, "Giovanni Dicanio" <giovanni.dica...@invalid.it>
wrote:
> <ashish.sadanan...@gmail.com> ha scritto nel messaggionews:1186205612.295233.142190@m37g2000prh.googlegroups.com...
>
> > I was playing with the EnumWindows() and EnumDesktopWindows()
> > functions to get a list of open windows to populate a list box but
> > both of them enumerate windows in the Z-order. I want the list box to
> > be populated in left to right order of the windows seen on the
> > taskbar. Is there a way to make either of these functions return
> > windows in that order or to sort the list box once it has been filled?
>
> Hi,
>
> If you use the Spy++ tool, you can find that the taskbar window that hosts
> the buttons (i.e.: the buttons associated to windows), is a window of class
> "ToolbarWindow32" ("ToolbarWindow32" is one of the Windows common controls,
> also called "toolbar".).
>
> So, the first step is to access this toolbar window (i.e. get its handle
> HWND).
> You may start with GetDesktopWindow, then do sequential calls to
> FindWindowEx to navigate the windows hierarchy (as found with Spy++):
> Shell_TrayWnd ->
>   ReBarWindow32 ->
>     MSTaskSwWClass ->
>       ToolbarWindow32     <--- the taskbar toolbar window
>
> e.g.
>
> HWND hDesktop = GetDesktopWindow();
> HWND hShellTray = FindWindowEx( hDesktop, NULL, _T("Shell_TrayWnd"), NULL );
> HWND hReBar = FindWindowEx( hShellTray, NULL, _T("ReBarWindow32"), NULL );
> ...
>
> So you finally get the 'HWND hToolbar' for the toolbar.
> Then, using this handle, you can send messages to the toolbar and
> communicate with it.
>
> You can send a TB_BUTTONCOUNT message to get the count of the buttons in the
> toolbar, and then you can send TB_GETBUTTON messages (e.g. in a for loop,
> index = 0,1,...count-1) to enumerate the buttons, and fill your list in
> left-to-right order.
>
> Note #1:
> It seems that there is an undocumented Win32 API function called
> GetTaskmanWindow, that helps accessing the taskbar. But it is undocumented,
> so I would prefer not using that. Moreover, I don't even know if it is
> defined in Windows Platform SDK header files, so you may also use an
> explicit call to GetProcAddress from the User32.dll to get a pointer to that
> function and call it.
>
> Note #2:
> I've found that Windows shell implements a COM interface called
> ITaskbarList, that exposes methods that control the taskbar, but I don't
> know it  well and don't know if it exposes also methods for enumerations...
>
> Giovanni

Hi Giovanni,
Thank you for that detailed reply. Although I haven't had a chance to
try it out yet it seems straightforward enough that I should be able
to manage it. But there is a problem with your solution; I also need
handles to these taskbar windows, EnumDesktopWindows() returns these
but how do I get handles using your method?

Thanks again,
Ashish.

0
8/9/2007 6:25:29 AM
Reply:

Similar Artilces:

how do i get oulook to get mail from yahoo?
I have yahoo accounts, but cannot get outlook to recognize them... am computer illiterate, so put answer in laymans terms please. thanks Do you have a paid yahoo account? You need an account that supports POP3 (free accounts don't) before you can use it with Outlook. -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coauthor, OneNote 2003 for Windows (Visual QuickStart Guide) Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com Sub...

Why does IE always open minimized windows when opening a new window?
When I minimize a window, to refer to later, and then open another window, the minimized window opens to full screen for a few seconds before the new window appears. Why can't IE not open a new window without maximizing some other window at the same time? Is there a solution to this problem? Kathy -- scrimaglia Posted via http://www.vistaheads.com scrimaglia wrote: > When I minimize a window, to refer to later, and then open another > window, the minimized window opens to full screen for a few seconds > before the new window appears. Why can't IE not ...

Windows Time Causing Exchange Crash
I am running Exchange server 2003 sp2 on windows 2003 sp1 with two domain controllers running 2003 as well. The problem is exchange will periodically quick working, I get a windows system event saying it cannot do an LDAP bind with either of the DCs when I restart windows time service on the DCs email starts going again. Time is in the right Time zones and set correctly on all servers. Any suggestions? Thanks Can we see complete unedited event from event log? What happens after you get that event? jspr wrote: > I am running Exchange server 2003 sp2 on windows 2003 sp1 with two >...

Cannot delete one message in Windows Mail
A message fron Sen Feinstein to an individual copied to me can not be deleted ? On Wed, 27 Feb 2008 13:43:18 +0100, John Kirby wrote: > A message fron Sen Feinstein to an individual copied to me can not be > deleted ? You have posted this message to the wrong newsgroup. The access in this groups name refers to Microsoft Access, a database program. Please repost to the correct newsgroup for whatever program you are using. I would suggest you include your Windows version number in the message. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail ...

strange window resizing glitches under XP (not strictly an MFC question but it's making my app look bad)
I've noticed a very ugly graphical "effect" when resizing a window under XP (Windows XP style / Silver appearance / ShowContentsWhileDragging). Resizing the right/bottom edges works like win2k (i.e. as expected) but dragging the left or top edge causes the right or bottom edges of the window frame to flicker like hell as the background pops through and then gets drawn over with the window contents. Try opening a large window of "My Computer" and then drag the left edge backwards and forwards across the screen quickly and repeatedly - not nice. There's also another...

Windows too large
System specs: Vista Business Intel Core2Duocpu t5470 NVIDIA GeForce 8400M GS I was having problems seeing the fonts inside the windows and the icons on the desk top. I customized the DPI to 144. This made the widows too large. When I went back to the DPI page to change back to 96 DPI, I couldn't reach the buttons on the bottom of the page to apply the change. The other problem is that the task bar is too large. It covers the bottom of the page. Again, I can't change it because I can't reach the apply buttons on the bottom of the page. I need to make the changes bec...

Coexsistence GroupWise 6.5 and Windows 2003
I have done couple of these migrations from Groupwise 5x to windows 2000 or 2k3. Now I researching on a up and coming project to do migration from 6.5 to 2k3. There seems to be an issue GroupWise API is old technology and seems it is not supported. Let me rephrase that you cannot create it using ConsoleOne and maybe i can getway with using the older Snapins say from GW 5.5 for NWAdmin. I see the utility by Novell Gateway for Exchange, has anyone used that for migration? any issues ? do you recommend using that? Or I am wrong into thinking that is a solution? Is there something develo...

How do I get pictures of certain equipment in Microsoft Visio?
I'm trying to use Visio to help illustrate our network. I know I've seen before where somebody had the exact equipment in his Visio project. How do I get those? Is there a main database with all the equipment, or do I need to go to each individual site and see if they have it? Thanks in advance. unless you are willing to pay for them at third party sites, the best bet is too check with the vendor. you might strart over at john marshall's site (www.mvps.org/visio) al "captmorg11" <captmorg11@discussions.microsoft.com> wrote in message news:336545C1-F340...

Online Ordering Problem
As my trial version of Money Plus Delux has only few days left to run, I decided to order a copy of it from the MS/Digital River download site. For whatever reason, the order form was pre-initialized for 3 copies instead of the one I ordered. I corrected the 3 to 1 before I filled in the credit card info. To my surprise, I was still billed for 3 copies but by that time I could not change or cancel my order. I immediately sent an email to Digital River about this but I wonder if any of you also encountered this seeming scam. JP In microsoft.public.money, JP wrote: >As my trial ve...

Custom Sort Order in a Form
Hello, I am trying to set the sort order to a custom setting in an Access Form (2k). I have a field with data "High", "Medium", "Low". If I sort normal the data is viewed High, Low, Medium. I want it to sort H,M,L. Is there anyway to do this? Thanks Create a table along the lines of: RatingValue SortOrder High 1 Medium 2 Low 3 Sort on the SortOrder field. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "jrizzo77" <jrizzo77@yahoo.c...

I cannot get my printer to print any information
I USED EXCEL 2003 TO GENERATE A WORKSHEET WITH DATA. I CANNOT PRINT IT. WHY? The why could be many things, some of which could be exel issues and some of which could be driver issues, network issues, or others. Can you, for instance, print from other applications to your printer? Have you been able to print from Excel in the past and this is a new problem, or is this your first attempt to print from Excel? -- Y "ANDIAMO" wrote: > I USED EXCEL 2003 TO GENERATE A WORKSHEET WITH DATA. I CANNOT PRINT IT. WHY? ...

Is tooltip window
Hi all, I am having an HWND, using this how can i able to get whether it is a tool tip window ? thanks in advance. Regards, Umesh P <kbnumesh@gmail.com> wrote in message news:1176702297.777421.285420@d57g2000hsg.googlegroups.com... > Hi all, > > I am having an HWND, using this how can i able to get whether it is > a tool tip window ? > Call GetClassName() and compare it to the tooltip class name (whatever that is). -- David ...

IE 8 secondary window problem?
Hi, Not sure this is the right place to post this question; if not I'd appreciate a link as to where to do it. Problem (if it is a problem, well, for me it is a problem!) is that when I'm on a page in IE 8 and click on something that opens in a second window (like a news article), the second window is about 1/3 the size of the full window. I have to enlarge it to see the whole article, video, or whatever. This gets a bit repetitive, and I'd rather have the second window open to full size but can't figure out if there's a setting to control it, and if so, which ...

Windows is not currently managing your wireless network
We have two computers in the house, one connected by wire to the router, and one via wireless. Of course they were set up by our kids.... Today I had to unplug all the wires and plug them back in again. Since that time the wireless computer hasn't been able to connect. In START/Connected to/Wireless connections we see the connection we expected. Status - Connected Network - Hunt's Corner Signal Strength - 5 bars When I go to the providers speedtest website we have excellent speed. That all looks good, But if I click the "View Wireless Networks" b...

Printing Blanket Purchase Orders
If one or more lines of a blanket PO have been received, why do these lines still appear on the PO printout? Is there a way to exclude received line items from printing on the PO at the next release date? I believe the solution is to modify the report. You would need to conditionally print line items based on the PO type and status. -- Charles Allen, MVP "Elaine" wrote: > If one or more lines of a blanket PO have been received, why do these lines > still appear on the PO printout? Is there a way to exclude received line > items from printing on the PO at the ...

cross administrative group move windows 98
We recently installed exchange 2003 in our organisation. We are now running in mixed mode with exchange 5.5. We are not able to do a cross administrative group move for mailbox of all windows 98 users. (from exchange 5.5 to exchange 2003). Any idea? Eric Lajeunesse <eric.lajeunesse@saputo.com> wrote: > We recently installed exchange 2003 in our organisation. We are now > running in mixed mode with exchange 5.5. > We are not able to do a cross administrative group move for mailbox > of all windows 98 users. (from exchange 5.5 to exchange 2003). > Any idea? Ask in th...

VBA
Dear all, I have several charts in a sheet for which I need to change the data ranges. Currently each chart has a different data range, and for each chart the new desired data range is just an straightforward extension of the original (i.e., the new data ranges could be easily calculated from the original ones just by adding a fixed number of rows/ columns). I am therefore trying to implement a macro for updating the data ranges of my charts automatically, but so far I haven't found a way for getting the actual data range of a chart. I guess I'm looking for something like the opposit...

Some accounts don't show up on the Get online statement list
I've set up some new accounts with my financial broker and check "get online statements". But when I go to connect these accounts do not show up in the "Get Statement" List for that institution. What do I need to do to add these to the list? In microsoft.public.money, Steven Friedman wrote: >I've set up some new accounts with my financial broker and >check "get online statements". But when I go to connect >these accounts do not show up in the "Get Statement" List >for that institution. What do I need to do to add these to &g...

Answer to the most annoying problem of Windows 7
This message was posted here because: 1. I couldn't find any newsgroup on Microsoft Communities for Windows 7 (which I believe is an absolute must) 2. the program mentioned at the end would also work for Vista. From day one of upgrading to Windows 7, I was faced with the unpleasant reality that Win7 doesn't remember the size and position of folders. To further torture me, for some reason unknown to me, it began to restrict some programs' windows--such as IE , Outlook, Chrome, and a few other--to a fixed size and position, not allowing any change no matter how many times...

Windows Event Log Reader (not server based)
Fist, I already know about "Log Parser" and all the sever-based Event Log utilities. What I would like is a simple GUI utility to read/view SAVED Event Log files. Anyone know of such a utility (non-server)? NOTE: I do have a shortcut in my "SendTo" folder that runs a Command using "Log Parser" but this is a workaround. Command start-------------- cd \EventLogArchive "C:\Program Files\Log Parser 2.2\logparser" "SELECT ALL * FROM %1" - i:EVT -o:DATAGRID Command ends-------------- "\EventLogArchive" = C:...

MS CRM Outlook offline: "Access denied. You do not have sufficient access rights or privileges to perform this action"
Hallo NG, MS CRM-Server runs fine. But one problem: MS CRM Outlook offline (Client PC) with Admin-Rights: --- "Access denied. You do not have sufficient access rights or privileges to perform this action". --- Working Online in Outlook or accessing via IE from client-pc -- no problems. ?? Thank you, U. K´┐Żnig .. ...

When I click on a column, that column and one to its right is sele
For some reason, on my first spreadsheet, when I click on a column, the one to its right is also selected. It doesn;t happen on all the columns. What did I do to cause that? Thank you for any assistance. I bet you merged some cells. Select those two columns and then Rightclick on any of the selected cells Format cells|Alignment tab Look for merged cells. You'll see that it's a mixture of merged cells (either a green square or a grey checkbox -- depends on the version). You can remove the merged cells by clearing that checkbox. But you may want to look to see if you removed som...

Windows Messenger fails to load
I know most of you think that Windows Messenger loading with Outlook Express is a curse, but I think its rather neat. However, when I installed AOL's Messenger, I accidentally set it to be the default messenger. This caused AOL messenger to load up instead of Window's Messenger when I open OE. However, i set default back to Windows Messenger (through addremove progs, set defaults). But when i get to Outlook Express, when i go to Tools > Windows Messenger > send instant message i get the following error: "Internet Explorer Install on Demand failed to install Windo...

Getting Common Dialog Font ?
Hi guys, Is there a way I can get the font that's displayed in a MessageBox() or a CFileDialog() ? When I create my controls explicitly they have that bold system font. I can set it to MS Sans Serif size 8 to match the dialog boxes created in the resource editor but is that the best way to do it ? It would be cool if there was a function like this: CFont* pFont=GetCommonFont(); Take care, Robert A. "Robert A." <invalid@invalid.org> wrote in message news:eqer0QbGEHA.1292@TK2MSFTNGP12.phx.gbl... > Hi guys, > > Is there a way I can get the font that's displa...

how do i get the hours between these times??
hi! i have the following scenario: if a person works between i.e. 08:00 and 21:00 i need to have a column that says how many hours and minutes it is between 08:00 and 18:00 18:15 and 20:00 20:00 and infinit i also have to have in mind that a person very well can work between i.e. 08:00 and 19:00. someone have a good solution for me =) ? thanks! -- hendersson ------------------------------------------------------------------------ hendersson's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=18427 View this thread: http://www.excelforum.com/showthread.php?th...