Re: w32Edge vs. w32AltEdge

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

----- Original Message -----
From: "Jon Snyder" <jongsnyder at hotmail.com>
To: "EUforum" <EUforum at topica.com>
Subject: w32Edge vs. w32AltEdge


> In win32lib What is the difference between w32Edge and w32AltEdge?  The
> documentation doesn't make it very clear.  When should i use one and
> when should i use the other?

Hi Jon,
sorry about the poor docs. That is something that can always be improved.

As you know, the create() function requires a top, left, width and height
parameter.
w32Edge refers to the "extreme" edge of the parent for the specific
parameter. For the Left is means the leftmost edge, for Top it means the
topmost edge, for Width it means the rightmost edge and for Height it means
the bottommost edge.

w32AltEdge is only meant to be used for the Left and Top parameters. In this
case it refers to the "other" extreme edge. For Left this is the rightmost
edge, for Top it means the bottommost edge. For the Width and Height
parameters it is is identical to w32Edge. Maybe this should change?

> I was creating a button and using w32Edge to determine the x and y
> positions,  but the button wouldn't show up in the window.  I wanted the
> button to be in the lower right corner of the window.  The code looked
> something like this.
>
> constant BUTTON = create( PushButton, "Ok", MAIN_WINDOW, { w32Edge,
> -(BORDER + BUTTON_WIDTH) }, {w32Edge, -(BORDER + BUTTON_HEIGHT)},
> BUTTON_WIDTH, BUTTON_HEIGHT, 0)
>
> Should i use w32AltEdge instead?

Yes.

> When i created a MleText box it lined up with the right and bottom edges
> when i had {w32Edge, -BORDER} as the width and height of the control,
> but when i setCtlSize when the window was resized i had to use a
> different value.  Should i have used w32AltEdge when i was resizing?


No. For the setCtlSize function, the parameters to supply are the new width
and new height. So w32Edge is correct here.

Here is a little demo program.
-------------------
include win32lib.ew
without warning

object VOID
-- Stop the flickering.
VOID = classDefaults (Window, {{CCwinstyle, 0}})

constant MAIN_WINDOW = create(Window, "cc", 0, 0, 0, 400, 400, 0)

constant BORDER = 2,
         BUTTON_WIDTH = 50,
         BUTTON_HEIGHT = 30

constant BUTTON = create( PushButton, "Ok", MAIN_WINDOW, { w32AltEdge,
 -(BORDER + BUTTON_WIDTH) }, {w32AltEdge, -(BORDER + BUTTON_HEIGHT)},
 BUTTON_WIDTH, BUTTON_HEIGHT, 0)

 -- Create an auto-wordwrap MLE field.
 constant FLD = create(MleText, "", MAIN_WINDOW, 5, 5, w32Edge, 200,
            {   WS_CHILD,
                WS_VISIBLE,
                WS_TABSTOP,
                WS_VSCROLL,
                WS_BORDER,
                ES_LEFT,
                ES_MULTILINE})

-- Handle window resizing.
procedure rs(atom style, atom x, atom y)
    integer maxh

    maxh = (200 + BORDER + BUTTON_HEIGHT)
    if style != SIZE_MINIMIZED then
      if y > maxh then
       setCtlSize(FLD, {w32Edge,-BORDER}, 200)

       setRect(BUTTON,{ w32AltEdge, -(BORDER + BUTTON_WIDTH) },
{w32AltEdge, -(BORDER + BUTTON_HEIGHT)},

                     BUTTON_WIDTH, BUTTON_HEIGHT, 1)
    end if
  end if

end procedure
onResize[MAIN_WINDOW] = routine_id("rs")

WinMain(MAIN_WINDOW, 0)
-------------------
cheers,
Derek.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu