VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



How to receive a ClassName and handle(HWND)of a given application and how to hide, show, minimize o

by Richard Cemus (2 Submissions)
Category: Windows System Services
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Fri 11th February 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

How to receive a ClassName and handle(HWND)of a given application and how to hide, show, minimize or maximize other applications directly from

API Declarations


Private Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_HIDE = 0
Private Const SW_SHOW = 5
Private Const SW_MAXIMIZE = 3
Private Const SW_MINIMIZE = 6
Private Const SW_NORMAL = 1


Rate How to receive a ClassName and handle(HWND)of a given application and how to hide, show, minimize o



Dim retval As Long, retval1 As Long
Dim s As String
s = Space(255)
retval = FindWindow(vbNullString, Text1.Text)
retval1 = GetClassName(retval, s, 255)
List1.AddItem "Window name:  " & Text1.Text
List1.AddItem "Window Hwnd:  " & retval
List1.AddItem "Classname:  " & s
List1.AddItem "Characters:  " & retval1
End Sub
Private Sub Form_Load()
Command1.Default = True
End Sub
Private Sub Option1_Click(Index As Integer)
Dim retval As Long, retval1 As Long, retval2 As Long
s = Space(255)
retval = FindWindow(vbNullString, Text1.Text)
retval1 = GetClassName(retval, s, 255)
If Option1.Item(0) Then
retval2 = ShowWindow(retval, SW_SHOW)
End If
If Option1.Item(1) Then
retval2 = ShowWindow(retval, SW_MINIMIZE)
End If
If Option1.Item(2) Then
retval2 = ShowWindow(retval, SW_HIDE)
End If
If Option1.Item(3) Then
retval2 = ShowWindow(retval, SW_MAXIMIZE)
End If
End Sub

Download this snippet    Add to My Saved Code

How to receive a ClassName and handle(HWND)of a given application and how to hide, show, minimize o Comments

No comments have been posted about How to receive a ClassName and handle(HWND)of a given application and how to hide, show, minimize o. Why not be the first to post a comment about How to receive a ClassName and handle(HWND)of a given application and how to hide, show, minimize o.

Post your comment

Subject:
Message:
0/1000 characters