|
-
Apr 30th, 2009, 02:49 PM
#1
Thread Starter
Hyperactive Member
GetWindowPlacement Api
Hey guys sorry for reposting after half an hour but got a new problem with this api in Vb9.
I Cant find what i am doing wrong xD
The Code works perfectly but im always getting the same value of 1 and 0. When the window is on i get a 1 and when the window is closed i get 0.
I need to know when the firm is Normal , Maximized or Minimized. Tnx alot 
Code:
Imports System.Runtime.InteropServices
Public Class Form1
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 FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
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
Dim iHwnd As Integer
iHwnd = FindWindow("notepad", vbNullString)
wp.Length = Marshal.SizeOf(wp)
Dim x As Integer
x = GetWindowPlacement(iHwnd, wp)
Me.Text = x
End Sub
End Class
-
Apr 30th, 2009, 02:50 PM
#2
Thread Starter
Hyperactive Member
Re: GetWindowPlacement Api
Nvm solved 
Pinvoke does magics with api xD
-
Apr 30th, 2009, 03:02 PM
#3
Re: GetWindowPlacement Api
It is a good habit to consult msdn too whenever you are trying to use an API: GetWindowPlacement Function.
This way you kind of learn to read C syntax but more importantly the remarks section there is often very helpful. Also, the list with related functions on the left can give you interesting new ideas to toy with other programs.
Then you 'cheat' with Pinvoke.net.
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
|