• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 386
  • Last Modified:

Taskbar window order using ITaskbarList

Hi everyone,

I'm trying to write a little app to control the order my applications are displayed on my taskbar. I'm working with ITaskbarList although in order for me to do anything productive with that I need to have handles to the windows' order I want to manipulate.

Can someone point me in the right direction to getting handles to all the windows currently open?

Thanks in advance,

1 Solution
Use 'EnumWindows()', e.g.

BOOL CALLBACK MyEnumWindowsProc(
  HWND hwnd,      // handle to parent window
  LPARAM lParam   // application-defined value
) {

  // add 'hwnd' to a list

EnumWindows ( MyEnumWindowsProc, 0);
BeechyAuthor Commented:
I'm still playing around with this although I'm having problems with the enumWindows and it's callback function.

My code can be seen below......
#include <iostream>
#include <windows.h>
#include <vector>
using namespace std;

//Vector of window handles
typedef vector<HWND>     Vector;

Vector     vHandles;

struct DATA
     HWND     hwnd;
     string     strWindow;

BOOL CALLBACK myCallback(HWND hwnd, DATA myData)
     return true;

void main()
     long     myLong = 666;
     DATA     myData;

     //Enum desktop windows to get handles to current windows.
     EnumDesktopWindows(NULL,&myCallback, myData);

It wont compile as I'm getting the following error...

error C2664: 'EnumDesktopWindows' : cannot convert parameter 2 from 'int (__stdcall *)(struct HWND__ *,struct DATA)' to 'int (__stdcall *)(struct HWND__ *,long)'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast

I can't understand why it's wanting a long value to be passed when the API reference states the data to be passed to the callback function is application defined.

Thanks in advance,


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now