• 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,

Beechy
0
Beechy
Asked:
Beechy
1 Solution
 
jkrCommented:
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);
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)
{
     vHandles.push_back(hwnd);
     return true;
}

void main()
{
     vHandles.clear();
     long     myLong = 666;
     DATA     myData;

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

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,

Beechy
0

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