Solved

hWnd to window state

Posted on 2000-03-26
4
421 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 10 start screen issues 9 55
Excel VBA, find a string in a column, update a cell 7 86
How to make an ADE file by code? 11 94
pop out of webbrowser1 control vba6 5 25
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

856 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