|
-
Apr 10th, 2001, 08:22 PM
#1
I am new to Win32 API programming in Visual Basic and I need help with a specific call. This is the GetWindowPlacement call:
Declare Function GetWindowPlacement Lib "user32" Alias "GetWindowPlacement" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
I already understand that I must place in the first argument (target window's handle), but I have no idea what I must put in the second argument. I do know that I must define the WINDOWPLACEMENT type, but I am not sure at all as what to place in the 2nd argument field when calling. Please respond and enlighten me as to what to do. HELP!
-
Apr 11th, 2001, 10:49 AM
#2
Thanks!
-
Apr 12th, 2006, 10:13 PM
#3
New Member
Re: API Help: GetWindowPlacement
I am having the very same problem and would like to see the answer too. 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.
-
Apr 13th, 2006, 12:42 PM
#4
Frenzied Member
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
-
Apr 13th, 2006, 12:58 PM
#5
Frenzied Member
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
-
Apr 13th, 2006, 11:01 PM
#6
New Member
Re: API Help: GetWindowPlacement
Excellent. Thank you.
I am sur this will come in handy for others...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|