CONSOLE GET LOC statement

Purpose

Retrieve the location of the console window on the screen.

Syntax

CONSOLE GET LOC TO x&, y&

Remarks

The location is a pixel coordinate relative to the upper left corner of the screen. This statement can be especially useful in conjunction with CONSOLE GET SIZE and GRAPHIC WINDOW, for exact positioning of graphic windows with respect to the console window.

See also

CONSOLE GET SCREEN, CONSOLE GET SIZE, CONSOLE GET VIEW, CONSOLE GET VIRTUAL, CONSOLE SET LOC, CONSOLE SET SCREEN, CONSOLE SET VIEW, CONSOLE SET VIRTUAL

Example

FUNCTION PBMAIN () AS LONG

 ' Center a graphic window within a console window

  LOCAL x, y, w, h AS LONG, hWin AS DWORD

  CONSOLE GET LOC TO x, y    ' Console pos on screen

  CONSOLE GET SIZE TO w, h   ' Console size

  x = x + (w - 200) / 2      ' Calculate center x pos

  y = y + (h - 200) / 2      ' Calculate center y pos

  GRAPHIC WINDOW "Box", x, y, 200, 200 TO hWin

  GRAPHIC ATTACH hWin, 0

  GRAPHIC BOX (10, 10) - (190, 190), 0, %RED

  SLEEP 5000  ' show it for 5 seconds, then end

END FUNCTION