Home   Archive   Permalink



Can a VID window find out where it is located?

I have a feeling I know the answer, but I just can't remember...
    
I know that one can position a window to a specified location:
view layout/offset [...] 100x100
    
I know that a program can find the screen size of the monitor with system/view/screen-face/size.
    
What I want to do is to find out where a window currently is located, in case the operator dragged it around on the screen. If I can find that, then I can save it when the program quits, and load it when the program starts again, so that I can view the window in the same position where it was the last time the program ran. Something like:
NEW-POSITION: load %last-window-position.txt
view layout/offset [...] NEW-POSITION
    
Thank you.

posted by:   Steven White       22-Mar-2016/11:00:31-7:00



Sorry to bother. It seems that answers come to me after I have gone through the work of formulating the question. Here is the answer, and I will write it down so I don't forget it:
    
R E B O L [
     Title: "VID test harness"
]
    
LAST-LOC-FILE: %last-location.txt
LAST-LOC: 20X20
    
WHERE-AM-I: does [
     print ["I am at " MAIN-WINDOW/offset]
]
    
QUIT-BUTTON: does [
     LAST-LOC: MAIN-WINDOW/offset
     save LAST-LOC-FILE LAST-LOC
     quit
]
    
if exists? LAST-LOC-FILE [
     LAST-LOC: load LAST-LOC-FILE
]
    
MAIN-WINDOW: layout/offset [
     banner "Find my location"
     button 200 "Where am I" [WHERE-AM-I]
     button 200 "Quit" [QUIT-BUTTON]
] LAST-LOC
    
view MAIN-WINDOW

posted by:   Steven White       22-Mar-2016/11:30:13-7:00