Re: [Dev-C++] Win32 shell programming
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Kevin W. <ke...@me...> - 2001-12-01 20:21:38
|
I don't think you are doing anything wrong. I have spent a few hours
experimenting with this and think that the problem is that most applications
don't set the WS_EX_APPWINDOW
extended style. Look at the Dev C++ template file - the parameter is set to
zero. If you set this parameter in your program code then print a list of
windows with that style, (using the code you have written) your program will
be listed.
Perhaps you could test the other styles and reject windows with the
WS_CHILD and WS_POPUP styles. However, this still leaves quite a few windows
that you can't switch to. Note that testing for the visible style leaves out
windows that are minimised to the task bar.
There must be another way!
Kev.
----- Original Message -----
From: dx FX <vin...@ed...>
To: Dev-C++ mailing list <dev...@li...>
Sent: Saturday, December 01, 2001 4:08 AM
Subject: [Dev-C++] Re: Re: Re: Win32 shell programming
> Ok. now Ive done it... but still am getting a zero count on application
windows. Anybody knows what Im doing wrong? the following is a test code.
Note that the code wasnt optimized for speed for it still is a test.
>
> #include <string>
> #include <windows.h>
> #include <iostream.h>
>
> BOOL IsAPPWINDOW(HWND);
> BOOL IsVISIBLE(HWND);
> int i = 0;
>
> BOOL CALLBACK AppGetWindows(HWND hwnd, LPARAM lParam) {
> if (IsAPPWINDOW(hwnd)) {
> // APPWINDOW...
> cin >> str2;
> if (IsVISIBLE(hwnd)) {
> // VISIBLE. Adding...
> i = i + 1;
> }
> }
> return true;
> }
>
> BOOL IsAPPWINDOW(HWND hwnd) {
> if ((GetWindowLong(hwnd,GWL_EXSTYLE) &
WS_EX_APPWINDOW)==WS_EX_APPWINDOW) {
> // the window referenced by the handle has a WS_EX_APPWINDOW style
> return true;
> } else {
> // no it doesnt
> return false;
> }
> }
>
> BOOL IsVISIBLE(HWND hwnd) {
> if ((GetWindowLong(hwnd,GWL_STYLE) & WS_VISIBLE)==WS_VISIBLE) {
> // the window referenced by the handle has a WS_VISIBLE style
> return true;
> } else {
> // no it doesnt
> return false;
> }
> }
>
> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int cmdShow) {
> if (EnumWindows(*AppGetWindows, 0)) {
> // print out the number of windows
> cout << i;
> } else {
> cout << "EnumWindows Failed!";
> }
> string str;
> cin >> str;
> }
>
>
> The program is suposed to detect the current windows with the WS_VISIBLE
and WS_EX_APPWINDOW styles and then count them. The output is the number of
windows that met the criteria. As one of you all said... the windows taskbar
only enumerates windows with the afformentioned styles. Take note that the
code is not yet optimized for it is still a test code. Any help on
optimizing the code would be a great help.
>
> Back to the problem... Did I do something wrong again??? I have other
applications running and it is supposed to output the number of the windows
available in the taskbar. Anybody! Help!
>
>
> __________________________________
> www.edsamail.com
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|