1. child window copies from parent "under" it

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 message » categorize

2. Re: child window copies from parent "under" it

You've created a rather 'strange' child... more like an incomplete control.
...notice that it can't even receive focus, by clicking on it's title bar,
for example.
Anyways, the simplest solution is:

global procedure onClick_ChildButton()
  openWindow(aChildWindow,Normal)
  setVisible(ChildButton,False)
end procedure

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: child window copies from parent "under" it

Dan's little button problem points out an interesting problem that beginners
like me often run across.
First of all, what are the 'official' differences, if any,  between 'child'
and 'secondary' windows ?
...and what are the 'rules' regarding the specifying of Window attributes.
I've also sometimes falsely assumed that all the various WS_  attributes were
distinct and exclusive, but they're not.
One attribute sometimes 'forces' another, which has not been specifically
declared in our (  or_all()  ).

...just babbling Wolf

new topic     » goto parent     » topic index » view message » categorize

4. Re: child window copies from parent "under" it

To answer my own previous question, and clarify my 'complaint' about Dan's
peculiar child window....
All the 'rules' regarding WS_ can be found under/after,  'General Window
Styles' in win32.hlp.
According to this, one cannot ( legally ! ) combine:
WS_DLGFRAME,  WS_SYSMENU,  and WS_CAPTION
... and this created the 'strange' window I complained about.

Wolf

new topic     » goto parent     » topic index » view message » categorize

5. Re: child window copies from parent "under" it

Wolf wrote:

> Dan's little button problem points out an interesting
> problem that beginners like me often run across.

One of the goals of Win32Lib is to allow programmers to focus on coding,
rather than Win32 internals. I think the addition of additional window
classes (WinModal, WinPalette, WinSplash, etc) would help greatly to resolve
some of these issues.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

6. Re: child window copies from parent "under" it

Fritz,

Ok, I'm not that surprised that I created a strange child :) , but your
simple solution is too simple; when I asked for a solution "other than
creating it where there is nothing to copy", I should have added "and
without having to make everything on the parent window be not visible or not
there", because that's what I really meant.

So, if the window I created was "strange", then how could I create a child
window that *isn't* strange, which wouldn't copy stuff (any stuff) from the
parent?

Dan

ps. I couldn't find win32.hlp???

----- Original Message -----
From: "wolfgang fritz" <wolfritz at KING.IGS.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Sunday, September 17, 2000 6:10 AM
Subject: Re: child window copies from parent "under" it


> You've created a rather 'strange' child... more like an incomplete
control.
> ...notice that it can't even receive focus, by clicking on it's title bar,
> for example.
> Anyways, the simplest solution is:
>
> global procedure onClick_ChildButton()
>   openWindow(aChildWindow,Normal)
>   setVisible(ChildButton,False)
> end procedure
>
> > Can anyone tell me how to make the child window without this copying
> > happening  (other than creating it where there is nothing to copy) ??

new topic     » goto parent     » topic index » view message » categorize

7. Re: child window copies from parent "under" it

Wolf,

I tried (& probably originally also tried) just using "WS_CHILD", and the
result was a *borderless* window, with no caption bar, which isn't really
what I was hoping for; that's why I tried combining the frame and menu
styles that I did.

 And nothing I saw at MS library site said I shouldn't; here's what it said
about WS_CHILD:  Creates a child window. A window with this style cannot
have a menu bar. This style cannot be used with the WS_POPUP style."

So now I have tried, not necessarily for any good reason, "WS_CLIPCHILDREN"
for my parent window, but I get no sysmenu on it to close the main, AND no
sysmenu on the child either, so I can't close either.

I've gotta assume that *someone* has at one time or another for one reason
or another created a "child" window that *works* and isn't strange??

All I'm trying to do is to create an *example* of how to create a child
window, to include with my "examples gateway" for Win32Lib, so if any one
has a better, functional example, please send it to me.

Dan



----- Original Message -----
From: "wolfgang fritz" <wolfritz at KING.IGS.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Sunday, September 17, 2000 7:37 AM
Subject: Re: child window copies from parent "under" it


> To answer my own previous question, and clarify my 'complaint' about Dan's
> peculiar child window....
> All the 'rules' regarding WS_ can be found under/after,  'General Window
> Styles' in win32.hlp.
> According to this, one cannot ( legally ! ) combine:
> WS_DLGFRAME,  WS_SYSMENU,  and WS_CAPTION
> ... and this created the 'strange' window I complained about.
>
> Wolf

new topic     » goto parent     » topic index » view message » categorize

8. Re: child window copies from parent "under" it

Dan
what do you envisage this "child" window doing? What behaviours are you
expecting? I ask this because in Windows, the concept of a window is very
broad. Every control, such as buttons, static text, combo box, etc... , is a
"window". Each of these are attached to a parent window and stuck in place
(unless you explicitly move them in your program). If what you are after is
a window with title bar, etc... that is somehow associated with a parent,
but also independent, maybe you are looking for something like a Multiple
Document Interface (MDI) window?

-----
cheers,
Derek Parnell

>Subject: Re: child window copies from parent "under" it
>
>
>Wolf,
>
>I tried (& probably originally also tried) just using "WS_CHILD", and the
>result was a *borderless* window, with no caption bar, which isn't really
>what I was hoping for; that's why I tried combining the frame and menu
>styles that I did.
>
> And nothing I saw at MS library site said I shouldn't; here's what it said
>about WS_CHILD:  Creates a child window. A window with this style cannot
>have a menu bar. This style cannot be used with the WS_POPUP style."
>
>So now I have tried, not necessarily for any good reason, "WS_CLIPCHILDREN"
>for my parent window, but I get no sysmenu on it to close the main, AND no
>sysmenu on the child either, so I can't close either.
>
>I've gotta assume that *someone* has at one time or another for one reason
>or another created a "child" window that *works* and isn't strange??
>
>All I'm trying to do is to create an *example* of how to create a child
>window, to include with my "examples gateway" for Win32Lib, so if any one
>has a better, functional example, please send it to me.
>
>Dan

new topic     » goto parent     » topic index » view message » categorize

9. Re: child window copies from parent "under" it

On Sun, 17 Sep 2000 20:01:36 -0700, Dan B Moyer wrote:

>...
>
>I've gotta assume that *someone* has at one time or another for one reason
>or another created a "child" window that *works* and isn't strange??
>
>All I'm trying to do is to create an *example* of how to create a child
>window, to include with my "examples gateway" for Win32Lib, so if any one
>has a better, functional example, please send it to me.
>
>Dan

Try *not* using WS_CHILD:

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

If you want a nonsizeable window that you can minimize, try:
or_all( { WS_DLGFRAME, WS_SYSMENU, WS_MINIMIZEBOX } ) )

The fact that you are specifying "MainWindow" as the parent kinda
makes 'aChildWindow' it's child.  WS_CHILD is just a window style...

-- Brian

new topic     » goto parent     » topic index » view message » categorize

10. Re: child window copies from parent "under" it

Brian,

An interesting, "outside the box" idea; but I think what I will probably do
is forget about trying to make a child with borders, and just make an
example using a child window the way it is apparently intended: for a
borderless but effectively sectioned off area of a main window's client area
which can receive stuff,(as Wolf has pointed out to me),  which also moves
with the main.

And I'll take a similar example of a "strange" child out of the "styles"
windows examples in my next version of "Win32Lib Examples Gateway", so as
not to confuse anyone else, :)

Dan






----- Original Message -----
From: "Brian Broker" <bkb at CNW.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Monday, September 18, 2000 2:02 PM
Subject: Re: child window copies from parent "under" it


> On Sun, 17 Sep 2000 20:01:36 -0700, Dan B Moyer wrote:
>
> >...
> >
> >I've gotta assume that *someone* has at one time or another for one
reason
> >or another created a "child" window that *works* and isn't strange??
> >
> >All I'm trying to do is to create an *example* of how to create a child
> >window, to include with my "examples gateway" for Win32Lib, so if any one
> >has a better, functional example, please send it to me.
> >
> >Dan
>
> Try *not* using WS_CHILD:
>
> -- CHILD WINDOW, attached to Main ("parent")
> constant aChildWindow =
>     create( Window, "Child Window", MainWindow, 50, 80, 400, 200,
>             or_all({ WS_DLGFRAME, WS_SYSMENU }))
>
> If you want a nonsizeable window that you can minimize, try:
> or_all( { WS_DLGFRAME, WS_SYSMENU, WS_MINIMIZEBOX } ) )
>
> The fact that you are specifying "MainWindow" as the parent kinda
> makes 'aChildWindow' it's child.  WS_CHILD is just a window style...
>
> -- Brian

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu