Taskbar window order using ITaskbarList

Posted on 2003-03-25
Medium Priority
Last Modified: 2007-12-19
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,

Question by:Beechy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 86

Accepted Solution

jkr earned 225 total points
ID: 8205434
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);

Author Comment

ID: 8209284
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question