Page 1 of 1

Find HWND from Class

Posted: Wed Sep 21, 2005 9:24 pm
by cecilcheah
Is it possible to find the hwnd from ClassName, not from the Window Text?

Cecil

Re: Find HWND from Class

Posted: Wed Sep 21, 2005 9:53 pm
by traumatic
This should be possible with FindWindowEx_().

If the last parameter "lpszWindow" is #NULL, all window names will
match thus only the 3rd parameter "lpszClass" will be used.

Is that what you're after?

Re: Find HWND from Class

Posted: Thu Sep 22, 2005 4:15 am
by PB
> Is it possible to find the hwnd from ClassName, not from the Window Text?

The FindWindow API has two parameters: title and class. Take your pick. :)

Re: Find HWND from Class

Posted: Thu Sep 22, 2005 4:37 am
by ricardo
cecilcheah wrote:Is it possible to find the hwnd from ClassName, not from the Window Text?

Cecil
Yes, like this:

Code: Select all

Handle = FindWindow_("XClass", 0)
Replace XClass with the one you are looking for.

Posted: Thu Sep 22, 2005 5:43 am
by netmaestro
Just don't forget that there can be multiple windows of the same class up at any given time, so if you are going by class only you will need to iterate through all the windows it finds to get the one you want. Unless you are looking for a window with a classname you have registered and you know to be unique, of course.