[C#]
hi!
is it possible to find a control within a window by the instance and not by the name. the name may differ in other windows language, but the instance may always be the same number.
thanks in advance.
[C#]
hi!
is it possible to find a control within a window by the instance and not by the name. the name may differ in other windows language, but the instance may always be the same number.
thanks in advance.
By "instance" you mean the reference (like pointer)?
If so then I suppose your question is to check if that control exists in a window (if you want the control, you already have it )
Try:
Code:MyForm.Controls.Contains(MyControl); //Returns true if MyForm has MyControl
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
i'm talking about >>WinApi<<. I need to hook another window which contains a listview and find this listview. it has a name, but it differs in each language.
You're trying to find the main window, or the listview's HWND?
You can try to find the window (in whatever language) by name, then see what it has for a window class. You can only search by title or by window class, so hopefully you can do a search by class.
Edit:
Also, you could always enumerate all windows, go through the list, and using GetWindowThreadProcessId and GetModuleFileNameEx you can get the name of the process that spawned the window.
Last edited by Cat; 02-26-2010 at 02:45 PM.
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.
To get the HWND of the listview you can use its Control ID in conjunction with GetDlgItem() (where hDlg is the listviews parent handle, and nIDDlgItem is the Control ID of the listview). Since the Control ID will stay the same in most applications, it's easier to check for that then to check for window names (which could change as you mentioned). And if there are multiple listview controls on a form then it is easier to check for the Control ID rather than the Class Name since the Control ID is unique to each control.
You can get the Control ID of the listview using something like Spy++.
Last edited by HLMetroid; 02-26-2010 at 08:46 PM.
wow it really works!
I enter the control ID (instead of Hinstance) and i found the control!
thanks guys!