Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-31-2004, 06:18 AM
Chesso Chesso is offline
Senior Member
 
Join Date: May 2004
Location: Sydney, Australia
Posts: 1,199
Default Get list of open windows.

atm my screen cap program you have to type in the windows name and then take a ss. I was thinking maybe displaying a list of open windows would be a better idea.

Ive done something similar to this in vb except it was a Module written by someone else so im not too sure.

Anybody know how i could do this?
Reply With Quote
  #2  
Old 05-31-2004, 06:24 AM
Dexx Dexx is offline
Member
 
Join Date: Jan 2001
Posts: 75
Default RE: Get list of open windows.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/enumwindows.asp

And here's an example

http://www.delphipages.com/threads/thread.cfm?ID=88623&G=88621

Hope helps,
Dexx
Reply With Quote
  #3  
Old 05-31-2004, 06:46 AM
Chesso Chesso is offline
Senior Member
 
Join Date: May 2004
Location: Sydney, Australia
Posts: 1,199
Default RE: Get list of open windows.

ummm.... dam i dont understand a single thing going in those lol.

Could someone show me an example of what i need to pass to EnumWindows function.
Reply With Quote
  #4  
Old 05-31-2004, 07:11 AM
Masi Masi is offline
Senior Member
 
Join Date: Nov 2003
Posts: 129
Default RE: Get list of open windows.

You can enumerate all windows. Here is how I do it:
function AllWindows(wHnd: THandle; List: TStringList): Bool; stdcall;
var Buffer: array[0..255] of char;
begin
SendMessage(wHnd, WM_GETTEXT, 255, LongInt(@Buffer[0]));
if (Buffer <> '') and IsWindow(wHnd) then
begin
List.AddObject(Buffer, TObject(wHnd));
end;
Result := True; // continiue enumeration
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Clear;
EnumWindows(@AllWindows, LParam(ListBox1.Items));
end;

Now you can retrieve Handle of any window in your ListBox.
wHnd: THandle;
Index: integer;
...
Index := ListBox1.ItemIndex;
wHnd := THandle(ListBox1.Items.Objects[Index]);


Hope it can help



Masi X
Reply With Quote
  #5  
Old 05-31-2004, 07:41 AM
Chesso Chesso is offline
Senior Member
 
Join Date: May 2004
Location: Sydney, Australia
Posts: 1,199
Default RE: Get list of open windows.

omg i tried this myself and i couldnt get it to work no matter what :|

but i started a new proj added listbox n button slapped that code in and works perfect thnx man
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 05:56 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.