Thread: [Dev-C++] EURICA!: Win Shell Programming
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: dx F. <vin...@ed...> - 2001-12-07 09:14:37
|
After many hours of programming... I've finally found the solution! I have experimented with many styles and now I have a working code, ready to be used in one of my programs I am currently writing. Below is a copy of the test program code. The new function, IsAppWindow(HWND) tells if the window the handle points to is an Application window in the taskbar:
#include <string>
#include <windows.h>
#include <iostream.h>
// using namespace std;
BOOL IsAppWindow(HWND);
int i = 0;
BOOL CALLBACK AppGetWindows(HWND hwnd, LPARAM lParam) {
string str2;
LPSTR LPString;
LPString = new(CHAR);
if (IsAppWindow(hwnd))
{
i = i + 1;
if (GetWindowText(hwnd, LPString ,19) > 0) {
cout << i << ":" << LPString << endl;
}
}
return true;
delete LPString;
LPString = 0;
}
BOOL IsAppWindow(HWND hWnd)
{
BOOL bResult = TRUE;
LONG nStyle;
HWND hOwner;
HWND hParent;
// if it is a WS_CHILD or not WS_VISIBLE, fail it
nStyle = GetWindowLong(hWnd, GWL_STYLE);
if((nStyle & WS_CHILD) || !(nStyle & WS_VISIBLE))
bResult = FALSE;
// if the window is a WS_EX_TOOLWINDOW fail it
nStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
if(nStyle & WS_EX_TOOLWINDOW)
bResult = FALSE;
// If this has an owner, then only accept this window
// if the parent is not accepted
hOwner = GetWindow(hWnd, GW_OWNER);
if(hOwner && bResult)
bResult = !IsAppWindow(hOwner);
// if it has a parent, fail
hParent = GetParent(hWnd);
if(hParent)
bResult = FALSE;
return bResult;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int cmdShow) {
if (EnumWindows(*AppGetWindows, 0)) {
cout << endl << i << " Total Windows" << endl;
} else {
cout << "EnumWindows Failed /n" << endl;
}
system("PAUSE");
}
At first I didn't really know where I could start writing the function. But thanks to some advice to you folks, I now have this little test code. The program now outputs not only the number of windows but also the titles of the windows.
Guys! all ya Folks! Thanks!!!!
__________________________________
www.edsamail.com
|
|
From: Nexus <nne...@ya...> - 2001-12-07 15:55:34
|
Yep it works congratis
Nexus
--- dx FX <vin...@ed...> wrote:
> After many hours of programming... I've finally
> found the solution! I have experimented with many
> styles and now I have a working code, ready to be
> used in one of my programs I am currently writing.
> Below is a copy of the test program code. The new
> function, IsAppWindow(HWND) tells if the window the
> handle points to is an Application window in the
> taskbar:
>
> #include <string>
> #include <windows.h>
> #include <iostream.h>
>
> // using namespace std;
>
> BOOL IsAppWindow(HWND);
>
> int i = 0;
>
> BOOL CALLBACK AppGetWindows(HWND hwnd, LPARAM
> lParam) {
> string str2;
> LPSTR LPString;
> LPString = new(CHAR);
>
> if (IsAppWindow(hwnd))
> {
> i = i + 1;
> if (GetWindowText(hwnd, LPString ,19) > 0) {
> cout << i << ":" << LPString << endl;
> }
> }
>
> return true;
> delete LPString;
> LPString = 0;
> }
>
> BOOL IsAppWindow(HWND hWnd)
> {
> BOOL bResult = TRUE;
> LONG nStyle;
> HWND hOwner;
> HWND hParent;
>
> // if it is a WS_CHILD or not WS_VISIBLE, fail it
> nStyle = GetWindowLong(hWnd, GWL_STYLE);
> if((nStyle & WS_CHILD) || !(nStyle & WS_VISIBLE))
> bResult = FALSE;
>
> // if the window is a WS_EX_TOOLWINDOW fail it
> nStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
> if(nStyle & WS_EX_TOOLWINDOW)
> bResult = FALSE;
>
> // If this has an owner, then only accept this
> window
> // if the parent is not accepted
> hOwner = GetWindow(hWnd, GW_OWNER);
> if(hOwner && bResult)
> bResult = !IsAppWindow(hOwner);
>
> // if it has a parent, fail
> hParent = GetParent(hWnd);
> if(hParent)
> bResult = FALSE;
>
> return bResult;
> }
>
> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE
> hPrevInstance, LPSTR lpCmdLine, int cmdShow) {
>
> if (EnumWindows(*AppGetWindows, 0)) {
> cout << endl << i << " Total Windows" << endl;
> } else {
> cout << "EnumWindows Failed /n" << endl;
> }
>
> system("PAUSE");
> }
>
> At first I didn't really know where I could start
> writing the function. But thanks to some advice to
> you folks, I now have this little test code. The
> program now outputs not only the number of windows
> but also the titles of the windows.
>
> Guys! all ya Folks! Thanks!!!!
>
> __________________________________
> www.edsamail.com
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
>
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
=====
Nexus
Nanomage.com
http://www.nanomage.com
__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com
|
|
From: The O. W. <ka...@po...> - 2001-12-08 03:29:58
|
I've looked around the email and forum sites and couldn't find an answer to either of the following. (If I've missed it, just point me in the right direction, please!) 1 has anyone been able to get the free Windows version of Qt to link? If so, is there a doc I can get ahold of explaining it? 2 The getopt function does not seem to be in the unistd.h headers (or anywhere else in the basic include directories) is there one? Or even a quick clone I can swipe? Thanks for your time! Dan |
|
From: Guido E. <gu...@ge...> - 2001-12-08 21:15:19
|
The Old Wolf schrieb: > I've looked around the email and forum sites and couldn't > find an answer to either of the following. (If I've missed it, > just point me in the right direction, please!) > 1 has anyone been able to get the free Windows version > of Qt to link? If so, is there a doc I can get ahold of > explaining it? Sorry, but the Trolltechs say at their website: --- The Qt Non Commercial Edition for Microsoft Windows is a binary only distribution requiring Microsoft Visual Studio version 6. We have no plans to support other compilers, but we may do so in the future. The Professional and Enterprise Editions include full source code and support several compilers. --- (To be found at http://www.trolltech.com/developer/download/qt-win-noncomm.html ) - Guido |