?
Solved

hWnd to window state

Posted on 2000-03-26
4
Medium Priority
?
430 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Accepted Solution

by:
TheMask earned 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month7 days, 22 hours left to enroll

765 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