Re: Newbie: Win32Lib: moveWindow-? (Plus new win32lib modify

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

--part1_bcaa4d58.24e8f543_boundary

<< David,

 I'd think I'd rather have them move at the "same" time, but it should
 probably be ok for now for the child to reposition right after the parent.
 Easy to accomplish is also important! :)  If starting to move parent
 "blanked" child until parent is finally positioned & repainted, moving the
 child at that time would seem to be perfectly ok, since that's what it
 would look like anyway if they were moved at the "same" time, wouldn't it?

 Dan >>

  I have written a procedure called modify that removes a control, then adds
a new one.  However, it doesn't fully remove the control, but can be safe.
As long as you don't add any more in the code after that, it works fine.
This is useful in your case, and can be useful in other cases, such as
renaming a control.  I had the dilemma where based on certain choices from a
listbox, the window will have a different set of controls.  I was going to
use this, but Dave finally convinced me to do it the smart way by making each
control, then setting them visible or invisible as needed.  But, in your
case, this would help you.  Here is the syntax:

return = modify(ControlName,{New parameters}).

  So in your case, you could find the new x and y coordintes of the parent
window, then use this command:

return = modify(ChildWindow,{Window,"Whatever",Parent,x + 10,y + 10,200,200,0)

  Please note that this wasn't done by Dave, and I take no responsibility for
damage.  That said, I'm 99% sure that if you use it right (not adding any
more controls after you modify), it won't mess up.  In fact, as long as you
don't add any more controls, there is no reason for it to mess up.
  A demo is attached.  To get the demo to work, you must include the
following code at the bottom of your copy of win32lib.ew:

global function modify( integer ctrl, sequence specs )
    atom style, response, id
    sequence class
    id = ctrl
    window[id] = {  specs[3], specs[1], specs[2], specs[4], specs[5],
specs[6], specs[7], specs[8] }
    if specs[1] = Window then
        createWindow( id )
    elsif specs[1] = Menu then
        createMenu( id, specs[2], specs[3] )
    elsif specs[1] = MenuItem then
        createMenuItem( id, specs[2], specs[3] )
    else
        poke( buffer1, className[ specs[1] ] & 0 )
        poke( buffer2, specs[2] & 0 )
        specs[8] = or_bits( classStyle[ specs[1] ], specs[8] )
        window_handle[id] = c_func( xCreateWindow, {
            0,                      -- exended style
            buffer1,                -- window class name
            buffer2,                -- window caption
            specs[8],             -- window style
            specs[4],                      -- initial x position
            specs[5],                      -- initial y position
            specs[6],                  -- initial x size
            specs[7],                  -- initial y size
            getHandle( specs[3] ),     -- parent window handle
            NULL,                   -- window menu handle
            0,                      -- program instance handle
            NULL} )                 -- creation parameters
        window_func[id] = c_func( xSetWindowLong,
        { window_handle[id], GWL_WndProc, WndProcAddress } )
        window_class[id] = classType[ specs[1] ]
        if and_bits( WS_TABSTOP, specs[8] ) then
        window_tab[specs[3]] = window_tab[specs[3]] + 1
        window_tab[id] = window_tab[specs[3]]
        end if
        if window_class[id] = SCROLLBAR then
        end if
    end if
    return id
end function

--part1_bcaa4d58.24e8f543_boundary
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline; filename="DEMO.EXW"

include win32lib.ew
without warning

sequence names
integer current, Button, x, y

names =3D {"0","Euphoria","Warning:","Subscript","Error","Imminent"}
current =3D 1
x =3D 110
y =3D 90

constant
  Win =3D create(Window,"Demonstration",0,200,200,300,300,0),
  ButtonAdd =3D create(PushButton,"Name",Win,30,200,40,30,0),
  ButtonU =3D create(PushButton,"Up",Win,180,190,50,30,0),
  ButtonD =3D create(PushButton,"Down",Win,180,220,50,30,0),
  ButtonL =3D create(PushButton,"Left",Win,130,205,50,30,0),
  ButtonR =3D create(PushButton,"Right",Win,230,205,50,30,0)

  Button =3D create(PushButton,names[current],Win,x,y,100,30,0)

procedure Name()
  current +=3D 1
  Button =3D modify(Button,{PushButton,names[current],Win,x,y,100,30,0})
  repaintWindow(Win)
end procedure

procedure Up()
  y -=3D 20
  Button =3D modify(Button,{PushButton,names[current],Win,x,y,100,30,0})
  repaintWindow(Win)
end procedure

procedure Down()
  y +=3D 20
  Button =3D modify(Button,{PushButton,names[current],Win,x,y,100,30,0})
  repaintWindow(Win)
end procedure

procedure Left()
  x -=3D 20
  Button =3D modify(Button,{PushButton,names[current],Win,x,y,100,30,0})
  repaintWindow(Win)
end procedure

procedure Right()
  x +=3D 20
  Button =3D modify(Button,{PushButton,names[current],Win,x,y,120,30,0})
  repaintWindow(Win)
end procedure

onClick[ButtonU] =3D routine_id("Up")
onClick[ButtonD] =3D routine_id("Down")
onClick[ButtonL] =3D routine_id("Left")
onClick[ButtonR] =3D routine_id("Right")
onClick[ButtonAdd] =3D routine_id("Name")

WinMain(Win)
--part1_bcaa4d58.24e8f543_boundary--

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

Search



Quick Links

User menu

Not signed in.

Misc Menu