| View previous topic :: View next topic |
| Author |
Message |
easy rider Valued Newbie

Joined: 10 Sep 2001 Posts: 26 Location: Netherlands
|
Posted: Fri Feb 08, 2002 6:32 pm Post subject: Resizable window |
|
|
Hi all,
I've created a resizable window with it's elements, this works so far so good. The window size is 300 * 250. the problem is how to fix it so that a user it can make smaller than 300 * 250, so only bigger of equal to it's original.
Rene  |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Fri Feb 08, 2002 7:31 pm Post subject: |
|
|
How about creating the window at the smallest size
that you want available, then resize it to 300x250
at startup? _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
easy rider Valued Newbie

Joined: 10 Sep 2001 Posts: 26 Location: Netherlands
|
Posted: Fri Feb 08, 2002 9:23 pm Post subject: |
|
|
hi mac,
i didn't ask my question very good i saw.
The smallest size is 300 * 250 so i want it only bigger (thats no prob) and not smaller then 300 * 250
Rene |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Fri Feb 08, 2002 9:37 pm Post subject: |
|
|
OK, how about a timer loop using @winpos() with the
"W" and "H" flags to check window size, and resize
if the window is smaller than 300x250:
__________________________________________________________________________________________________________________________
| Code: |
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"Test Prog",-1,0,300,250,RESIZABLE
DIALOG SHOW
:EVLOOP
WAIT EVENT
goto @event()
:RESIZE
rem -- width/height difference is width + 8, height + 27 --
if @greater(308, @winpos("Test Prog",W))
WINDOW POSITION,"Test Prog",,,308
end
if @greater(277, @winpos("Test Prog",H))
WINDOW POSITION,"Test Prog",,,,277
end
goto EVLOOP
:CLOSE
EXIT
|
[EDIT]
Used Sylvester's ideas, also allowed for width/height difference
between original Window creation and WINDOW POSITION. _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361

Last edited by Mac on Sat Feb 09, 2002 7:48 pm; edited 2 times in total |
|
| Back to top |
|
 |
easy rider Valued Newbie

Joined: 10 Sep 2001 Posts: 26 Location: Netherlands
|
Posted: Fri Feb 08, 2002 11:14 pm Post subject: |
|
|
Hi mac,
Thanks this works good for me.
See ya
Rene |
|
| Back to top |
|
 |
Sylvester Valued Newbie

Joined: 31 Jul 2000 Posts: 43 Location: Boston, MA USA
|
Posted: Sat Feb 09, 2002 12:47 am Post subject: |
|
|
Hi, Mac and Easy Rider.
Mac, why use a timer loop?
A RESIZE event is going to be caused whenever the dialog's size is changed by the user anyway. So why not just do the size checks in there and reset to the minimum values if needed without the timer? Like in the following bit of code.
| Code: |
Title Resize
DIALOG CREATE,Resize,-1,0,300,250,RESIZABLE
DIALOG ADD,BUTTON,Exit,212,208,80,28,Exit
DIALOG SHOW
:Evloop
wait event
goto @event()
:RESIZE
REM We check values of Width and Height
parse "%%width;%%height",@dlgpos(,WH)
REM If Width is below the minimum Value, set to 300
if @greater(300,%%width)
%%width = 300
end
REM If Height is below the minimum value, set to 250
if @greater(250,%%height)
%%height = 250
end
REM The following sets the Width and Height
dialog setpos,,,,%%width,%%height
REM Just for fun, We'll move the Button Element with respect to the Dialog
dialog setpos,Exit,@diff(%%height,38 ),@diff(%%width,92),80,28
goto evloop
:ExitBUTTON
info "Buh-Bye!!!"
:Close
exit
|
NOTE: The space in @diff(%%height,38 ) is intentional to prevent the smiley from showing.
To be really extra sure that the window behaves and never goes below the minimum size, you can also use the PAINT style in DIALOG CREATE like in this next bit.
| Code: |
Title Resize
DIALOG CREATE,Resize,-1,0,300,250,RESIZABLE,PAINT
DIALOG ADD,BUTTON,Exit,212,208,80,28,Exit
DIALOG SHOW
:Evloop
wait event
goto @event()
:PAINT
:RESIZE
REM We check values of Width and Height
parse "%%width;%%height",@dlgpos(,WH)
REM If Width is below the minimum Value, set to 300
if @greater(300,%%width)
%%width = 300
end
REM If Height is below the minimum value, set to 250
if @greater(250,%%height)
%%height = 250
end
REM The following sets the Width and Height
dialog setpos,,,,%%width,%%height
REM Just for fun, We'll move the Button Element with respect to the Dialog
dialog setpos,Exit,@diff(%%height,38 ),@diff(%%width,92),80,28
goto evloop
:ExitBUTTON
info "Buh-Bye!!!"
:Close
exit
|
That PAINT style will cause a PAINT event whenever the dialog is redrawn like when it is being restored or being brought to the front or whatever. Personally, I don't really thing you'll need to use it.
Anyway, only my thoughts and I've just reached my quota for the day.
I go bye bye now.  _________________ Sylvester
In the immortal words of the great philosopher, Homer ... "D'OH!!!" 8O |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Feb 09, 2002 7:20 pm Post subject: |
|
|
Good thinking Sylvester.
Easy Rider - Ya might want to allow for the title bar
height when using WINDOW POSITION. Also, checking
the width/height separately similiar to Sylvester's
example is probably a good idea.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Feb 09, 2002 7:47 pm Post subject: |
|
|
I modified my example above using Sylvester's ideas.
Also, on my Windows 95 system, WINDOW POSITION
needs allowance for both width and height difference
from original window creation. Strange...  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|