Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
Traverse the global list of all windows Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
03-Sep-02
Category
Win API
Language
Delphi 2.x
Views
41
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Tomas Rutkauskas
Traverse the global list of all windows

Answer:

Sometimes you may want to do something with all windows (and controls) on the 
screen, including non-Delphi windows.

For such a purpose, you will use the API function EnumWindows. The following code 
includes the calls MakeProcInstance/ FreeProcInstance, which are needed in 
16bit-Windows (including Delphi 1 under Win95).

This sample code hides every existing window.. a rather useless example, but after 
all, it's just an example.

1   
2   function NextWindow(Wnd: HWnd; Form: TForm1): Boolean; export;
3   {$IFDEF Win32} stdcall;
4   {$ENDIF}
5   begin
6     ShowWindow(Wnd, SW_HIDE);
7     NextWindow := true; { next window, please }
8   end;
9   
10  procedure TForm1.Sample;
11  var
12    EnumProc: TFarProc;
13  begin
14    { this works in Win32 }
15    EnumWindows(@NextWindow, LongInt(Self));
16  
17    { MakeProcInstance for Win16 }
18    EnumProc := MakeProcInstance(@NextWindow, HInstance);
19    EnumWindows(EnumProc, 0);
20    FreeProcInstance(EnumProc);
21  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC