CISA FotoGallery

Statistiche

Tot. visite contenuti : 927953
Home Articoli tecnici API Determinare il WinStyle di una Finestra

Determinare il WinStyle di una Finestra

Per determinare lo stato di visualizzazione di una qualsiasi finestra che esponga HWND serve ricorrere alle API GetWindowPlacement.

CODICE

Option Compare Database
Option Explicit

Private Declare Function
GetWindowPlacement Lib "user32.dll" _
   (ByVal hwnd As Long, _
   lpwndpl As WINDOWPLACEMENT) As Long

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

'// ShowWindow() flags
Private Const SW_HIDE = 0
Private Const SW_SHOWNORMAL = 1
Private Const SW_NORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_MAXIMIZE = 3
Private Const SW_SHOWNOACTIVATE = 4
Private Const SW_SHOW = 5
Private Const SW_MINIMIZE = 6
Private Const SW_SHOWMINNOACTIVE = 7
Private Const SW_SHOWNA = 8
Private Const SW_RESTORE = 9
Private Const SW_SHOWDEFAULT = 10
Private Const SW_MAX = 10

Private Function GetWindowsState(test_hwnd As Long) As Integer
   Dim
currWinP As WINDOWPLACEMENT
   GetWindowPlacement test_hwnd, currWinP
   
   Select Case currWinP.showCmd
      Case SW_SHOWMINIMIZED
         MsgBox "SW_SHOWMINIMIZED"
      Case SW_SHOWNORMAL
         MsgBox "SW_SHOWNORMAL"
      Case SW_SHOWMAXIMIZED
         MsgBox "SW_SHOWMAXIMIZED"
      'Case ......
      
      
Case Else
      
   End Select
   
GetWindowsState = currWinP.showCmd
End Function


Link a MSDN:      
GetWindowPlacement


Ovviamente è anche possibile impostarne le condizioni usando SetWindowPlacement.

Link a MSDN:      
SetWindowPlacement


Alessandro