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
