Page 1 of 1
Automatic resize of the stack when opening the app..........
Posted: Sun Jun 17, 2007 9:33 am
by LESTROSO
Hy to everybody,
i have a problem....
i don't know how to make an automatic resize of the stack when opening
the app , because i want my application is visible in any monitor at any
resolution or from 800x600 to 1024x768.........
do you have some code to help me please?
thank you,
Lestroso
Posted: Sun Jun 17, 2007 12:03 pm
by Mark
Dear lestroso,
In the card script of the mainstack of your projects, include the following script:
Code: Select all
on preOpenStack
set the rect of this stack to the screenRect
end preOpenStack
Now add a resizeStack handler.
Code: Select all
on resizeStack
-- update the locations and rects of all objects
end resizeStack
Suppose that you have a field and a button, your resizeStakc handler might look like this:
Code: Select all
on resizeStack
lock screen
put the rect of this cd into myRect
subtract 58 from last item of myRect
set the rect of fld 1 to myRect
set the top of btn 1 to the bottom of fld myRect + 13
set the right of btn 1 to the width of this cd - 13
pass resizeStack -- only if necessary
unlock screen
end resizeStack
One word of warning, though. In a time where most screens measure 17" or more, with resolutions of 1600x1200 and more, a full-screen application easily looks very awkward and unusual, while taking over someone's screen is not very polite. Please think twice before making a full-screen application.
Best regards,
Mark
Posted: Sun Jun 17, 2007 5:05 pm
by LESTROSO
Thank you mark!!
But, for each object do i must write the code you said?
Can i set from ide in the property window for an automatic resize?
because for each card i have used several objects and for me it's a little
complicated to write the code but i'll try your code...
And i would like that just when the application start the window and the object resize properly .
Can i put just this code? to resize the window on start?
Code: Select all
on preOpenStack
set the rect of this stack to the screenRect
end preOpenStack
Thanks,
lestroso

Posted: Sun Jun 17, 2007 8:06 pm
by Mark
Hi lestroso,
You can use Rev's geometry manager, which you will find in the property inspector, but the GM is unreliable and there will always be a moment when you regret using it. Writing your own scripts is the best solution.
So, yes, you have to write a script for each object. If objects are placed in groups on multiple cards, this is no problem at all. I can imagine that it is quite a lot of work if all your cards are different. In that case, put part of your scripts at card level and another part at stack level. At card level, finish the resizeStack handler with a pass command.
There is no property for automatic resize. You can do this when the stack opens, e.g. in the preOpenStack handler. If you change the stack size by script, while the lockmessages is false, the resizeStack handler will run automatically. If the user resizes the script manually, the resizeStack handler will run as well.
Yes, you can run the preOpenStack handler as you quoted it. It will set the size of the window to the same size as the screen. If this is too big, you can adjust the rect or determine the rect by yourself:
Code: Select all
on preOpenStack
set the rect of this stack to 0,0,600,400
set the loc of this stack to the screenLoc
end preOpenStack
or
Code: Select all
on preOpenStack
put the rect of this screen into myRect
add 64 to item 1 of myRect
add 64 to item 2 of myRect
subtract 64 from item 3 of myRect
subtract 64 from item 4 of myRect
set the rect of this stack to myRect
set the loc of this stack to the screenLoc
end preOpenStack
Posted: Mon Jun 18, 2007 3:19 am
by FourthWorld
The only difficulty with the screenRect is that it returns the full physical size of the monitor, and doesn't take into account the menu bar and Dock on OS X or the Task Bar on Windows.
To get the screenRect adjusted for these trimmings, use the windowBoundingRect.
Posted: Wed Jun 20, 2007 4:37 pm
by LESTROSO
Thank you to all..... thank you mark....thank you fourthworld..... but i have still the problem.......
i have understood that i need the command "resize window"......
ok,......if the program start it must recognise the rect of the screen and then resize the window itself.........
i'm thinking about this code
Code: Select all
on preopenstack
if the screen rect is 800,600 then resizewindow 700,500
end preopenstack
i need a piece of code like this.......do you have any idea?????
i will thank you again so much!!!............
bye
lestroso
Posted: Mon Jun 25, 2007 4:39 pm
by LESTROSO
Thank you to everybody in any way boys..........
i have understood that:
i can use the resize window to resize the card and the geometry for the
objects or set the monitor resolution to 1024x768 if it's not that , but i
don't know how to do that change
in fact now i'm developing a shooter game in 1024 x 768 and i want
fix the resolution to that.
if you have any ideas do not hesitate, please let me know...............
thanks again to all,
LESTROSO

Posted: Sat Jun 30, 2007 4:37 pm
by LESTROSO
Hy to everybody and many thanks to Mark!!!!!
Mark thanks again for your support and i have now made a correction of
your code that now works fine.
If you vary the number you can adjust the window appear on the center
without cutting.
I have made 52 for the 1024x768 resolution, it's quite good......
here the code:
Code: Select all
on preOpenStack
put the screenrect into myRect
add 52 to item 1 of myRect
add 52 to item 2 of myRect
subtract 52 from item 3 of myRect
subtract 52 from item 4 of myRect
set the rect of this stack to myRect
set the loc of this stack to the screenLoc
end preOpenStack
Bye see you soon......
Lestroso
