[Dev-C++] Re: Re: Re: Win32 shell programming
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: dx F. <vin...@ed...> - 2001-12-01 22:51:06
|
Does anyone know what is wrong here? Anyone knows where I can asks these questions?
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
|