1. Restore a Window

Hello Everybody,

I there a way to restore a window to it's original size (the one used in createEx(}) if the size is changed (not minimized}. Without using getRect/setRect?

Don Cole

new topic     » topic index » view message » categorize

2. Re: Restore a Window

dcole said...

I there a way to restore a window to it's original size (the one used in createEx(}) if the size is changed (not minimized}. Without using getRect/setRect?

I assume you mean by "if the size is changed" that the user manually changes the window size by using the mouse. In that case, the answer is no. It is your application's responsibility to know what size to restore the window to and you need to do that with setRect().

Why do you want to avoid using setRect()?

new topic     » goto parent     » topic index » view message » categorize

3. Re: Restore a Window

DerekParnell said...
dcole said...

I there a way to restore a window to it's original size (the one used in createEx(}) if the size is changed (not minimized}. Without using getRect/setRect?

I assume you mean by "if the size is changed" that the user manually changes the window size by using the mouse.

No, I'm changing the size with setRect.

DerekParnell said...

Why do you want to avoid using setRect()?

Because I thoght I saw somewhere that you could do it with one command. Rather than:

sequence s 
s=getRect(Window1}--get the original size 
 
setRect(Window1.10,10,1100,1100,1}--change  the size of the window here with setRect() 
setRect(Window1, s[1],s[2], s[3]-s[1], s[4]-s[2],1)}--restore to original size 

But I can't find that procedure anymore. It might have been showWindow(Window1,SW_RESTORE). But that only works if one uses SW_MINIMIZE to change the window size.

What I'm trying to do is blowup a window and it's EditTexts and the EditTexts' fontsize. Then restore them back to their original sizes. Is there an easier way of doing this?

Don Cole

new topic     » goto parent     » topic index » view message » categorize

4. Re: Restore a Window

dcole said...

Is there an easier way of doing this?

No. Think about it ... restore to what? The system doesn't know which size is your application's default size for each window so that means you have to record what that size is. And thus its up to you to restore it back if its been changed.

However, you could make it a bit easier with these routines ...

procedure SetDefaultSize(integer win) 
    setUserProperty(win, "DefaultSize", getRect(win)) 
end procedure 
 
procedure RestoreDefaultSize(win) 
    sequence ds 
 
    ds = getUserProperty(win,"DefaultSize") 
    if length(ds) != 0 then 
       ds = ds[1] 
       setRect(win, ds[1],ds[2], ds[3]-ds[1], ds[4]-ds[2],1)}--restore to 'default' 
    end if 
 
end procedure 
 
-- Now use it like this ... 
SetDefaultSize(Window1) 
 
setRect(Window1.10,10,1100,1100,1}--change  the size of the window here with setRect() 
 
RestoreDefaultSize(Window1) 
new topic     » goto parent     » topic index » view message » categorize

5. Re: Restore a Window

DerekParnell said...
dcole said...

Is there an easier way of doing this?

No. Think about it ... restore to what? The system doesn't know which size is your application's default size for each window so that means you have to record what that size is. And thus its up to you to restore it back if its been changed.

However, you could make it a bit easier with these routines ...

procedure SetDefaultSize(integer win) 
    setUserProperty(win, "DefaultSize", getRect(win)) 
end procedure 
 
procedure RestoreDefaultSize(win) 
    sequence ds 
 
    ds = getUserProperty(win,"DefaultSize") 
    if length(ds) != 0 then 
       ds = ds[1] 
       setRect(win, ds[1],ds[2], ds[3]-ds[1], ds[4]-ds[2],1)}--restore to 'default' 
    end if 
 
end procedure 
 
-- Now use it like this ... 
SetDefaultSize(Window1) 
 
setRect(Window1.10,10,1100,1100,1}--change  the size of the window here with setRect() 
 
RestoreDefaultSize(Window1) 

Thanks Pete, Your code works pretty well and fine.

I guess you have to save all the original Windows and EditTexts attributes with getRect(}.

Don Cole

new topic     » goto parent     » topic index » view message » categorize

6. Re: Restore a Window

dcole said...

Thanks Pete,

LOL

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu