Results 1 to 3 of 3

Thread: GetWindowPlacement Api

  1. #1

    Thread Starter
    Hyperactive Member Skatebone's Avatar
    Join Date
    Jan 2009
    Location
    Malta
    Posts
    279

    Smile 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
    Life runs on code

  2. #2

    Thread Starter
    Hyperactive Member Skatebone's Avatar
    Join Date
    Jan 2009
    Location
    Malta
    Posts
    279

    Re: GetWindowPlacement Api

    Nvm solved

    Pinvoke does magics with api xD
    Life runs on code

  3. #3
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    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.
    VB 2005, Win Xp Pro sp2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width