Re: API Help: GetWindowPlacement
I am having the very same problem and would like to see the answer too. :eek: I can not find a VB.Net GetWindowPlacement method or example. I have looked everwhere and here lies a resolved answer to the same question that is, well, not answered....
Could someone make this VB.Net friendly or give a .net method that will find the windowstate of a known window? (not my VB.Net application)
I would like to be able to determine windowstate for a different application.
____________________
Public Declare Function GetWindowPlacement Lib "user32.dll" ( ByVal hwnd As IntPtr, ByRef lpwndpl As WINDOWPLACEMENT) As Integer
It is the WINDOWPLACEMENT that VB.Net does not like ....I am not sure why or how to make the type...
_________________________________
If there is a different way that would be great too.
I do not want to actually deal with size(width/hight position etc) just the window state(maximized/minimized/normal) as clean as possible.
Thank You.
Re: API Help: GetWindowPlacement
Create a structure called WINDOWPLACEMENT:
VB Code:
'for vb6
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Sub Command1_Click()
Dim wp As WINDOWPLACEMENT
wp.Length = Len(wp)
GetWindowPlacement targetHandle, wp
End Sub
Re: API Help: GetWindowPlacement
for .NET
VB Code:
Imports System.Runtime.InteropServices
Private Structure POINTAPI
Public x As Integer
Public y As Integer
End Structure
Private Structure RECT
Public Left As Integer
Public Top As Integer
Public Right As Integer
Public Bottom As Integer
End Structure
Private Structure WINDOWPLACEMENT
Public Length As Integer
Public flags As Integer
Public showCmd As Integer
Public ptMinPosition As POINTAPI
Public ptMaxPosition As POINTAPI
Public rcNormalPosition As RECT
End Structure
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Integer, ByRef lpwndpl As WINDOWPLACEMENT) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim wp As WINDOWPLACEMENT
wp.Length = Marshal.SizeOf(wp)
Dim x As Integer
x = GetWindowPlacement(&H1075C, wp)
End Sub
the window state should be in wp.showCmd
Re: API Help: GetWindowPlacement
Excellent. Thank you.
I am sur this will come in handy for others...