PDA

View Full Version : Example: Resize Runtime


Adam
09-15-2005, 01:31 PM
Attached is a sample project that will allow your AutoPlay Media Studio 6.0 runtime to be resized dynamically at runtime. To apply this example to your project follow these steps:

1) Copy the contents of the "Global Functions" section of the sample project to the same location in your project.
2) On each page in your project you must add the following function calls to the appropriate events:

On Preload:
Resize_OnPreLoad();

On Close:
Resize_OnClose();

On Size:
Resize_OnSize(e_PageWidth,e_PageHeight);

3) You must enable the "Resizable" option under Project -> Settings.

Adam Kapilik

rhosk
09-25-2005, 05:47 AM
Adam, I'm surprised that you ddin't get any responses to this. It's a really sweet template, thanks!

Adam
09-26-2005, 01:56 PM
Thanks Ron. must appreciated

Adam Kapilik

pjborg
10-10-2005, 11:07 AM
This is awesome! It works splendidly! Thank you!

Byte
10-11-2005, 04:39 AM
hi adam,
i apply your example to my project, and get the following errors:

on starting the application

"On Preload, Line 134: Argument 1 must be of type table."
which ist this line
for i = 1, Table.Count(Objects) do

if i klick ok, the application starts
if i jump to the next page i get the error:

"On Preload, Line 239: attempt to index global 'tblProps' (a nil value)"
which is this line
if tblProps.ObType == OBJECT_BUTTON then

after klicking on ok it jumps to this page but is not displaying anything.

by jumping to the next page i get the error:

"On Close, Line 65: attempt to index global 'tblPos' (a nil value)"
which is this line
if tblPos.ObType == OBJECT_BUTTON then

and again the error:
"On Preload, Line 239: attempt to index global 'tblProps' (a nil value)"

an so on

any suggestions on that problem?

byte

rhosk
10-11-2005, 04:56 AM
Check your "Page Actions" for exact spelling/case :)

Byte
10-11-2005, 06:49 AM
i copyed everything out of adam's example. add the functions on each page and checked it again. it's all there, but i still get these errors

byte

rhosk
10-11-2005, 06:54 AM
Can you post the project?

Byte
10-11-2005, 05:53 PM
i don't think so, the project is over 5 mb big.

but never mind, i just don't use the resize in my project.

thanks alot anyway for help

byte

Corey
10-11-2005, 06:37 PM
FWIW the project works perfectly on my end too. :yes

rhosk
10-11-2005, 06:49 PM
Yeah, it works flawlessly for me too and I have many objects on the page(s). byte, I had your symptoms by simply misspelling a function call. Never give up the ship!

pjborg
10-12-2005, 12:39 AM
Hey, Byte,
There is some script in "Project > Global Functions..." that makes the whole thing work. Did you copy that part to your project?

pjborg
10-12-2005, 12:47 AM
By the way, just want to say thanks again for this example: it really opened my eyes to the possibilities of global functions. I'm still learning all this scripting, and I was thinking I'd have to go to each object and put this resize stuff on each one individually. From now on I'm going to always ask: How can I do this globally (read: quickly and easily)? Thanks, Adam, for the big bump on the head!

Corey
10-12-2005, 12:51 AM
Yes, Global Functions are definitely the way to go. Modular code rules. It's the key to designing projects which can be easily modified/upgraded. I put almost all of my code in the Global Functions area these days... Very easy to work with too, custom functions are incredibly simple to work with yet super powerful. :yes

Byte
10-12-2005, 06:40 AM
hi pjborg,

yes i did copy the whole part to my Project > Global Functions. that's exactly where i am getting my errors from. when it calls the

On Preload:
Resize_OnPreLoad();

the error "On Preload, Line 134: Argument 1 must be of type table." is line 134 in Global Functions.

after i finish some other stuff in my project, i will go through these global functions again.

byte

pjborg
10-12-2005, 12:02 PM
I got that same error message when displaying a page containing no objects. pj

Byte
10-12-2005, 04:41 PM
hi pjborg,

the problem happens to be the same everytime i jump to a new page.

first i get the error on close and then the one on preload. no matter if there are ojects on the page or not.
for some reason, which i don't understand, it is not initialising the table and the variable.

byte

rhosk
10-12-2005, 04:50 PM
Byte,

First of all, do you have the latest version of AMS (6.0.1.0)?

Second, if you could post a small sample of your project (doesn't have to include all the objects). If you download Adam's sample project, it works right out of the box. You obviously have a minor typo somewhere is all. It works really well.

Do you happen to have a plugin of sorts on the page? The plugin part of the function needs a little help.

Byte
10-12-2005, 06:49 PM
hi,

i got Version 6.0.0.0, didn't noticed there was an update. i go download it right away and update my version.

i tryed to upload a part of my project in a nother post, did't work.

Adam's sample project works perfect and is realy awesome.

yes i got plugins in the project (some shapes). maybe that's the problem.
what do i need to do if there ar plugins in the project?

byte

Byte
10-13-2005, 03:37 AM
hi rhosk,

your tip was good. after i deleted all my shape plugins it works fine.
so what do i have to do to get that awesome scipt to work with plugins?

byte

rhosk
10-13-2005, 04:00 AM
Hmm, it should still work even though you have shape plugins, although they just won't resize. If that function is failing (PreLoad), it must not be able to find any objects. This could be anything from all objects being disabled/invisible to......

In any event, I've attached the global functions with the plugin section completed. I guess Adam figured we could add these if we needed them. Just copy/paste it into your Global function area where the resize functions are. Again, double check your spelling on the 3 page events and just ensure that they're in the right places, etc...It could be a matter of 1(one) tiny typo and it will fail...believe you me, I've been there :)

Byte
10-13-2005, 06:33 AM
hi rhosk,

that was it. works perfect now. in adam's project the plugin part was compleetly missing, so it could't work.

thanks a lot for your help and support. :yes
newbie byte is happy :p now

byte

Corey
10-13-2005, 01:28 PM
3 cheers for rhosk. Hip, hip huzzah!

:yes :yes :yes :yes :yes :yes :yes :yes :yes :yes

Byte
10-15-2005, 02:10 AM
hi all,

since the resize works perfect on my project now, i got a little question.

is it possible to change the size of text also. for example on buttons, input fields and labels?

byte

yosik
10-15-2005, 04:12 PM
You can use the Button.SetProperties action and change the font size. Ditto for Labels and Input objects.

Yossi

Byte
10-15-2005, 07:55 PM
hi,

on buttons, labels and paragraphs the resize of the font works greate. on input fields, listboxes and comboboxes i allways get the windows-debug-error window and the application quits.

in the attached txt-file you can see, how i did it. could anyone please look into it and tell me why it is not working

byte

Byte
10-18-2005, 08:29 AM
anyone here, that can help me with that?

byte

45eyey
10-19-2005, 10:35 AM
rezising works fine except for the labels , when i maximize the labels do not stay in the same place ie:centred under an image it move to one side any suggestions would be useful

abcnormal
12-29-2005, 09:04 PM
This looks great. Works great.
But how can I set my project to run in full screen, and still get the benefits of the functions.

(I do not want to set it in kiosk mode, because I do not want the black part around the project, I want it to run in whatever screensize the client is using as the startupsize (orginal size)).

yosik
12-30-2005, 11:45 AM
Run in Flat mode instead of kiosk mode.

Yossi

abcnormal
12-30-2005, 08:45 PM
But running it in flat mode does not solve my problem. I want it to be fullscreen, some way I need to make a function that will find the users screensize, and set the current application size to the screensize. I am running it in standard mode.

Corey
12-30-2005, 09:08 PM
Ask and ye shall receive. Attached... :yes

Intrigued
12-30-2005, 09:13 PM
If I understand you correctly then here is a function that should get the result you are needing:

Global Functions:

function SetFullScreen()
tblScreenSize = System.GetDisplayInfo()
DW = tblScreenSize.Width
DH = tblScreenSize.Height
Window.SetPos(Application.GetWndHandle(), 0, 0)
Window.SetSize(Application.GetWndHandle(), DW, DH)
end

Then to "call" (use) the function (say in the On Show of the first page showing):

SetFullScreen()

Intrigued
12-30-2005, 09:26 PM
It works best (no flicker) if you put the function call (to use) in the On Preload area, just after the other line of code like such:

Resize_OnPreLoad();
SetFullScreen()

abcnormal
12-30-2005, 09:49 PM
I get full size yes, but all my objects are not resized.
All I am looking for actually, is the same code as if I pressed the Maximize button on the application. Because when I do that, all is working perfectly. But I want it to start there.

Corey
12-30-2005, 09:53 PM
When you maximize Windows applications it doesn't resize the objects. Try maximizing something like Photoshop, Dreamweaver, or Flash, everything stays the same size except the window. Adam posted a project once where all the objects resized dynamically, try a search in the examples forum... :yes

abcnormal
12-30-2005, 10:07 PM
I am using the code where it resizes all objects.
However, I can not get it to work with the fullscreen code.
I am not used to this syntax yet. :)

bobbie
02-11-2006, 11:00 PM
Thanks Adam, great coding ..

azmanar
02-12-2006, 03:19 AM
Hi,

I combined the magical ingredients by Adam, Intrigue and Corey.

Whoosh......... Got all the RESIZING potion I needed to change sizes of my subjects, at a click.

Thanks to the wizards...

Intrigued
02-12-2006, 10:26 AM
Well, if all be told we had to consort with the likes of Harry Potter. But, hey, you gotta' do wha' ya gotta' do!

;)

DebaserXP
04-01-2006, 09:36 AM
I have found that removing my template pages and any flash objects prevents the error messages above.

Stan Hamers
04-03-2006, 02:36 PM
:yes Adam thanks for your example it is working perfect! For me it is a great new feature of AMS6 to resize the window in runtime, but after reading all the “post replies” I, am still trying to manipulate this script to start the CD automatically in the maximum resized position and to give the customer the possibility to minimum resize the window with the resize Windows button, if he wants. What do I have to change or add in your script to manipulate the Windows resize button
This will make the new feature complete in my opinion.
I cannot find the combination where “AZMANAR” is talking about in his reply,:huh I ,am just a copy past script writer

Worm
04-03-2006, 03:00 PM
@->Stan Hamers

Drop this in the Preload of your first Page, it should do the trick

hTrayWnd = DLL.CallFunction(_SystemFolder.."\\User32.dll", "FindWindowA", "\"Shell_trayWnd\",\"\"", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)
TraySize=Window.GetSize(hTrayWnd)
TrayPos=Window.GetPos(hTrayWnd)

if (TrayPos.X==0 and TrayPos.Y==0 and TraySize.Width == System.GetDisplayInfo().Width) then
Window.SetPos(Application.GetWndHandle(), 0, TraySize.Height)
Window.SetSize(Application.GetWndHandle(), System.GetDisplayInfo().Width, System.GetDisplayInfo().Height - TraySize.Height)
elseif(TrayPos.X==0 and TrayPos.Y==0 and TraySize.Height == System.GetDisplayInfo().Height) then
Window.SetPos(Application.GetWndHandle(), TraySize.Width, 0)
Window.SetSize(Application.GetWndHandle(), System.GetDisplayInfo().Width - TraySize.Width, System.GetDisplayInfo().Height)
elseif (TrayPos.X == 0 and TrayPos.Y > 0) then
Window.SetPos(Application.GetWndHandle(), 0, 0)
Window.SetSize(Application.GetWndHandle(), System.GetDisplayInfo().Width, System.GetDisplayInfo().Height - TraySize.Height)
elseif (TrayPos.X > 0 and TrayPos.Y == 0) then
Window.SetPos(Application.GetWndHandle(), 0, 0)
Window.SetSize(Application.GetWndHandle(), System.GetDisplayInfo().Width - TraySize.Width, System.GetDisplayInfo().Height)
end

Stan Hamers
04-03-2006, 11:54 PM
Thanks Worm for your replay but your code is only changing the Windows resize to maximum. This gives almost the same result as with the full screen solution from “Corey and Intrigued” in the replay list.
If I push the minimize button it is not going back to the original size and I am missing al the great “Adam” features that also the buttons and images etc. are resizing automatically with the screen size.
Or is this combination not possible?:huh

Worm
04-04-2006, 08:09 AM
Sounds like your looking more for a way to have the app maximized when launched, but the user can use the "Restore" button to have it go to your normal sized app. In that case, simply maximize you window at launch

Window.Maximize(Application.GetWndHandle())

Stan Hamers
04-04-2006, 01:05 PM
:yes Thanks Worm for your help. It is working perfect!:lol

Adam
04-05-2006, 11:42 AM
As of today almost 3000 people have looked at this thread. I think that we need to build this into the software at some point so that it is easier to add.

REF: 12619

Adam Kapilik

rhosk
04-05-2006, 01:50 PM
allowObjectsResize = true :yes

playmenow
04-06-2006, 03:04 AM
Error:

On Preload, Line 149: attemp to index global hTable '(a nil value)'
It's line: for i = 1, hTable.Count(Objects) do

and much more......

rhosk
04-06-2006, 05:10 AM
http://s92220213.onlinehome.us/images/icon5.gif

azmanar
04-06-2006, 05:10 AM
As of today almost 3000 people have looked at this thread. I think that we need to build this into the software at some point so that it is easier to add.

REF: 12619

Adam Kapilik

YESsss.......... !

playmenow
04-06-2006, 05:18 AM
and don't forget to coreect the errors (regarding hTable....there's also a typo,
Heighth)....AND:
it would be nice to work with the flat or custom mask mode ;)

azmanar
04-06-2006, 05:43 AM
:yes Adam thanks for your example it is working perfect! For me it is a great new feature of AMS6 to resize the window in runtime, but after reading all the “post replies” I, am still trying to manipulate this script to start the CD automatically in the maximum resized position and to give the customer the possibility to minimum resize the window with the resize Windows button, if he wants. What do I have to change or add in your script to manipulate the Windows resize button
This will make the new feature complete in my opinion.
I cannot find the combination where “AZMANAR” is talking about in his reply,:huh I ,am just a copy past script writer

Stan,

Sorry... I didnt enter examples area for a long time.

Attached is the example you were seeking for - combination of Adam + Corey + Rhosk.

What it does:
1. When the EXE started, it will maximize.
2. After user reduce the size, there is a button to MAX it up again.

The project can only use STANDARD format settings. Bordered, Flat and Kiosk settings cannot take the RESIZE function as I have tested. Objects will disappear.

azmanar
04-06-2006, 07:37 AM
RESIZE FAQ

Q1: When do you expect the objects to disappear if you have the resize function in the global area of your project?

Answer: If you set the Project Settings to other than STANDARD, whenever you MINIMIZE to the sys tray using Application.Minimize Action, then MAXIMIZE it again, most objects will disappear.

Why: I stopped searching for the reason and couldnt find a solution after spending 2 days completely on it.

So?: If you find any solution, please share with us.

Corey
04-06-2006, 08:11 AM
As of today almost 3000 people have looked at this thread.
Ahem. I have an theory. That is to say, an theory which is mine, and no one else's. And this theory, which is mine, encompasses a great deal of information. Oh yes, I should say so. It is a cautious and far reaching theory, yet not too broad and certainly not without specific focus. In fact, some may think it almost too specific. At the same time this theory, which is mine, and not anyone else's, is highly adaptable and takes into full account the many factors which tend to influence theories in general. I've spent a great deal of time developing this theory, in fact some may say too much time. Not only through the process of scientifical analysis, but also a series of strategic luncheons. And in the end I feel *very* strongly that this theory, which is mine, carries great weight, some even say too much weight, vis-a-vis the contextual ramifications of the statistical assertions which the young Adams of the today's world speak of with such apple cheeked aplomb.

rhosk
04-06-2006, 08:15 AM
Ahem. I have an theory. That is to say, an theory which is mine, and no one else's. And this theory, which is mine, encompasses a great deal of information. Oh yes, I should say so. It is a cautious and far reaching theory, yet not too broad and certainly not without specific focus. In fact, some may think it almost too specific. At the same time this theory, which is mine, and not anyone else's, is highly adaptable and takes into full account the many factors which tend to influence theories in general. I've spent a great deal of time developing this theory, in fact some may say too much time. Not only through the process of scientifical analysis, but also a series of strategic luncheons. And in the end I feel *very* strongly that this theory, which is mine, carries great weight, some even say too much weight, vis-a-vis the contextual ramifications of the statistical assertions which the young Adams of the today's world speak of with such apple cheeked aplomb.

Again ... http://s92220213.onlinehome.us/images/icon5.gif

:D

Worm
04-06-2006, 08:41 AM
See if this does any better for you Azmanar

azmanar
04-06-2006, 01:27 PM
See if this does any better for you Azmanar

THANKS Worm ...

Your code is so economical, yet it does the same resize function. It's more efficient because I noticed the difference in speed. Really cool.

Also, I can use the Resize Function even in Bordered Settings and not lose my objects.

Thanks for sharing with us newbies.

Worm
04-06-2006, 01:28 PM
When it comes to the economy of that code, the credit all goes to the Tig we all know and love.

azmanar
04-06-2006, 01:38 PM
When it comes to the economy of that code, the credit all goes to the Tig we all know and love.

.... May Tig and Worm be Blessed with Economic Prosperity, Manifolds ....

Corey
04-06-2006, 02:22 PM
Geonodes... Sombreros...

Stan Hamers
04-09-2006, 08:50 AM
Hello Worm,
Is it also possible to get you compact code working in combination with more pages?
I changed all the code in the example of Adam and put you compact code in it, but the resizing is only good working for all the objects in the page where I change the window size. If I go to an other page the window is resized but the objects are not resized.
Thanks in advance for you time.

Stan Hamers
04-09-2006, 09:54 AM
Here the changed example where I was talking about.
To make my problem more clear.

adivin
04-11-2006, 11:30 AM
Hello Worm,
Is it also possible to get you compact code working in combination with more pages?
....
I have the same question... If I use page jump it does't work...

Worm
04-11-2006, 11:51 AM
I'll take a look when I get a chance, right now, it's busy, busy, busy.

adivin
04-12-2006, 10:33 AM
I'll take a look when I get a chance, right now, it's busy, busy, busy.
OK I'll wait for you.
Attached is an example
Thank you

Eagle
04-12-2006, 01:32 PM
OK, so you are experimenting with Adam's Resize template (tks Adam)
and you would like to reduce the 'web object' flicker blues..on resize.

try this mod in the 'OnSize event' of the page with the web object:

eg:

Web.SetEnabled("WebObject", false);
Resize_OnSize(e_PageWidth,e_PageHeight); -- Adam's code call here
Web.SetEnabled("WebObject", true);

viola ! .. for WinXP and later Windoz mainly :yes
(seemed to sort it at my end ...)

Stan Hamers
04-13-2006, 01:26 PM
Take your time Worm, The code of Adam is still working fine to gether with you idea to put the “Window.Maximize(Application.GetWndHandle())” in the show event of the page.
I hoped with the compact code from you that the resizing in the first page might work faster.

rick mora
06-04-2006, 09:33 PM
can anyone help me please.
I am using the same script posted by adam.
for resizing the program and it works fine, but when I use it along with another script for using an input box I get an error message that says.
on click, Line 6: attempt to index 'SQLite' ( a nil value).

this is the original script from adam

---Delete old database to refresh database if files are changed
File.Delete(_SourceFolder .. "\\AutoPlay\\Docs\\Images.db", false, false, false, nil);
---set db path
sImageDatabase = _SourceFolder .. "\\AutoPlay\\Docs\\Images.db";
---Open the database, or in abscence, create one
db = SQLite.Open(sImageDatabase);
nLastError = Application.GetLastError();
if nLastError ~= SQLite.OK then
Dialog.Message("Error Opening File", SQLite.GetLastErrorString());
end
-- Create table Image_List within the database with desired fields (columns)
-- If the table Image_List exists, no action taken
SQLite.Query(db,"CREATE TABLE Image_List(RecordID integer primary key, Title text, Path text)");
tImage = File.Find(_SourceFolder.. "\\AutoPlay\\User Images\\", "*", true, false, nil, nil);
--do the following for each file:
for j,file_path in tImage do
fTitle = String.SplitPath(file_path).Filename, file_path
---insert image file info into database
SQLite.Query(db,"insert or replace into Image_List values (NULL,"..Enclose(fTitle)..", "..Enclose(file_path)..")");
end



and this is the cript for the input box

--if the enter key is pressed, click object search
if e_Key == 13 then
Page.ClickObject("Go_btn");
end

--if the esc key is pressed, click object refresh
if e_Key == 27 then
Page.ClickObject("Clear_btn");
end

=========================
and this one is for the ThumbList.


--get the selected item index
selected = ThumbList.GetSelectedItems("Pic_tn");

--if selected does not equal nil (ie. there is something stored
--in selected), then set the lable object text. Since we have not
--enabled 'multi select', only one item can be selected at a time,
--and therefore we only care about the first value in the table
--'selected'.
if selected then
info = ThumbList.GetItemInfo("Pic_tn", selected[1]);
---Label.SetText("Status", "Image " .. selected[1] .. " / " .. ThumbList.GetItemCount("Pic_tn") .. " (" .. info.filename .. " | Size: " .. info.image_width .. " x " .. info.image_height .. " | Color: " .. info.image_bpp .."bit) Double Click Image to Open");
--- Image.Load("UserP_img", "Image " .. selected[1] .. " / " .. ThumbList.GetItemCount("Pic_tn") .. " (" .. info.filename .. ");

---else
--- Label.SetText("Status", "");
end
--get the selected item index
selected = ThumbList.GetSelectedItems("Pic_tn");

--if selected does not equal nil (ie. there is something stored
--in selected), then open that image. Since we have not
--enabled 'multi select', only one item can be selected at a time,
--and therefore we only care about the first value in the table
--'selected'.
if selected then
File.Open(info.filepath, "", SW_SHOWNORMAL);
end


if any one of you can help I will truly apriciated.

thank you
rick mora

JonnyONL
06-17-2006, 12:21 PM
it seems that you forgot to enable the SQLite plug-in. to enable it, go to Project --> Plugins and check SQLite

holtgrewe
06-22-2006, 07:28 PM
Adam, terrific functions for resizing pages and objects.
Did anyone ever figure out a solution to the 'flicker' problem when resizing, when jumping from page to page? I can't find a solution in the forum.

Any help is really appreciated.

holtgrewe
06-23-2006, 06:35 PM
I found my problem with the resizing and the "flicker" from page to page. When using transitions, the images and objects briefly appear in their original position prior to being resized. I removed the transitions and Adam's code works perfectly...?!?!

DJuse
11-03-2006, 09:27 PM
Does anyone know how can we also resize the Media Player.
It work fine for everything else but when you try to resize the MP everything get distortioned!

sombms
12-15-2006, 08:40 PM
Hey, this is regarding your error when you try to make ur app resize... that error was coming because there were no objects in you page!!! try putting a lable or something in ur page and then try, it should work...

nals
03-29-2007, 05:17 AM
Works Fine for me , Thanks Adam.,
:yes

willfreer
08-20-2007, 11:02 AM
For some reason this works good on the background, but the buttons, art and video art still their original size, in the top left of the project, any suggestions?

mindstitchdr
08-20-2007, 12:18 PM
Try this:

Make sure you project is set to Resizable then,

Global Functions:
---------------------------------------------------------------------------
--Function Resize_OnSize;
--This function is in place to reduce the amount of code that must go on
--each pages "On Size" event
---------------------------------------------------------------------------
function Resize_OnSize (PageWidth,PageHeight)
if bFirstRun then
setOriginalPageSize(PageWidth,PageHeight);
bFirstRun = false;
end
SetSize(PageWidth,PageHeight);
end

---------------------------------------------------------------------------
--Function Resize_OnPreLoad();
--This function is in place to reduce the amount of code that must go on
--each pages "On Preload" event
---------------------------------------------------------------------------
function Resize_OnPreLoad()
getOriginalPositions();
Size = Page.GetSize();
if not bFirstRun then
SetSize(Size.Width,Size.Height);
end
end


-- This is a global variable that is used to determine the first time that
-- This page has been Accessed
bFirstRun = true;

---------------------------------------------------------------------------
--Function setOriginalPageSize
--This function is used to set a global table with the original page
--size of your project
---------------------------------------------------------------------------
function setOriginalPageSize(WidthO,HeightO)
-- Store these values in a global table. This action is only
-- performed once.
tblOriginalSize = {Width=WidthO,Height=HeightO};
end

---------------------------------------------------------------------------
--Function RevertSize
--This function puts all objects back to their original position and size
--This makes the page look proper if the project is resized on a different
--page.
---------------------------------------------------------------------------
function Resize_OnClose ()

-- Stop the page from redrawing temporarily. If this was not in place
-- you would see a flash of the original objects before it is resized
-- when you jump pages.
Application.SetRedraw(false);

-- The loop will go through all of the entries in the global table tblOriginalPos
-- and set all of the objects back to their original state.
for i = 1, Table.Count(tblOriginalPos) do
-- Get the table that is stored in the global table on every itteration of
-- the loop
tblPos = tblOriginalPos[i];

-- The next if -> elseif block determines which type of object
-- is currently in the table tblPos
if tblPos.ObType == OBJECT_BUTTON then
-- If it is a Button then set it back to its original size
Button.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
-- If it is a Button then set it back to its original Position
Button.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_LABEL then
Label.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Label.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_PARAGRAPH then
Paragraph.SetSize(tblPos.ObName,tblPos.W,tblPos.H) ;
Paragraph.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_IMAGE then
Image.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Image.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_FLASH then
Flash.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Flash.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_VIDEO then
Video.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Video.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_WEB then
Web.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Web.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_INPUT then
Input.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Input.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_HOTSPOT then
Hotspot.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Hotspot.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_LISTBOX then
ListBox.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
ListBox.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_COMBOBOX then
ComboBox.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
ComboBox.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_PROGRESS then
Progress.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Progress.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_TREE then
Tree.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Tree.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_PLUGIN then
Plugin.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Plugin.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);

end
end
end

---------------------------------------------------------------------------
--Function getOriginalPositions
--This function enumerates all objects on the current page. It then stores
--information about the objects in a global table to be used for a
--reference point to perform the position and size adjustments
--The following information is stored about each object:
-- Object Name
-- Object Type
-- Width
-- Height
-- Position X
-- Position Y
---------------------------------------------------------------------------
function getOriginalPositions ()
-- The master table that contains information about each object on the page
tblOriginalPos = {};
-- The table that will be stored in the above master table. Each objects
-- information will be stored in the below table
Pos = {};
-- Get all of the objects on a page
Objects = Page.EnumerateObjects();
-- Loop through each object on the page
for i = 1, Table.Count(Objects) do
-- Find out what TYPE of object it is.
Type = Page.GetObjectType(Objects[i]);
-- If it is a Button then
if Type == OBJECT_BUTTON then
-- Get the size
Size = Button.GetSize(Objects[i]);
-- Get the Position
Position = Button.GetPos(Objects[i]);
-- Set the table up to store this information
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_BUTTON};
-- Store the 'Pos' table in the master table tblOriginalPos
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_LABEL then
Size = Label.GetSize(Objects[i]);
Position = Label.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_LABEL};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_PARAGRAPH then
Size = Paragraph.GetSize(Objects[i]);
Position = Paragraph.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_PARAGRAPH};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_IMAGE then
Size = Image.GetSize(Objects[i]);
Position = Image.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_IMAGE};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_FLASH then
Size = Flash.GetSize(Objects[i]);
Position = Flash.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_FLASH};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_VIDEO then
Size = Video.GetSize(Objects[i]);
Position = Video.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_VIDEO};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_WEB then
Size = Web.GetSize(Objects[i]);
Position = Web.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_WEB};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_INPUT then
Size = Input.GetSize(Objects[i]);
Position = Input.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_INPUT};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_HOTSPOT then
Size = Hotspot.GetSize(Objects[i]);
Position = Hotspot.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_HOTSPOT};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_LISTBOX then
Size = ListBox.GetSize(Objects[i]);
Position = ListBox.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_LISTBOX};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_COMBOBOX then
Size = ComboBox.GetSize(Objects[i]);
Position = ComboBox.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_COMBOBOX};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_PROGRESS then
Size = Progress.GetSize(Objects[i]);
Position = Progress.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_PROGRESS};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_TREE then
Size = Tree.GetSize(Objects[i]);
Position = Tree.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_TREE};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_PLUGIN then
Size = Plugin.GetSize(Objects[i]);
Position = Plugin.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_PLUGIN};
tblOriginalPos[i] = Pos;
end
end
end

---------------------------------------------------------------------------
--Function SetSize
--This function is where the calculations for resizing and repositioning
--takes place. It accepts a page Width and Height as parameters. It then
--finds the ration between the original paage size and the current page size.
--Every object on the page is then repositioned and resized by the ration
--of the difference in size.
---------------------------------------------------------------------------
function SetSize (Width,Height)
-- Get the original size of the page/project
OriginalWidth = tblOriginalSize.Width;
OriginalHeight = tblOriginalSize.Height;

-- Calculate the difference between the original page size and the current
RatioW = Width / OriginalWidth;
RatioH = Height / OriginalHeight;

-- Turn off the redraw
Application.SetRedraw(false);

-- Now loop through the table that stores information about each object
--and reposition and resize them according to the above ratio
for i=1, Table.Count(tblOriginalPos) do
-- Each item in tblOriginalPos is a table that holds specific informtion about
-- that object
tblProps = tblOriginalPos[i];
-- If the item is a Button
if tblProps.ObType == OBJECT_BUTTON then
-- Set the position of the object
Button.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
-- Set the size of the object
Button.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_LABEL then
Label.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Label.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_PARAGRAPH then
Paragraph.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Paragraph.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_IMAGE then
Image.SetPos(tblProps.ObName, tblProps.X * RatioW, tblProps.Y * RatioH);
Image.SetSize(tblProps.ObName, tblProps.W * RatioW, tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_FLASH then
Flash.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Flash.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_VIDEO then
Video.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Video.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_WEB then
Web.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Web.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_INPUT then
Input.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Input.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_HOTSPOT then
Hotspot.SetPos(tblProps.ObName, tblProps.X * RatioW, tblProps.Y * RatioH);
Hotspot.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_LISTBOX then
ListBox.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
ListBox.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_COMBOBOX then
ComboBox.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
ComboBox.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_PROGRESS then
Progress.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Progress.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_TREE then
Tree.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Tree.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_PLUGIN then
Plugin.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Plugin.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
end
end

-- Allow the page to redraw once all objects have been adjusted
Application.SetRedraw(true);

end

Page's On Preload:

Resize_OnPreLoad();

Page's On Close:

Resize_OnClose();

Page's On Size:

Resize_OnSize(e_PageWidth,e_PageHeight);

Solmos
09-08-2007, 06:36 AM
Hi mindstitchdr

in that code it is possible to redimensionar the size of the columns of datagrid? fixing to us to the size of an image by column?

I have proven with this code but not work

Global functions:

elseif tblProps.ObType == OBJECT_IMAGE then
Image.SetPos(tblProps.ObName, tblProps.X * RatioW, tblProps.Y * RatioH);
Image.SetSize(tblProps.ObName, tblProps.W * RatioW, tblProps.H * RatioH);

if tblProps.ObName == "Image10" then
DataGrid.SetColumnWidth("Plugin1", 0, tblProps.W * RatioW, true);
elseif tblProps.ObName == "Image9" then
DataGrid.SetColumnWidth("Plugin1", 1, tblProps.W * RatioW, true);
elseif tblProps.ObName == "Image1" then
DataGrid.SetColumnWidth("Plugin1", 2, tblProps.W * RatioW, true);
end

Solmos
09-08-2007, 09:03 AM
another question

since it could do so that redimensione the application from 630x405 and not less of that size of page?

thx

mindstitchdr
09-12-2007, 10:58 AM
Sorry it took so long to reply, put this in your projects OnStartup actions:

function g_OnGetMinMaxInfo()
tbReturn = {};
tbReturn.MinX = 630;
tbReturn.MinY = 405;


return tbReturn;
end

That should prevent the page from going smaller than 630x405. As far as the datagrid plugin resizing I'm not sure.

meshmeh
09-12-2007, 02:49 PM
Dear friends
I tried this program it is ok in all object except for mediaplayer !!!!!
why that happened

andunok
10-25-2007, 05:12 PM
yes:yes:yes;);)
You are the BEST of the BEST-mindstitchdr
Thanks for all...You resolved the FULLSCREEN mode for my project.

FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN FULLSCREEN ;););););)
BRAVISSIMO,,,,,,,,

rhosk
10-25-2007, 07:23 PM
I do believe that he's a little excited...

FoxLeader
10-25-2007, 07:59 PM
Really? I don't :lol

Anyway, good job and thanks for sharing!

Adam
10-26-2007, 03:57 PM
thats funny. It's good to see people get excited over lua actions.

AJK

andunok
11-08-2007, 03:10 PM
:) Hi, mindstitchdr
I want if you can or if it's possible to make in my project 3 buttons:

1. maximize (minimize)
2. restore
3. exit
My project is Resizable and Standard

I wish to make Resizable and Bordered with 3 buttons: maximize (minimize), restore and exit seem like windows.:huh
It's possible?
Thanks....
By the way......good job for your script (Fullscreen mode);)

mindstitchdr
11-08-2007, 04:14 PM
Well it looks like you have to leave the app at "Standard" for this to work. Take a look at my example. When you minimize the app then restore, none of the buttons redraw. I'm not really sure how to fix it, if it is possible.

usernameCasper
11-08-2007, 04:36 PM
Hey mindstitchdr,

I looked at your project and it seems you got alot of code that is redundant.
E.g.: Your global functions, and statements in the syntax like:
currentapp = Application.GetWndHandle();
Window.Minimize(Application.GetWndHandle(currentap p));

It won't redraw cause allot of the code is redundant.
Try to add the following code into button3:

Window.Minimize(Application.GetWndHandle());

And try to optimize the code, remove redundant code.

Hope this helps (keep it simple and it works).

Kind regards,
Casper

mindstitchdr
11-08-2007, 04:53 PM
Well keep in mind this resize function is not "My code". Its the code from the example posted by Adam on the first page. (willfreer didn't look in the Global Functions) I know the button 3 code was redundant, I was just trying things to try to get it to work and could not.

usernameCasper
11-08-2007, 04:57 PM
Ahh, yes, but the global function contains alot more redundant code than the code in the button.
I haven't analysed it yet, just a quick look, I maybe will look to it tomorrow,
I got to take a nap now (almost 0:00 am :)).
But for minimizing and maximizing you don't need the resize function, I made
the similiar function a while ago and it worked fine.
I'll post tomorrow further.

Good night,
Casper

Dermot
11-08-2007, 08:42 PM
or just upgrade to version 7.0 and you won't need any code at all. :yes

mindstitchdr
11-08-2007, 09:33 PM
Yeah upgrading will remove the need for the code, but will it fix the question of "Bordered" vs "Standard"?

alban
11-18-2007, 01:37 PM
If i want to make a auto full screen project with no borders & no windows trayicon (Hidding windows desktop) & autoresize on desktop resolution (1024/768 or 1280/1024 etc). Works this script or media studio 7?

Mike O
11-26-2007, 10:41 AM
Hi,

I've been using Adam's resize code and have noticed that the labels do not resize properly. Is there any way to make labels resize proportionally as well?

mindstitchdr
11-26-2007, 11:18 AM
Yeah Mike O, I had the same problem. I just created a button using transparent images and use that for everything I need Labels for. Here it is, if you want it.

Mike O
11-26-2007, 11:58 AM
Thanks for the button - but the text stays the same size, same problem as the label. How did you get the text to adjust?

mindstitchdr
11-26-2007, 02:07 PM
Ok, I've been playing with this for a little bit and I think I figured it out. The problem is we need to change the Label.SetSize to Label.SetProperties for the font size. Try replacing your Global code for resize to this and see if it works for you.

This only fixes the labels not the buttons.

---------------------------------------------------------------------------
--Function Resize_OnSize;
--This function is in place to reduce the amount of code that must go on
--each pages "On Size" event
---------------------------------------------------------------------------
function Resize_OnSize (PageWidth,PageHeight)
if bFirstRun then
setOriginalPageSize(PageWidth,PageHeight);
bFirstRun = false;
end
SetSize(PageWidth,PageHeight);
end

---------------------------------------------------------------------------
--Function Resize_OnPreLoad();
--This function is in place to reduce the amount of code that must go on
--each pages "On Preload" event
---------------------------------------------------------------------------
function Resize_OnPreLoad()
getOriginalPositions();
Size = Page.GetSize();
if not bFirstRun then
SetSize(Size.Width,Size.Height);
end
end


-- This is a global variable that is used to determine the first time that
-- This page has been Accessed
bFirstRun = true;

---------------------------------------------------------------------------
--Function setOriginalPageSize
--This function is used to set a global table with the original page
--size of your project
---------------------------------------------------------------------------
function setOriginalPageSize(WidthO,HeightO)
-- Store these values in a global table. This action is only
-- performed once.
tblOriginalSize = {Width=WidthO,Height=HeightO};
end

---------------------------------------------------------------------------
--Function RevertSize
--This function puts all objects back to their original position and size
--This makes the page look proper if the project is resized on a different
--page.
---------------------------------------------------------------------------
function Resize_OnClose ()

-- Stop the page from redrawing temporarily. If this was not in place
-- you would see a flash of the original objects before it is resized
-- when you jump pages.
Application.SetRedraw(false);

-- The loop will go through all of the entries in the global table tblOriginalPos
-- and set all of the objects back to their original state.
for i = 1, Table.Count(tblOriginalPos) do
-- Get the table that is stored in the global table on every itteration of
-- the loop
tblPos = tblOriginalPos[i];

-- The next if -> elseif block determines which type of object
-- is currently in the table tblPos
if tblPos.ObType == OBJECT_BUTTON then
-- If it is a Button then set it back to its original size
Button.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
-- If it is a Button then set it back to its original Position
Button.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
Button.SetProperties(tblPos.ObName, {FontSize=tblPos.F});
elseif tblPos.ObType == OBJECT_LABEL then
Label.SetProperties(tblPos.ObName, {FontSize=tblPos.F});
--Label.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Label.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_PARAGRAPH then
Paragraph.SetSize(tblPos.ObName,tblPos.W,tblPos.H) ;
Paragraph.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_IMAGE then
Image.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Image.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_FLASH then
Flash.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Flash.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_VIDEO then
Video.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Video.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_WEB then
Web.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Web.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_INPUT then
Input.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Input.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_HOTSPOT then
Hotspot.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Hotspot.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_LISTBOX then
ListBox.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
ListBox.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_COMBOBOX then
ComboBox.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
ComboBox.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_PROGRESS then
Progress.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Progress.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_TREE then
Tree.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Tree.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);
elseif tblPos.ObType == OBJECT_PLUGIN then
Plugin.SetSize(tblPos.ObName,tblPos.W,tblPos.H);
Plugin.SetPos(tblPos.ObName, tblPos.X, tblPos.Y);

end
end
end

---------------------------------------------------------------------------
--Function getOriginalPositions
--This function enumerates all objects on the current page. It then stores
--information about the objects in a global table to be used for a
--reference point to perform the position and size adjustments
--The following information is stored about each object:
-- Object Name
-- Object Type
-- Width
-- Height
-- Position X
-- Position Y
---------------------------------------------------------------------------
function getOriginalPositions ()
-- The master table that contains information about each object on the page
tblOriginalPos = {};
-- The table that will be stored in the above master table. Each objects
-- information will be stored in the below table
Pos = {};
-- Get all of the objects on a page
Objects = Page.EnumerateObjects();
-- Loop through each object on the page
for i = 1, Table.Count(Objects) do
-- Find out what TYPE of object it is.
Type = Page.GetObjectType(Objects[i]);
-- If it is a Button then
if Type == OBJECT_BUTTON then
-- Get the size
Size = Button.GetSize(Objects[i]);
-- Get the Position
Position = Button.GetPos(Objects[i]);
BFontS = Button.GetProperties(Objects[i]);
-- Set the table up to store this information
Pos = {F=BFontS.FontSize,W=Size.Width,H=Size.Height,X=Po sition.X,Y=Position.Y,ObName=Objects[i],ObType=OBJECT_BUTTON};
-- Store the 'Pos' table in the master table tblOriginalPos
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_LABEL then
--Size = Label.GetSize(Objects[i]);
LFontS = Label.GetProperties(Objects[i]);
Position = Label.GetPos(Objects[i]);
Pos = {F=LFontS.FontSize,X=Position.X,Y=Position.Y,ObNam e=Objects[i],ObType=OBJECT_LABEL};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_PARAGRAPH then
Size = Paragraph.GetSize(Objects[i]);
Position = Paragraph.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_PARAGRAPH};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_IMAGE then
Size = Image.GetSize(Objects[i]);
Position = Image.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_IMAGE};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_FLASH then
Size = Flash.GetSize(Objects[i]);
Position = Flash.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_FLASH};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_VIDEO then
Size = Video.GetSize(Objects[i]);
Position = Video.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_VIDEO};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_WEB then
Size = Web.GetSize(Objects[i]);
Position = Web.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_WEB};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_INPUT then
Size = Input.GetSize(Objects[i]);
Position = Input.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_INPUT};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_HOTSPOT then
Size = Hotspot.GetSize(Objects[i]);
Position = Hotspot.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_HOTSPOT};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_LISTBOX then
Size = ListBox.GetSize(Objects[i]);
Position = ListBox.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_LISTBOX};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_COMBOBOX then
Size = ComboBox.GetSize(Objects[i]);
Position = ComboBox.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_COMBOBOX};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_PROGRESS then
Size = Progress.GetSize(Objects[i]);
Position = Progress.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_PROGRESS};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_TREE then
Size = Tree.GetSize(Objects[i]);
Position = Tree.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_TREE};
tblOriginalPos[i] = Pos;
elseif Type == OBJECT_PLUGIN then
Size = Plugin.GetSize(Objects[i]);
Position = Plugin.GetPos(Objects[i]);
Pos = {W=Size.Width,H=Size.Height,X=Position.X,Y=Positio n.Y,ObName=Objects[i],ObType=OBJECT_PLUGIN};
tblOriginalPos[i] = Pos;
end
end
end

---------------------------------------------------------------------------
--Function SetSize
--This function is where the calculations for resizing and repositioning
--takes place. It accepts a page Width and Height as parameters. It then
--finds the ration between the original paage size and the current page size.
--Every object on the page is then repositioned and resized by the ration
--of the difference in size.
---------------------------------------------------------------------------
function SetSize (Width,Height)
-- Get the original size of the page/project
OriginalWidth = tblOriginalSize.Width;
OriginalHeight = tblOriginalSize.Height;

-- Calculate the difference between the original page size and the current
RatioW = Width / OriginalWidth;
RatioH = Height / OriginalHeight;
if RatioW > RatioH then
RatioF = RatioW - RatioH / 2 / 100
else
RatioF = RatioH - RatioW / 2 / 100
end

-- Turn off the redraw
Application.SetRedraw(false);

-- Now loop through the table that stores information about each object
--and reposition and resize them according to the above ratio
for i=1, Table.Count(tblOriginalPos) do
-- Each item in tblOriginalPos is a table that holds specific informtion about
-- that object
tblProps = tblOriginalPos[i];
-- If the item is a Button
if tblProps.ObType == OBJECT_BUTTON then
-- Set the position of the object
Button.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
-- Set the size of the object
Button.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
Button.SetProperties(tblProps.ObName, {FontSize=tblProps.F * RatioF});
elseif tblProps.ObType == OBJECT_LABEL then
Label.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Label.SetProperties(tblProps.ObName, {FontSize=tblProps.F * RatioF});
--Label.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_PARAGRAPH then
Paragraph.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Paragraph.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_IMAGE then
Image.SetPos(tblProps.ObName, tblProps.X * RatioW, tblProps.Y * RatioH);
Image.SetSize(tblProps.ObName, tblProps.W * RatioW, tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_FLASH then
Flash.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Flash.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_VIDEO then
Video.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Video.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_WEB then
Web.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Web.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_INPUT then
Input.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Input.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_HOTSPOT then
Hotspot.SetPos(tblProps.ObName, tblProps.X * RatioW, tblProps.Y * RatioH);
Hotspot.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_LISTBOX then
ListBox.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
ListBox.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_COMBOBOX then
ComboBox.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
ComboBox.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_PROGRESS then
Progress.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Progress.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_TREE then
Tree.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Tree.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
elseif tblProps.ObType == OBJECT_PLUGIN then
Plugin.SetPos(tblProps.ObName,tblProps.X * RatioW, tblProps.Y * RatioH);
Plugin.SetSize(tblProps.ObName,tblProps.W * RatioW,tblProps.H * RatioH);
end
end

-- Allow the page to redraw once all objects have been adjusted
Application.SetRedraw(true);

end



Edit: This is kind of weird on labels that use bold, I'm sure it has something to do with text smaller than a certain size not allowing bold.

Edit 2: I've changed the above code to include the button fonts. This is really weird. It really only works if you maximize or restore or you change the page size by dragging one of the corners. Not sure why.

Mike O
11-26-2007, 02:21 PM
Most Excellent! Thanks - it works much better. I've got to get to another task now. I'll check it out further and let you know the results.

2epro
06-18-2008, 04:47 PM
after a flawless copy & paste i get this error ::

onsize, line 318: attempt to index global 'tblprops' ( a nil value)

Centauri Soldier
07-27-2009, 04:08 AM
I have put the Resize into an action plugin and have adapted it to work with all current objects. Also, labels resize now.

And now I know who AJK is...thanks for the awsome resize code Adam. Very nice work!:D I can now update the plugin and put your actual name in there instead of "the author of the ResizeAJK example".

See this thread (http://www.indigorose.com/forums/showthread.php?p=141503#post141503) for the latest version of the Resize plugin.

mimo
07-28-2009, 07:41 AM
i got a problem ! I added the global function and pages actions to my project and when i change the page in my project every object became invisible . so i attached the project to u adam to help me with it .


http://rapidshare.com/files/260952133/the_project.rar.html

mimo
07-28-2009, 09:57 PM
there are a problem in this example , when i set page transition , i saw the objects in the original size till they resize . what i mean is that redrawing is visible because of transition effect . so is there anyway to solve this problem .

Centauri Soldier
07-29-2009, 04:45 PM
I'll look into it. Please post future Plugin comments and bugs in the actual Plugin thread for everyone's benefit if you would not mind too much. Thanks. :)

mimo
07-30-2009, 07:46 AM
i would not mind at all centauri. but i am talking here about the example not the plugin and in the plugin thread i talk about the plugin . i do that because i think that if we solve any problem in the example ,we could solve it in the plugin and vise verse . and i think by doing this a lot of users could share their ideas to help .

Worm
07-30-2009, 08:08 AM
You'll not overcome the transition issue. The way AMS does a transition is to grab a screen shot of the page being transitioned to as it was designed (not after the On Show event), and that is the image used to transition.

At least thats what I think, I'm only going off my experience here.

mimo
07-30-2009, 11:09 AM
so , what is adam's opinion about page transition problem ?

and there is another problem which is the size of buttons text . the size of buttons text don't change as the button change in size and that develop a lot of problems .

if anyone can modify the script of this example and upload it to solve those problems that would be great .

mimo
08-01-2009, 01:38 PM
buttons text problem is the most important problem in this example , i wish we could overcome it with creative scripting

Centauri Soldier
08-01-2009, 02:33 PM
Now that can be done. I'll look into it. I'm in a few other projects right now, but as soon as I'm done I'll throw a script together to handle the buttons.

mimo
08-02-2009, 09:19 PM
they are:
1- paragraph and rich text objects don't change in font size .
2- button text don't change in size as the the button do .
3- when we set page transition we find that the openning page have the original size and when the transition end it resize to the new size so all page redrawing became visible .

if any body can solve any of these problems , please help !!

Centauri Soldier
08-03-2009, 12:55 AM
This plugin was based off of an example. The best option might be to just rewrite the plugin from scratch.

DoveBirkoff
08-05-2009, 04:39 PM
Hi folks,

firsts of all thanks a lot for the effort on it. This just what i was looking for.. :yes
it works "out of the box" ;)

I'm reusing the code for a project with just a page and only an input text box.
The idea is resize the project as desired in order to test different ways at wrapping a paragraph...

so far so good, but for my purpose I need the Input Boxto be Multi-line and I wouldn't like to see any scrollbar (makes nicer).
The apps behaves:

- Multiline DISABLE :Works as expected. input object supports manual input (obvious) & pasting text. Only a single line is allow.

- Multiline ENABLE, vertical & horizontal scrollbar disable: IF text pasted is bigger (longer in lines) than actual Input Box size, text won't be pasted (it's gone after few ms).

- Multiline ENABLE, vertical scrollbar enable, horizontal scrollbar disable: Works as expected. Pasted text is being displayed and added down vertically to the existing text (if any).


It's not big deal but I'd appreciate some light on this.


cheers
David

Centauri Soldier
08-05-2009, 10:36 PM
Try Page.Redraw() after you resize the app.

DoveBirkoff
08-08-2009, 05:57 PM
Try Page.Redraw() after you resize the app.

Thanks for the point, it solved a second problem I came through :yes
at the end I left the vertical bar for functional reasons...

Cheers
PS: I agree as well with the idea of implement this function in AMS

mimo
08-17-2009, 11:55 AM
my wish is to find a way to make this example deal with paragraphs , buttons text and labels size with invisible redrawing . if anyone can do this and upload it , that would be awesome .