Smart Window placement
2 posters
Page 1 of 1
Smart Window placement
This is an example of a way to save Window settings yet always display the whole window when the program opens.
sub OpenWindow()
local x
local y
x=150 : y=150
if (open(5,"/boot/home/config/settings/myprogram.settings"))then
line input #1 x$
line input #1 y$
close #1
x=val(x$)
y=val(y$)
if x<0 x=150
if y<0 y=150
if (x> peek("desktopwidth")-500) x=150
if y> (peek("desktopheight")-500) y=150
end if
window open x,y to x+500,y+500, "MainWindow", "myprogram"
// set up the Window
end sub
sub CloseWindow()
x= window get "MainWindow", "Position-X"
y= window get "MainWindow", "Position-y"
open #1,"/boot/home/config/settings/myprogram.settings","w"
print #1 str$(x)
print #1 str$(y)
close #1
window close "MainWindow"
return
end sub
sub OpenWindow()
local x
local y
x=150 : y=150
if (open(5,"/boot/home/config/settings/myprogram.settings"))then
line input #1 x$
line input #1 y$
close #1
x=val(x$)
y=val(y$)
if x<0 x=150
if y<0 y=150
if (x> peek("desktopwidth")-500) x=150
if y> (peek("desktopheight")-500) y=150
end if
window open x,y to x+500,y+500, "MainWindow", "myprogram"
// set up the Window
end sub
sub CloseWindow()
x= window get "MainWindow", "Position-X"
y= window get "MainWindow", "Position-y"
open #1,"/boot/home/config/settings/myprogram.settings","w"
print #1 str$(x)
print #1 str$(y)
close #1
window close "MainWindow"
return
end sub
Re: Smart Window placement
Looks pretty much like what I've been doing, except that you are hardcoding your window dimensions. I find it more flexible to put those dimensions into variables:
That way, I can later make the window 600 x 400 without much drama. Of course, if I sat down and did some actual planning instead of just starting to code and seeing what developed, I might not need to!
- Code:
WinWidth = 500
WinHeight = 500
That way, I can later make the window 600 x 400 without much drama. Of course, if I sat down and did some actual planning instead of just starting to code and seeing what developed, I might not need to!
clasqm- Posts : 5
Join date : 2015-04-21
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|