![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Dec 2007
Posts: 93
Rep Power: 2
![]() |
Sup guys,
Is there any function that retrieves the handles to all visible windows on screen(not including controls)? Thanks. |
|
|
|
|
|
#2 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 653
Rep Power: 4
![]() |
Re: Going through all windows -
|
|
|
|
|
|
#3 |
|
Programmer
Join Date: Dec 2007
Posts: 93
Rep Power: 2
![]() |
Re: Going through all windows -
I did try to use that function but for some reason I came up with an outrageous number like 272. I am sure that there aren't that many visible windows on my screen
Any ideas?Thanks. |
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,318
Rep Power: 5
![]() |
Re: Going through all windows -
EnumWindows() tends to be pretty reliable with picking up windows on the screen -- and it picks up ALL windows, whether visible or not. The issue is probably that your definition of "window" is somewhat more limited that the one used by the OS -- a window is just a particular type of system resource.
Several system applications (and even the odd background service, which sometimes needs to communicate with the user) have windows that are invisible until they are needed. Some things that are also routinely on the desktop are actually windows even if they don't look like a window: examples include the task bar, each icon in the notification area of the taskbar, the start menu, toolbars, the desktop itself, ..... |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Dec 2007
Posts: 93
Rep Power: 2
![]() |
Re: Going through all windows -
Thanks for that reply! But the thing is that I in fact am aware of that
Is there any way to use that function to pick up JUST TOP LEVEL windows?I'm not sure that your aware of this(not that many people are) but as far as I know a top level window is a window the has the WS_OVERLAPPED or WS_OVERLAPPEDWINDOW styles. Please reply even if you don't know how to do this(because this is really important to me and I need to know if you know. ![]() Thanks. |
|
|
|
|
|
#6 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,318
Rep Power: 5
![]() |
Re: Going through all windows -
Quote:
A top-level window is one that has no parent (eg GetParent() will return NULL). It has nothing to do with the WS_OVERLAPPED style. WS_OVERLAPPED is a style commonly used by applications for their main window. WS_OVERLAPPEDWINDOW is a combination of that style with some other common ones (so it has a caption, maximize button, etc etc). However, it is not mandatory that applications use these styles To check if a window has the a particular bit set do this; int window_has_style = (GetWindowLong(window, GWL_STYLE) & style_bit); And, to nag mods again, this is win32 API stuff that (except for the code example which is C) works in any language under windows operating systems. It has nothing to do with C++. |
|
|
|
|
|
|
#7 |
|
Programmer
Join Date: Dec 2007
Posts: 93
Rep Power: 2
![]() |
Re: Going through all windows -
LOL :p, thanks for telling me that
. But what about the main problem?Thanks. |
|
|
|
|
|
#8 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,318
Rep Power: 5
![]() |
Re: Going through all windows -
The ingredients are in the posts above; you work it out.
__________________
Dear God So far today I've done all right. I haven't been grumpy yet. But in a few minutes, God, I'm going to get out of bed, and from then on I'm going to need a lot more help. AMEN |
|
|
|
|
|
#9 |
|
Programmer
Join Date: Dec 2007
Posts: 93
Rep Power: 2
![]() |
Re: Going through all windows -
Hmm, actually you gave me an idea. I could use EnumWindows(...) to enumarate all windows then can check to see if the current window in the enumaration function has the styles WS_VISIBLE and possibly WS_OVERLAPPED/WINDOW and then store the handles in a HWND vector for later use.
There is just two questions remaining - 1) First of all how can I stop the enumaration when all windows have been processed? Because to my understanding it keeps on going. 2) And last, is a folder window a top level one? Thanks. |
|
|
|
|
|
#10 |
|
Professional Programmer
Join Date: Oct 2005
Location: Chitown
Posts: 423
Rep Power: 4
![]() |
Re: Going through all windows -
If you have Visual Studio I suggest you play around with Spy++
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Typical Revisons from windows 2000 to windows xp | ronaldr | C++ | 2 | Nov 23rd, 2007 11:17 PM |
| looking for a good windows programming book | cwl157 | Coder's Corner Lounge | 3 | May 30th, 2007 7:51 AM |
| Search for and close open windows | badbasser98 | C++ | 13 | Feb 27th, 2006 1:04 PM |
| Windows Vista, well sort of | coldDeath | Coder's Corner Lounge | 21 | Sep 6th, 2005 2:00 PM |
| Net Group /ADD (on a windows box, non domain controller) | Infinite Recursion | Other Programming Languages | 1 | Apr 13th, 2005 3:27 PM |