M
MeistersingerVonNurnberg
Hi - Trying to activate an app that may or may not be minimized. Thought I
might be able to use the GetWindowPlacement api call, but it keeps crashing.
Likely due to my calculation of the WINDOWPLACEMENT struct / type size. Below
is the code of what I am doing. Any ideas?
' WinAPI structured type declarations.
Type POINTAPI
X As Integer
Y As Integer
End Type
Type RECT
Left As Integer
Top As Integer
Right As Integer
Bottom As Integer
End Type
Type WINDOWPLACEMENT
length As Integer
flags As Integer
showCmd As Integer
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
' WinAPI function declarations.
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Integer
Public Declare Function GetWindowPlacement Lib "user32" (ByVal hWnd As
Integer, ByRef lpwndpl As WINDOWPLACEMENT) As Integer
Public Declare Function SetWindowPlacement Lib "user32" (ByVal hWnd As
Integer, ByRef lpwndpl As WINDOWPLACEMENT) As Integer
Sub Some_Sub()
Dim lRC As Long
Dim hWnd As Integer
Dim wp As WINDOWPLACEMENT
hWnd = FindWindow(vbNullString, "UltraEdit - [file.txt]")
If hWnd = 0 Then GoTo gto_Exit_Function
wp.length = Len(wp)
lRC = GetWindowPlacement(hWnd, wp) ' ==> CRASHES HERE; MAYBE B/C OF LEN
CALC ABOVE? <==
If lRC = 0 Then GoTo gto_Exit_Function
gto_Exit_Function:
If Err Then Err.Clear
End Sub
might be able to use the GetWindowPlacement api call, but it keeps crashing.
Likely due to my calculation of the WINDOWPLACEMENT struct / type size. Below
is the code of what I am doing. Any ideas?
' WinAPI structured type declarations.
Type POINTAPI
X As Integer
Y As Integer
End Type
Type RECT
Left As Integer
Top As Integer
Right As Integer
Bottom As Integer
End Type
Type WINDOWPLACEMENT
length As Integer
flags As Integer
showCmd As Integer
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
' WinAPI function declarations.
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Integer
Public Declare Function GetWindowPlacement Lib "user32" (ByVal hWnd As
Integer, ByRef lpwndpl As WINDOWPLACEMENT) As Integer
Public Declare Function SetWindowPlacement Lib "user32" (ByVal hWnd As
Integer, ByRef lpwndpl As WINDOWPLACEMENT) As Integer
Sub Some_Sub()
Dim lRC As Long
Dim hWnd As Integer
Dim wp As WINDOWPLACEMENT
hWnd = FindWindow(vbNullString, "UltraEdit - [file.txt]")
If hWnd = 0 Then GoTo gto_Exit_Function
wp.length = Len(wp)
lRC = GetWindowPlacement(hWnd, wp) ' ==> CRASHES HERE; MAYBE B/C OF LEN
CALC ABOVE? <==
If lRC = 0 Then GoTo gto_Exit_Function
gto_Exit_Function:
If Err Then Err.Clear
End Sub