1. w32Edge vs. w32AltEdge
- Posted by Jon Snyder <jongsnyder at hotmail.com> Aug 21, 2001
- 419 views
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? 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? 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?
2. Re: w32Edge vs. w32AltEdge
- Posted by Derek Parnell <ddparnell at bigpond.com> Aug 21, 2001
- 409 views
----- 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.
3. Re: w32Edge vs. w32AltEdge
- Posted by Derek Parnell <ddparnell at bigpond.com> Aug 23, 2001
- 400 views
----- Original Message ----- From: "Jon Snyder" <jongsnyder at hotmail.com> To: "EUforum" <EUforum at topica.com> Subject: RE: w32Edge vs. w32AltEdge > > > Derek Parnell wrote: > > ----- Original Message ----- > > From: "Jon Snyder" <jongsnyder at hotmail.com> > > To: "EUforum" <EUforum at topica.com> > > Sent: Wednesday, August 22, 2001 5:09 AM > > 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? > > Derrek, > Thanks for the clarification, and the sample code. > > Maybe you should change it so that instead of putting {w32Edge, -20} one > could write {1, -20} the "1" translating to 100% of the window size. > The only problem with this is that if someone wanted to use 100% by > itself, it would just translate to one pixel. Maybe a constant that > means 100% would be better. Just a thought Well, w32Edge sort of does mean 100% for width and height parameters, which is what I'd meant it for anyway. I really didn't think it useful for the left and top parameters. Infact, now that I think it through a bit more, maybe we should get rid of w32AltEdge and just use w32Edge. For the left and top parameters, it would mean the 100% of the parent sizes and for the width and height is would 100% also. If no one complains about this, I'll get rid of w32AltEdge constant. ---- Derek.