473,513 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GetWindowEx() looping question

this is a little off topic but its also in comp.windows.programing
and hasent goten a reply and so im posting it here:

is it possible to loop through all top level windows using
GetWindowEx(), and save all their handles in an array? i have been
trying this one for a while but it dosent seem to work i end up in a
never ending loop. anyone know how this works?

please and thank you DarkChild

Feb 22 '06 #1
13 3770
da*********@gmail.com writes:
this is a little off topic but its also in comp.windows.programing
and hasent goten a reply and so im posting it here:
Actually, it's _completely_ off-topic.
is it possible to loop through all top level windows using
GetWindowEx(), and save all their handles in an array? i have been
trying this one for a while but it dosent seem to work i end up in a
never ending loop. anyone know how this works?


I'm sorry that you have been unable to get satisfactory response from
comp.windows.programming; you might try waiting a little longer, or
perhaps a web-based forum.

As to this newsgroup, I'm afraid we don't answer questions related to
non-Standard C function usage. Facilities provided by external
libraries or as extensions, etc., are way off-topic here, and as this
group already has a difficulty in keeping the signal-to-noise ratio
relatively sane, most of us simply refuse to answer such questions
(on-list, at least), even if we happen to know it (I don't).

At any rate, you are /far/ more likely to get useful responses from
trying several other Windows-programming-related forums.

Best of luck.

-Micah
Feb 23 '06 #2
da*********@gmail.com writes:
this is a little off topic but its also in comp.windows.programing
and hasent goten a reply and so im posting it here:

is it possible to loop through all top level windows using
GetWindowEx(), and save all their handles in an array? i have been
trying this one for a while but it dosent seem to work i end up in a
never ending loop. anyone know how this works?


Sorry, but this is entirely off-topic here. I'm sorry you're not
getting answers in comp.windows.programming, but that doesn't make it
topical here. Perhaps you could try one of the microsoft.*
newsgroups.

When you find an appropriate newsgroup, I strongly suggest you post
the actual code you're using.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 23 '06 #3

<da*********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
this is a little off topic but its also in comp.windows.programing
and hasent goten a reply and so im posting it here:

is it possible to loop through all top level windows using
GetWindowEx(), and save all their handles in an array? i have been
trying this one for a while but it dosent seem to work i end up in a
never ending loop. anyone know how this works?


Forgive them, for they know not what they say.

Saving the return values from a function to an array is standard C. Anyone
here can help with that. However, you unfortunately mentioned
'GetWindowsEx()' which provokes hostility among the immature and
inconsiderate. How about rephrasing your question, and posting code where
the 'GetWindowsEx()' is replaced by something non-descript?
Rod Pemberton
Feb 23 '06 #4
"Rod Pemberton" <do*********@sorry.bitbucket.cmm> writes:
<da*********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
this is a little off topic but its also in comp.windows.programing
and hasent goten a reply and so im posting it here:

is it possible to loop through all top level windows using
GetWindowEx(), and save all their handles in an array? i have been
trying this one for a while but it dosent seem to work i end up in a
never ending loop. anyone know how this works?


Forgive them, for they know not what they say.

Saving the return values from a function to an array is standard C. Anyone
here can help with that. However, you unfortunately mentioned
'GetWindowsEx()' which provokes hostility among the immature and
inconsiderate. How about rephrasing your question, and posting code where
the 'GetWindowsEx()' is replaced by something non-descript?


Actually, Rod, my lack of ability/inclination to post a helpful
response has nothing to do with arrays.

I have no idea what GetWindowEx() does, whether it can be used to loop
through all top level windows, and whether it provides access to
handles that could be stored in an array. Even if I did know these
things, their knowledge shouldn't really affect my answer.

Now, if his post explained something more about what GetWindowEx()
does, and asked a question that is obviously a Standard C-related
question, I (and others) might be able to help.

Also, I take issue to your assertion that anyone reacted with
hostility (at least, in any messages that have yet to show up on my
server), and would challenge you to produce an example of such. I was
very careful to word my response in a non-hostile manner.

The simple fact is, his question, at least as it was framed, was about
GetWindowEx(), not arrays, and is therefore off-topic here.

-Micah
Feb 23 '06 #5
Rod Pemberton wrote:

<da*********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
this is a little off topic but its also in comp.windows.programing
and hasent goten a reply and so im posting it here:

is it possible to loop through all top level windows using
GetWindowEx(), and save all their handles in an array? i have been
trying this one for a while but it dosent seem to work i end up in a
never ending loop. anyone know how this works?
Forgive them, for they know not what they say.

Saving the return values from a function to an array is standard C.


True.
Anyone here can help with that.
If he had posted some code, perhaps.
However, you unfortunately mentioned
'GetWindowsEx()' which provokes hostility among the immature and
inconsiderate. How about rephrasing your question, and posting code where
the 'GetWindowsEx()' is replaced by something non-descript?


Except you fail to realize that, lacking any sample code, it is entirely
possible that the fault lays in the way in which he uses GetWindowEx(),
and that is not something topical to clc.

Replacing "GetWindowEx()" with "something non-descript" such as "foo()"
will simply (and rightfully) be met with "what does foo() do", unless
you explain what it does.

I don't think people would have a problem with using GetWindowEx(), if
the OP were to post code, along with a description of the function.

Of course, given that Microsoft's documentation shows no such function as
"GetWindowEx()" or "GetWindowsEx()", it's entirely possible that we're not
even talking about MS-Windows here. Or it may be some third-party library
for MS-Windows. Or it may be a typo in the OP's post. Or...

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Feb 23 '06 #6
> Of course, given that Microsoft's documentation shows no such function as
"GetWindowEx()" or "GetWindowsEx()", it's entirely possible that we're not
even talking about MS-Windows here. Or it may be some third-party library
for MS-Windows. Or it may be a typo in the OP's post. Or...


im sorry therir was an error in my pose the function is as follows:

HWND FindWindowEx(

HWND hwndParent,
HWND hwndChildAfter,
LPCTSTR lpszClass,
LPCTSTR lpszWindow
);

Parameters

hwndParent
[in] Handle to the parent window whose child windows are to be
searched.

If hwndParent is NULL, the function uses the desktop window as
the parent window. The function searches among windows that are child
windows of the desktop.

Microsoft Windows 2000 and Windows XP: If hwndParent is
HWND_MESSAGE, the function searches all message-only windows.
hwndChildAfter
[in] Handle to a child window. The search begins with the next
child window in the Z order. The child window must be a direct child
window of hwndParent, not just a descendant window.

If hwndChildAfter is NULL, the search begins with the first
child window of hwndParent.

Note that if both hwndParent and hwndChildAfter are NULL, the
function searches all top-level and message-only windows.
lpszClass
[in]

Pointer to a null-terminated string that specifies the class
name or a class atom created by a previous call to the RegisterClass or
RegisterClassEx function. The atom must be placed in the low-order word
of lpszClass; the high-order word must be zero.

If lpszClass is a string, it specifies the window class name.
The class name can be any name registered with RegisterClass or
RegisterClassEx, or any of the predefined control-class names, or it
can be MAKEINTATOM(0x800). In this latter case, 0x8000 is the atom for
a menu class. For more information, see the Remarks section of this
topic.
lpszWindow
[in] Pointer to a null-terminated string that specifies the
window name (the window's title). If this parameter is NULL, all window
names match.

Return Value

If the function succeeds, the return value is a handle to the
window that has the specified class and window names.

If the function fails, the return value is NULL. To get extended
error information, call GetLastError.

and sorry its off topic but im getting mixed messages so i figgure i
should try anyway.

Feb 23 '06 #7
da*********@gmail.com writes:
Of course, given that Microsoft's documentation shows no such function as
"GetWindowEx()" or "GetWindowsEx()", it's entirely possible that we're not
even talking about MS-Windows here. Or it may be some third-party library
for MS-Windows. Or it may be a typo in the OP's post. Or...
im sorry therir was an error in my pose the function is as follows:

HWND FindWindowEx(

HWND hwndParent,
HWND hwndChildAfter,
LPCTSTR lpszClass,
LPCTSTR lpszWindow
);

[snip] and sorry its off topic but im getting mixed messages so i figgure i
should try anyway.


Sorry about the mixed messages. Some people here don't seem to
understand what's topical in this newsgroup and what isn't.

Your question is off-topic in comp.lang.c. HWND and LPCTSTR appear to
be system-specific types; we don't know how they're defined. (That's
not a request for you to explain them.)

There are a number of newsgroups that deal with MS Windows
programming. I don't know which one would be the most appropriate. I
think you mentioned comp.windows.ms.programmer; you might try
comp.os.ms-windows.programmer.win32, or perhaps one of the
microsoft.public.* newsgroups (there are 2349 of them on the news
server I use).

You've shown us the documentation for the FindWindowEx() function, but
you haven't shown us your code that's causing the problem. Once you
decide on an appropriate newsgroup, post a small complete compilable
program that exhibits the problem, so others can try it themselves,
and explain *exactly* how it fails (what it does and what you wanted
it to do). You shouldn't need to post a description of FindWindowEx()
if you find a forum where they already know about it.

Good luck.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 23 '06 #8
da*********@gmail.com writes:
Of course, given that Microsoft's documentation shows no such function as
"GetWindowEx()" or "GetWindowsEx()", it's entirely possible that we're not
even talking about MS-Windows here. Or it may be some third-party library
for MS-Windows. Or it may be a typo in the OP's post. Or...


im sorry therir was an error in my pose the function is as follows:


<snip>

Thanks for posting information on the function. There's still a lot of
Windows specific stuff in the description, but I think most would be
able to get the drift.

The thing is, from reading your description of the function, there
doesn't seem to be any obvious way (to me, at least) to use it to
iterate over all windows in a class of windows, and store their
handles in an array. That doesn't mean it can't be done, but it very
much seems like the answer will be Windows-related, rather than
C-related. Again, I'd really recommend that you ask this in a
different Windows-related forum. If the first one you tried turned out
unhelpful, you should look for others: there are many.

-Micah

Feb 23 '06 #9

<da*********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
this is a little off topic but its also in comp.windows.programing
and hasent goten a reply and so im posting it here:

is it possible to loop through all top level windows using
GetWindowEx(), and save all their handles in an array? i have been
trying this one for a while but it dosent seem to work i end up in a
never ending loop. anyone know how this works?

please and thank you DarkChild


Post your question (including your code) to group
comp.os.ms-windows.programmer.win32. It is a very
active group with many Windows experts. They'll
likely tell you about a function called 'EnumWindows()'.

Only standard C is topical for comp.lang.c

-Mike
Feb 23 '06 #10
da*********@gmail.com wrote:
this is a little off topic but its also in comp.windows.programing
and hasent goten a reply and so im posting it here:

is it possible to loop through all top level windows using
GetWindowEx(), and save all their handles in an array? i have been
trying this one for a while but it dosent seem to work i end up in a
never ending loop. anyone know how this works?


Ok OT, but as you're not getting anywhere fast ...

The simplest way to do this is to use EnumWindows() - as that enumerates
*only* top-level windows.

Say you have a main window wndproc, put this in some handy message handler
....

EnumWindows(EnumWindowsProc, (LPARAM)hwnd);

Note that the function call passes the current window's hwnd onto the
callback function EnumWindowsProc.

The EnumWindowsProc could be like this ...

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
HDC hDc;
char buffer[100]
static int n = 0;

// Get the main window's hwnd.
//
hDc = GetDC((HWND)lParam);

// Format the current enumerated window's hwnd.
//
wsprintf(buffer, "%X", hwnd);

TextOut(hDc, 0, n += 15, buffer, strlen(buffer));

ReleaseDC((HWND)lParam, hDc);

return TRUE;
}

The code above will output the window handles of all the top-level windows
on to the main window's client area.
--
==============
*Not a pedant*
==============
Feb 23 '06 #11
pemo wrote:
da*********@gmail.com wrote:
this is a little off topic but its also in comp.windows.programing
and hasent goten a reply and so im posting it here:

is it possible to loop through all top level windows using
GetWindowEx(), and save all their handles in an array? i have been
trying this one for a while but it dosent seem to work i end up in
a never ending loop. anyone know how this works?


Ok OT, but as you're not getting anywhere fast ...

The simplest way to do this is to use EnumWindows() - as that
enumerates *only* top-level windows.

Say you have a main window wndproc, put this in some handy message
handler ...


He is getting nowhere rapidly because he is asking in the wrong
place. You are doing no favors by answering in that same wrong
place, since there is nobody here to evaluate and correct that
answer. All you are doing is encouraging misbehaviour and creating
clutter.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
Feb 23 '06 #12
CBFalconer wrote:
pemo wrote:
da*********@gmail.com wrote:
this is a little off topic but its also in comp.windows.programing
and hasent goten a reply and so im posting it here:

is it possible to loop through all top level windows using
GetWindowEx(), and save all their handles in an array? i have been
trying this one for a while but it dosent seem to work i end up in
a never ending loop. anyone know how this works?


Ok OT, but as you're not getting anywhere fast ...

The simplest way to do this is to use EnumWindows() - as that
enumerates *only* top-level windows.

Say you have a main window wndproc, put this in some handy message
handler ...


He is getting nowhere rapidly because he is asking in the wrong
place. You are doing no favors by answering in that same wrong
place, since there is nobody here to evaluate and correct that
answer. All you are doing is encouraging misbehaviour and creating
clutter.


Main point taken.

The answer is correct though.

--
==============
*Not a pedant*
==============
Feb 23 '06 #13
da*********@gmail.com wrote:
Of course, given that Microsoft's documentation shows no such function as
"GetWindowEx()" or "GetWindowsEx()", it's entirely possible that we're not
even talking about MS-Windows here. Or it may be some third-party library
for MS-Windows. Or it may be a typo in the OP's post. Or...


im sorry therir was an error in my pose the function is as follows:

HWND FindWindowEx(

[...snip...]

Well, you still haven't posted your code which is having the problem.

However, making some assumptions (a bad thing, I know), you mention that
you want to fill an array by using this function in a loop. However,
nothing in the description of the function says that it iterates through
a list. Rather, it returns "a handle to _the_ window" (emphasis mine),
which tells me that it is explicitly stating that you will get the same
return value over and over. Calling it repeatedly will _not_ get you a
handle to the _next_ window.

I think this is a perfect example of why (1) showing actual code is very
important, (2) posting to the proper group is very important, and (3) not
giving erroneous information (like the wrong function name) is very
important.

Had you posted a question to a Windows programming group asking about
using FindWindowEx() in a loop, and included your code, someone there
probably would have pointed out right away that you're either using the
function incorrectly, or using the wrong function entirely.

If you want to find _all_ of the windows, then you need to use a
function which will enumerate (key word -- hint, hint) them for you.
Of course, now we're back to "which function that is, and how you use it
properly, are off-topic to clc and probably belong in one of the
comp.os.ms-windows.* or microsoft.public.* newsgroups". If, once you
get the function and how to use it, and you are using it properly (that
is, you are getting a list of values returned from successive calls) you
still have trouble filling in an array with its return values, then that
would be back on-topic here, but you need to post the code which is
failing, along with a description of the failure.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Feb 23 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1854
by: Colin Steadman | last post by:
I've create a simple survey using ASP. Its finished and works, but one aspect of my coding is annoying me and I cant figure out a better way of doing it. Basically the questions are stored in...
3
4724
by: bellefy | last post by:
Hi All, I have a fairly large table with approx 30K rows that updates every night via a cron script that automatically downloads the 2 new csv's. The problem is the files are downloaded from...
0
1527
by: | last post by:
Greets All, Question on data in datagrid /listbox and looping? I’m trying to decide the best way to write this code. 1 would like the user to make several selections from one listbox/combo box...
0
1396
by: | last post by:
Greets All, Question on data in datagrid /listbox and looping? I’m trying to decide the best way to write this code. 1 would like the user to make several selections from one listbox/combo box...
10
2085
by: Avi | last post by:
Hi I need to read in a large set of text files (9GB+ each) into a database table based on fixed width lengths. There are several ways to complete this, but I am wondering if anyone has...
7
2144
by: jwatson | last post by:
hey guys need help or some guidances please. Basically its a complicated looping and relational question. Write a program to calculate te percentage score of the mark of the students.The program...
20
2800
by: Ifoel | last post by:
Hi all, Sorry im beginer in vb. I want making programm looping character or number. Just say i have numbers from 100 to 10000. just sample: Private Sub Timer1_Timer() if check1.value= 1...
9
1539
by: Neil Gould | last post by:
I'm preparing an ASP script to send email to club members via the club's website. In getting familiar with CDOSYS, I noticed that the recommended method of sending the same content to multiple...
1
1977
by: Robocop | last post by:
Having just started using C again after some years off, i've been stumped by a problem i think someone more experienced could probably solve pretty easily. I have these 4 objects (vectors), and i...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7539
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7525
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3234
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.