CENTER statement

Purpose: CENTER displays the control centered on screen, on a window or in a position relative to the vertical and/or horizontal midpoint of a window. In calculating the vertical component of CENTER, the area of the system TaskBar is taken into account.


 Syntax 1:

 CENTER(hWnd)

 Parameters:

  • hWnd Handle to control to be centered.

 Syntax 2:

 CENTER(hWnd [, X_hWnd])

 Parameters:

  • hWnd Handle to control to be centered.
  • X_hWnd [OPTIONAL] handle to control on which hWnd is to be centered.

 Syntax 3:

 CENTER(hWnd [, X_hWnd] [, Y_hWnd])

 Parameters:

  • hWnd Handle to control to be centered.
  • X_hWnd [OPTIONAL] first handle to control on which hWnd is to be horizontally centered.
  • Y_hWnd [OPTIONAL] second handle to control on which hWnd is to be vertically centered.

Remarks:

Most times, we want to center a form on the screen,


 CENTER(Form)

but sometimes we want to center one form on another form,


 CENTER(Form1, Form2)

and sometimes we want to use our current Y position with a new X position,


 CENTER(Form1,Form2,Form1)

and sometimes(albeit rarely), we may want to center between two forms.


 CENTER(Form1,Form2,Form3)

Example 1:


 GUI "Test_New_Center"

 SUB FORMLOAD
  LOCAL Form1 AS Control
  LOCAL Form2 AS Control
  LOCAL Form3 AS Control
  ' *********************************************************************
  Form1 = BCX_FORM("X~Dialog" , 100, 10, 80, 80)
  Form2 = BCX_FORM("Y~Dialog" , 385, 165, 80, 80)
  Form3 = BCX_FORM("Centered Dialog", 10, 200)
  ' *********************************************************************
  ' Uncomment -ONE- of the following example usages then re-compile
  ' *********************************************************************
  ' CENTER(Form3) 'Center Form3 On Screen(Classic Form)
  ' CENTER(Form3,Form2) 'Center Form3 On Form2
  CENTER(Form1,Form3) 'Center Form1 On Form3
  ' *******************************************
  CALL SHOW(Form3)
  CALL SHOW(Form2)
  CALL SHOW(Form1)
 END SUB

 BEGIN EVENTS
 END EVENTS

Example 2:


 GUI "Test_New_Center"

 SUB FORMLOAD
  LOCAL Form1 AS Control
  LOCAL Form2 AS Control
  LOCAL Form3 AS Control
  ' *********************************************************************
  Form1 = BCX_FORM("X~Dialog" , 100, 10, 80, 80)
  Form2 = BCX_FORM("Y~Dialog" , 385, 165, 80, 80)
  Form3 = BCX_FORM("Centered Dialog", 10, 200)
  ' *********************************************************************
  ' Uncomment -ONE- of the following example usages then re-compile
  ' *********************************************************************
  ' CENTER(Form3) 'Center Form3 On Screen(Classic Form)
  ' CENTER(Form3,Form2) 'Center Form3 On Form2
  CENTER(Form3,Form1,Form2) 'Center Form3 On Form1(x) AND Form2(y)
  ' *********************************************************************
  CALL Show(Form1)
  CALL Show(Form2)
  CALL Show(Form3)
 END SUB

 BEGIN EVENTS
 END EVENTS

Example 3:


 GUI "Test"

 SUB Formload
  DIM Form AS Control
  DIM Butt AS Control
  Form = Bcx_Form("Test")
  Butt = Bcx_Button("Button", Form, 123, 0, 0)
  CENTER(Butt,Form)  'CENTER Button on Form
  SHOW(Form)
 END SUB

 BEGIN EVENTS
 END EVENTS