! Deschide fereastra principala centrata
logical function CenterWindow()	!(qwinfo)

use dflib
type(qwinfo) winfo
!TYPE QWINFO
!  INTEGER(2) TYPE  ! request type (controls SETWSIZEQQ)
!  INTEGER(2) X     ! x coordinate for upper left
!  INTEGER(2) Y     ! y coordinate for upper left
!  INTEGER(2) H     ! window height
!  INTEGER(2) W     ! window width
!END TYPE QWINFO

! winfo%type:
!QWIN$MIN - Minimizes the window. 
!QWIN$MAX - Maximizes the window. 
!QWIN$RESTORE - Restores the minimized window to its previous size. 
!QWIN$SET - Sets the window's position and size according to the other values in qwinfo. 

integer unit
LOGICAL(4) status
TYPE (windowconfig) wc
!  INTEGER(2) numxpixels    ! Number of pixels on x-axis.
!  INTEGER(2) numypixels    ! Number of pixels on y-axis.

status = GETWINDOWCONFIG(wc)

! Get values for main window:
unit = QWIN$FRAMEWINDOW
ireq = QWIN$SIZECURR
result = GETWSIZEQQ (unit, ireq, winfo) 


! Fill winfo:
winfo%type =QWIN$SET
! Window dimensions are default ones:
!winfo%h = ...
!winfo%w = ...

! Calculate centered position:
winfo%x = (wc%numXpixels - winfo%w)/int2(2)
winfo%y = (wc%numYpixels - winfo%h)/int2(2) - 30	! Allow 3*10 pixels for bars


unit = QWIN$FRAMEWINDOW
result = SetWSizeqq(unit, winfo)
CenterWindow = .true.

end function CenterWindow



