Solved

hWnd to window state

Posted on 2000-03-26
4
414 Views
Last Modified: 2008-02-20
is there an api that will take an hWnd and give me the windows state? If so what is it?
0
Comment
Question by:hess
  • 2
4 Comments
 

Accepted Solution

by:
TheMask earned 50 total points
ID: 2659618
"IsIconic" method determines if the window is minimized or maximized

Declaration:
Private Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long

Usage:
use the hWnd of the window as the input parameter.

Return:
0 Window is maximized
1 Window is minimized
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2659641
Use GetWindowPlacement is you want to distinguish between a normal and maximized window.

Example:

Option Explicit
Const SW_HIDE = 0
Const SW_SHOWMAXIMIZED = 3
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWNORMAL = 1
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
Private Type POINTAPI
    x As Long
    y 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 lhWnd As Long
    Dim wp As WINDOWPLACEMENT
    wp.Length = Len(wp)
   
    'Valid Window handle
    lhWnd = Me.hwnd
   
    Call GetWindowPlacement(lhWnd, wp)
    Select Case wp.showCmd
    Case SW_HIDE
        Caption = "SW_HIDE"
    Case SW_SHOWNORMAL
        Caption = "Normal"
    Case SW_SHOWMINIMIZED
        Caption = "Min"
    Case SW_SHOWMAXIMIZED
        Caption = "Max"
    Case Else
        Caption = "wp.showCmd = " & CStr(wp.showCmd)
    End Select
End Sub
0
 

Author Comment

by:hess
ID: 2661984
I guess that the answer asnwers my question so i will accepted it. I was looking to see if a windo was visable. Thanks
0
 

Author Comment

by:hess
ID: 2661995
forgot to accept it... sorry
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now