Hi,
There is an API called 'FindWindow'. I want to know how to use it.
It returns the HWND of the window, but I don't know what parameters to pass for Class Name and Window Name
Help!
Printable View
Hi,
There is an API called 'FindWindow'. I want to know how to use it.
It returns the HWND of the window, but I don't know what parameters to pass for Class Name and Window Name
Help!
Borrowed From Hack...
[vbcpde]
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_CLOSE = &H10
Private Const WM_QUIT = &H12
Dim CloseIt As Long
CloseIt = FindWindow(vbNullString, "Caption Of Window To Be Closed")
PostMessage CloseIt, WM_CLOSE, CLng(0), CLng(0)
[/Highlight]
The first parameter of the FindWindow API doesn't have to be vbNullString. It can be the class name of the window you are searching.
Whats the class name. In VC++ is it the name of the class I give for 'CFrameWnd' when I use MFC
No, those are only MFC classes.
For example, different windows have different types class names.
BUTTON - button window
#32770 - Dialog windows
LISTBOX - list box
You can give windows your own class names when you create them using CreateWindow API. VB windows have class names like ThunderRT6TextBox etc.
You can also use Spy++ (comes with MSVC++) to find the class names for different windows.