Re: [Win] Panel and Resizing

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu