I'm trying to get a window handle on a child window in my process and the only information I have is the window class name. Are there any win32 functions I can use for that? I'm doing this from C#.
A bit more detail: This is a Visual Studio plugin, written in C#. So my process is visual studio, which has lots of windows. One of them has a window class "VsTipWindow". I don't know the immediate parent window of that window, all I have is the class name. Is there any way for me to get the window handle from just that?
The Win32 API provides no direct method for obtaining the window handle associated with a console application. However, you can obtain the window handle by calling FindWindow() . This function retrieves a window handle based on a class name or window name. Call GetConsoleTitle() to determine the current console title.
Either you want to take handle of your Own Application or some third party application if it is third party application then you can use FindWindow() function with window class name or by Window Name .
A Windows window is identified by a "window handle" ( HWND ) and is created after the CWnd object is created by a call to the Create member function of class CWnd . The window may be destroyed either by a program call or by a user's action. The window handle is stored in the window object's m_hWnd member variable.
FindWindow is the Win32 call you want for this (or FindWindowEx if there's more than one window with that particular class name, and FindWindow isn't returning the one you're looking for).
just additional information..
maybe it's useful to know that you can get the handle of a window from a point
WindowFromPoint
http://msdn.microsoft.com/en-us/library/ms633558(VS.85).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With