1. [Win] Panel and Resizing
Two questions:
1. How can I make a control that is a simple panel inside a larger window? I
tried using a group control with no caption, but that didn't work, because
I'm colouring the inside of this panel, and the border of the group
interferes with it.
2. How can I restrict resizing of a window to a certain aspect ratio? I'd
like to do this as your resize it, rather than wait until you've finished
resizing, and then correct in one dimension or another.
Thanks
=====================================================
.______<-------------------\__
/ _____<--------------------__|===
||_ <-------------------/
\__| Mr Trick
2. Re: [Win] Panel and Resizing
Here is some code that might help...
--------------------
------------------------------------------------
-- resize.exw Version: 1.0
--
-- Demonstrates ...
-- 1) How to create simple panels in a a window.
-- 2) How to resize relative to the parent window
-- 3) How to resize and keep the aspect ratio constant.
------------------------------------------------
without warning
include win32lib.ew
object VOID
------------------------------------------------
-- Controls IDs
------------------------------------------------
integer MainWin
integer Panel01
integer Panel02
------------------------------------------------
-- Event Handlers
------------------------------------------------
------------------------------------------------
procedure onResize_MainWin(integer self, integer event, sequence parms)
------------------------------------------------
sequence lNewSize
-- Set the Panel #1 size relative to the main window.
setCtlSize(Panel01, 0.75, 0.75)
-- Set the Panel #2 width relative to Panel #1, but keep it's
-- width/height ratio constant.
lNewSize = getCtlSize(Panel01)
-- Panel #2's width is half Panel #1's width
lNewSize[1] *= 0.5
-- But it's height is always 25% bigger than its width.
lNewSize[2] = lNewSize[1] * 1.25
setCtlSize(Panel02, lNewSize[1], lNewSize[2])
end procedure
------------------------------------------------
-- Application Initiation
------------------------------------------------
function AppInit()
integer lRC
lRC = 0
MainWin = createEx(Window, "Resizing Panels", 0, 0, 0, 600, 400,
0, 0)
Panel01 = createEx( Window, "", MainWin, 10,10,0,0,
{WS_CHILD, WS_VISIBLE, WS_BORDER}, 0)
setWindowBackColor(Panel01, BrightCyan)
-- Link in the event handlers.
Panel02 = createEx( Window, "", Panel01, 10,10,0,0,
{WS_CHILD, WS_VISIBLE}, 0)
setWindowBackColor(Panel02, Yellow)
setHandler(MainWin, w32HResize, routine_id("onResize_MainWin"))
return lRC
end function
if AppInit() = 0 then
WinMain( MainWin, Normal)
end if
--------------------
16/10/2002 9:05:46 AM, mistertrik at hotmail.com wrote:
>
>Two questions:
>
>1. How can I make a control that is a simple panel inside a larger window? I
>tried using a group control with no caption, but that didn't work, because
>I'm colouring the inside of this panel, and the border of the group
>interferes with it.
>
>2. How can I restrict resizing of a window to a certain aspect ratio? I'd
>like to do this as your resize it, rather than wait until you've finished
>resizing, and then correct in one dimension or another.
>
---------
Cheers,
Derek Parnell
3. Re: [Win] Panel and Resizing
Thank you, that does indeed. My code to keep the window the right size, and
scale is this:
winSize = getClientRect(parent)
if winSize[4] / winSize[3] > 0.75 then
setCtlSize(child,winSize[3]-2*border,0.75*(winSize[3]-2*border))
else
setCtlSize(child,1.33*(winSize[4]-2*border),winSize[4]-2*border)
end if
I had a problem also that nothing would display on the child window if I
drew to it on an onPaint event, but I found that to be because I hadn't
linked repaintWindow() for the child window also.
=====================================================
.______<-------------------\__
/ _____<--------------------__|===
||_ <-------------------/
\__| Mr Trick
>From: Derek Parnell <ddparnell at bigpond.com>
>Reply-To: EUforum at topica.com
>To: EUforum <EUforum at topica.com>
>Subject: Re: [Win] Panel and Resizing
>Date: Wed, 16 Oct 2002 11:16:20 +1000
>
>
>Here is some code that might help...
>--------------------
>--
>-- Demonstrates ...
>-- 1) How to create simple panels in a a window.
>-- 2) How to resize relative to the parent window
>-- 3) How to resize and keep the aspect ratio constant.
>
>integer MainWin
>integer Panel01
>integer Panel02
>
>
> sequence lNewSize
>
> -- Set the Panel #1 size relative to the main window.
> setCtlSize(Panel01, 0.75, 0.75)
>
> -- Set the Panel #2 width relative to Panel #1, but keep it's
> -- width/height ratio constant.
> lNewSize = getCtlSize(Panel01)
> -- Panel #2's width is half Panel #1's width
> lNewSize[1] *= 0.5
> -- But it's height is always 25% bigger than its width.
> lNewSize[2] = lNewSize[1] * 1.25
>
> setCtlSize(Panel02, lNewSize[1], lNewSize[2])
>
>end procedure
>function AppInit()
> integer lRC
>
> lRC = 0
> MainWin = createEx(Window, "Resizing Panels", 0, 0, 0, 600, 400,
> 0, 0)
>
> Panel01 = createEx( Window, "", MainWin, 10,10,0,0,
> {WS_CHILD, WS_VISIBLE, WS_BORDER}, 0)
> setWindowBackColor(Panel01, BrightCyan)
>
> -- Link in the event handlers.
> Panel02 = createEx( Window, "", Panel01, 10,10,0,0,
> {WS_CHILD, WS_VISIBLE}, 0)
> setWindowBackColor(Panel02, Yellow)
>
> setHandler(MainWin, w32HResize, routine_id("onResize_MainWin"))
>
> return lRC
>end function
>
>if AppInit() = 0 then
> WinMain( MainWin, Normal)
>end if
>
>--------------------
>
>
>16/10/2002 9:05:46 AM, mistertrik at hotmail.com wrote:
>
> >
> >Two questions:
> >
> >1. How can I make a control that is a simple panel inside a larger
>window? I
> >tried using a group control with no caption, but that didn't work,
>because
> >I'm colouring the inside of this panel, and the border of the group
> >interferes with it.
> >
> >2. How can I restrict resizing of a window to a certain aspect ratio? I'd
> >like to do this as your resize it, rather than wait until you've finished
> >resizing, and then correct in one dimension or another.
> >
>---------
>Cheers,
>Derek Parnell
>
>
>