Re: Default attributes in new Win32lib

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

R.Stowasser wrote:
> 
> Hi Derek,
> 
> I still did not find out why you generally changed WS_CHILD to
> WS_CLIPPINGCHILD (WS_CHILD + WS_CLIPSIBLINGS) for all the controls. The
> following code will not work correctly for me.(Win95/Win98) The picture
> is from Winlib's DemoRecources folder. What would be wrong with the
> commented statements, which should indicate the default attributes
> according to Win32lib's documentation?

Ok, you got me there. The docs are wrong. Sorry.

Here is the longer explanation...

The graphics model I'm working from is that each control is on its own
layer. This doesn't impact anything until controls overlap.  The 
bottom layer is the parent Window. All its child controls have layers
which are above the parent, meaning that when a child control overlaps
the parent window (a very normal thing), you get to see the child
control and not the portion of the parent that is overlapped. 

Now when you get child controls of the same parent (i.e. siblings) that
overlap, one will obscure a portion of the other, depending on the
relative 'height' of the layers they own. The higher one is seen and
the lower one is obscured. 

The height of a control's layer is first determined by the order that you
create the child controls in. The first child control is the highest layer
and subsequent child controls are on progressively lower layers.

You can alter the relative height of layers by using the moveZOrder()
routine. 

Each control, including the parent window, has canvas on which pixels are
drawn. All pixels drawn on a canvas share the same layer as the owning
control. This means that if one draws pixels onto a canvas that is 
on a lower layer than an overlapping control, the pixels in the overlapped
area will be obscured.
 
> --  code generated by Win32Lib IDE
> 
> include Win32Lib.ew
> without warning
> 
> --  Window Win
> constant Win = createEx( Window, "Window1", 0, 50, 50, 400, 300, 0, 0 )
> constant BM = createEx( Bitmap, "Bitmap2", Win, 68, 44, 260, 172, 0, 0 )
> setBitmap( BM,"largetiles.bmp")
> constant Edit = createEx( EditText, "Hello World", Win,4,156,144,32,0,0)
> --constant Edit = createEx( EditText, "Hello World", Win,4,156,144,32,
> -- {WS_CHILD, WS_VISIBLE,ES_AUTOHSCROLL,ES_LEFT,WS_BORDER,WS_TABSTOP},0)
> setHint( Edit,"This is an EditText")
> setFont( Edit,"Arial",12,Normal+Bold)
> setBitmap( Edit,"largetiles.bmp")
> constant PB = createEx( PushButton, "Exit", Win,268, 64, 104, 36, 0, 0 )
> --constant PB = createEx( PushButton, "Exit", Win, 268, 64, 104, 36,
> --  {WS_CHILD,WS_VISIBLE,BS_PUSHBUTTON,WS_TABSTOP}, 0 )
> setFont( PB,"Arial",12,Normal+Bold)
> 
> procedure Win_onAfterEvent (integer self, integer event, sequence params)
> sequence result
>    setPenWidth(Win,3)
>    drawLine(Win, 10,10,390,260)
>    setFont(Win, "Arial", 10, Bold+Italic)
>    result=drawText(Win,"Fourscore and twenty years ago, our fathers,...",
>             {5,50, 140, 120}, DT_WORDBREAK, 4, 0, 0)
> end procedure
> setHandler( Win, w32HAfterEvent, routine_id("Win_onAfterEvent"))
> 
> procedure PB_onClick (integer self, integer event, sequence params)
>       closeWindow(Win)
> end procedure
> setHandler( PB, w32HClick, routine_id("PB_onClick"))
> 
> WinMain( Win,Normal )

To get the effect you are (I think) trying for you can either create the
bitmap control last, so it appears on the bottom of the child control
layers, or use the moveZOrder() routine to place it on the bottom.

Also, (re)drawing pixels after *every* event is not a recommended way of
doing stuff. Try using just the w32HPaint event instead.

Now if my model needs improvement, I'm happy to consider any changes that
people may suggest. I'm wide open to improvements.

-- 
Derek Parnell
Melbourne, Australia

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

Search



Quick Links

User menu

Not signed in.

Misc Menu