Enumwindows

  • Thread starter Thread starter Wayne
  • Start date Start date
W

Wayne

I have some code written in delphi that uses EnumWindows, I would like to
begin to translate this code to C#. Is there a built in EnumWindows call in
Csharp? or do I have to import the API and use it that way?

Thanks
Wayne
 
You have to use DllImport

[DllImport("user32")]
public static extern int EnumWindows(EnumWindowsCB cb, int lparam);
 
I am sorry for the stupid question, but what does EnumWindows do? Gives you
a list of each MDI Child window? Each Form? Each Application?

Telmo Sampaio
 
It will give you a list of every top level window on the current desktop.
From there for each window you can call EnumChildWindow recursivly which
will give you a list of each of the child windows.

Thanks
Wayne
 
No problem importing it, just wanted to make sure I had to, what about the
following:

EnumChildWindows
GetWindowtext
GetWindow
SendMessage
PostMessage
SetCursorPos

The Help in VS.net is great, just its VERY BIG and sometimes hard to find
exactly what you need.

Thanks
Wayne



Shakir Hussain said:
You have to use DllImport

[DllImport("user32")]
public static extern int EnumWindows(EnumWindowsCB cb, int lparam);

--
Shak
(Houston)


Wayne said:
I have some code written in delphi that uses EnumWindows, I would like to
begin to translate this code to C#. Is there a built in EnumWindows call in
Csharp? or do I have to import the API and use it that way?

Thanks
Wayne
 
a) SetCursorPos

Cursor.Position.X = 50;
Cursor.Position.Y = 50;

b)GetWindow

IntPtr handle = //set handle here
Form myForm = Form.FromHandle(handle );

c)GetWindowText

IntPtr handle = //set handle here
Form myForm = Form.FromHandle(handle );
string Title = myForm.Text;

d) EnumChildWindows, SendMessage and Postmessage can be used using DllImport

--
Shak
(Houston)



Wayne said:
No problem importing it, just wanted to make sure I had to, what about the
following:

EnumChildWindows
GetWindowtext
GetWindow
SendMessage
PostMessage
SetCursorPos

The Help in VS.net is great, just its VERY BIG and sometimes hard to find
exactly what you need.

Thanks
Wayne



Shakir Hussain said:
You have to use DllImport

[DllImport("user32")]
public static extern int EnumWindows(EnumWindowsCB cb, int lparam);

--
Shak
(Houston)


Wayne said:
I have some code written in delphi that uses EnumWindows, I would like to
begin to translate this code to C#. Is there a built in EnumWindows
call
in
Csharp? or do I have to import the API and use it that way?

Thanks
Wayne
 
Thanks Wayne! I am no good with Win32 APIs... I always cheated using (what's
his name? Petzold?)'s API book.

Telmo Sampaio
 
a) x,y are marked as read only so that won't work
b) the form may not be in my app, when I run this code using a handle that I
know exists I get back a null refferance.
c) see b
d) cool I'll get that converted

Any other ideas?

Thanks
Wayne
 
I played with the Cursor.Postion a bit more, turns out I have to create a
new Point and assign the postion property the point. So I am good there.
Just need to know how to find a window and get it's text if its not in my
app and possible that it's not a .net app.

Thanks
Wayne
 
Thanks to everyone for their hints and help. I got Enumwindows working over
the weekend.

Thanks
Wayne
 
Back
Top