Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

hWnd to window state

Posted on 2000-03-26
4
Medium Priority
?
433 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

610 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