-- getWorkarea() code originally by Brian K. Broker - APR 2000

include win32lib.ew
without warning

constant
   zSystemParameters = registerw32Function( user32, "SystemParametersInfoA", {C_UINT, C_UINT, C_POINTER, C_UINT}, C_LONG),
   zSPI_SETWORKAREA = 47,
   zSPI_GETWORKAREA = 48

--

function getWorkarea()
-- Returns: sequence containing the coordinates of the work area,
-- expressed in virtual screen coordinates {x1,y1, x2,y2}
  atom workarea
  sequence wa_out

  -- get pointer for RECT structure to receive coordinates
  workarea = acquire_mem( 0,SIZEOF_RECT )

  -- call C function from user32.dll
  if not w32Func( zSystemParameters, {zSPI_GETWORKAREA, 0, workarea, 0} ) then
      warnErr( "getWorkarea:SystemParametersInfo failed" )
  end if

  -- set return sequence
  wa_out = { fetch( workarea, rectLeft ),  fetch( workarea, rectTop ),
             fetch( workarea, rectRight ), fetch( workarea, rectBottom ) }

  -- free pointer
  release_mem( workarea )

  return wa_out
end function

-- now, for our actual 'window' creation

sequence area
atom ok, x, y, cx, cy


-- get the size and location allowing for the taskbar
area=getWorkarea()
x = area[1]
y = area[2]
cx = area[3]-area[1]
cy = area[4] - area[2]

constant
Win=create( Window, " ", 0, x, y, cx, cy, 0)

setText(Win,"total 'working' area = " & sprintf("%d",cx)
          & " by " & sprintf("%d",cy) & " pixels")

WinMain(Win,Normal)
