Basic Univers
; Autor  : Dr. Dri
; Date   : 03/08/2006
; Version: PB4

; Description : obtenir la taille réelle d'une fenêtre (largeur et hauteur)



Procedure.l WindowRealWidth(Window.l, Width.l = #PB_Default)
  Protected WindowID.l, Style.l, rc.Rect
  
  If IsWindow(Window)
    WindowID = WindowID(Window)
    Style = GetWindowLong_(WindowID, #GWL_STYLE)
    
    If Width > #PB_Default
      rc\right = Width
    Else
      rc\right = WindowWidth(Window)
    EndIf
    
    If AdjustWindowRect_(rc, Style, GetMenu_(WindowID))
      Width = rc\right - rc\left
    EndIf
  EndIf
  
  ProcedureReturn Width
EndProcedure

Procedure.l WindowRealHeight(Window.l, Height.l = #PB_Default)
  Protected WindowID.l, Style.l, rc.Rect
  
  If IsWindow(Window)
    WindowID = WindowID(Window)
    Style = GetWindowLong_(WindowID, #GWL_STYLE)
    
    If Height > #PB_Default
      rc\bottom = Height
    Else
      rc\bottom = WindowHeight(Window)
    EndIf
    
    If AdjustWindowRect_(rc, Style, GetMenu_(WindowID))
      Height = rc\bottom - rc\top
    EndIf
  EndIf
  
  ProcedureReturn Height
EndProcedure

If OpenWindow(0, 0, 0, 320, 240, "")
  
  ; taille réelle de la fenêtre
  Debug WindowRealWidth(0)
  Debug WindowRealHeight(0)
  
  Debug "---"
  
  ; taille réelle de la fenêtre si sa taille était 600*400
  Debug WindowRealWidth(0, 600)
  Debug WindowRealHeight(0, 400)
  
EndIf