|
Post by retromidi on Sept 24, 2014 2:41:40 GMT -5
How can runBASIC get the window/screen size? This is needed so that graphics can for example: be centered, not bleed off the window/screen.
|
|
neal
Full Member
 
Posts: 104
|
Post by neal on Sept 25, 2014 0:53:21 GMT -5
This is something rough I just threw together (it will need changes to work with IE):
Note that the screen size is not available until you get to the second screen of the application.
Main program:
html "<script type=""text/javascript"">var x=window.innerWidth; var y=window.innerHeight; r = new XMLHttpRequest(); r.open('GET', 'https://www.mysite.com/seaside/go/runbasicpersonal?app=ajaxtest&x=' + x + '&y=' + y, false); r.send();</script>"
button #go, "Get Screen Size", [go] wait
[go] cls sqliteconnect #db, "size.db" #db execute("SELECT X,Y FROM TEMP_TABLE") #row = #db #nextrow() x = #row x() y = #row y() #db disconnect()
print "screen height = "; y print "screen width = "; x
"ajaxtest.bas":
x = val(getUrlParam$(UrlKeys$, "x")) y = val(getUrlParam$(UrlKeys$, "y"))
sqliteconnect #db, "size.db" #db execute("DROP TABLE TEMP_TABLE") #db execute("CREATE TABLE TEMP_TABLE (x, y)") #db execute("INSERT INTO TEMP_TABLE(X,Y) VALUES ("; x; ","; y; ")") #db disconnect()
function getUrlParam$(params$, key$) ' Return the value of the URL parameter key$ while 1 i = i + 1 w$ = word$(params$, i, "&") if w$ = "" then exit while k$ = word$(w$, 1, "=") if upper$(key$) = upper$(k$) then getUrlParam$ = word$(w$, 2, "=") exit while end if next end function
|
|