Solved

hWnd to window state

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

776 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