-- getsysms.ew: implementation of GetSystemMetrics
-- function returns width and height of total screen
-- to be used as nWidth and nHeight in create()
-- 6th and 7th element of this function
-- most of the code 'taken' from Jacques Deschênes
-- Ad Rienks, September 13, 1998

include dll.e
include msgbox.e

integer ok

constant OpenFailed = "Failed to open user32.dll"
constant DefineFailed = "Failed to define one of user32 functions."
constant FatalErr = "Fatal error in getsysms.ew"

-- make sure the DLL is actually open. ( usually is, anyways ! )
constant user32 = open_dll("user32.dll")
    
-- report an error, and abort, if not...
if not user32 then
    ok = message_box(OpenFailed, FatalErr, 0)
    abort(1)
end if

-- create a link to the GetSystemMetrics function in user32.dll.
constant iGetSystemMetrics = define_c_func(user32, "GetSystemMetrics",
                                            {C_INT}, C_INT)

-- report an error if the above fails.
if iGetSystemMetrics = -1 then
    ok = message_box(DefineFailed, FatalErr, 0)
    abort(1)
end if

-- this is the function our demo calls.
global function GetSystemMetrics(integer Screen)
    return c_func(iGetSystemMetrics, {Screen})
end function

