child window copies from parent "under" it

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

When I create a "child" window in the following way, it has a curious(?) and
undesirable attribute: whatever is in the main window under where the child
window
is created is graphically COPIED into the child window, & moves with it.  In
the example, it's a button, though it's not functional in the child window
it's copied into.

Can anyone tell me how to make the child window without this copying
happening  (other than creating it where there is nothing to copy) ??

Dan Moyer

<code follows>
--   ChildWin

-- THIS EXAMPLE CREATES A CHILD WINDOW and writes a message into it

-----------------------------------------------------------------
include win32lib.ew
without warning

----------------------------------------------------------------
-- CREATE THE MAIN WINDOW:

constant
MainWindow = create( Window, "Child Window Demo", 0, 0, 0, 500, 400, 0 )

-------------------------------------------

-- CHILD WINDOW, attached to Main ("parent")
constant aChildWindow =
    create( Window, "Child Window", MainWindow, 50, 80, 400, 200,
_all({  WS_CHILD,WS_DLGFRAME, WS_SYSMENU, WS_CAPTION}))

-------------------------------------------
-- MAKE A BUTTON TO OPEN THE CHILD WINDOW:

constant ChildButton = create( DefPushButton, "Open Child Window",
MainWindow, 120, 100, 200, 30, 0 )

----------------------------------------------------------
--  SET THE FONT STYLE AND SIZES ON THE BUTTON & IN THE WINDOW:

setFont(ChildButton, "Arial", 10, Bold)
setFont(aChildWindow, "Arial", 12, Bold)

----------------------------------------------------------
--  GET THE SIZE OF TEXT IN CHILD WINDOW, AS SET BY setFont, TO USE
--  TO SPECIFY NEW LINE POSITIONS WHEN WRITING TO THE WINDOW:

integer TheFontHeight -- the font height
TheFontHeight = getFontMetric(aChildWindow,tmHeight)--in the window

-----------------------------------------------------------
-- MAKE THE 2ND WINDOW A CHILD WINDOW WHEN BUTTON IS CLICKED:

global procedure onClick_ChildButton()
  openWindow(aChildWindow,Normal)
end procedure

onClick[ChildButton] = routine_id( "onClick_ChildButton" )
-----------------------------------------------------------------
--  WRITE TO CHILD WINDOW:
global procedure onPaint_aChildWindow(integer x1,integer y1, integer x2,
integer y2)

    setPosition(aChildWindow, 10, TheFontHeight)-- sets new position of text
   wPuts(aChildWindow,"THIS IS A CHILD WINDOW.")
    setPosition(aChildWindow, 10, 3*TheFontHeight)
   wPuts(aChildWindow,"It will move with the main window.")
end procedure

-- tell Windows when to do the action
onPaint[aChildWindow] = routine_id( "onPaint_aChildWindow" )

-----------------------------------------------------------------

-- hand control over to Windows
    WinMain( MainWindow, Normal )

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

Search



Quick Links

User menu

Not signed in.

Misc Menu