Find HWND from Class

Just starting out? Need help? Post your questions and find answers here.
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Find HWND from Class

Post by cecilcheah »

Is it possible to find the hwnd from ClassName, not from the Window Text?

Cecil
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Find HWND from Class

Post 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?
Good programmers don't comment their code. It was hard to write, should be hard to read.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Find HWND from Class

Post 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. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: Find HWND from Class

Post 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.
ARGENTINA WORLD CHAMPION
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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.
BERESHEIT
Post Reply