The new "OnResize" handler

  OnResize:
    UseData winMainProcedure
    Invoke pegObject, [hWnd], IDC_WINMAIN_BTN0, 0, 4  ; Note the new parameter
    Invoke pegObject, [hWnd], IDC_WINMAIN_BTN2, 2, 4  ; Note the new parameter
    Invoke pegObject, [hWnd], IDC_WINMAIN_BTN6, 6, 4  ; Note the new parameter
    Invoke pegObject, [hWnd], IDC_WINMAIN_BTN8, 8, 4  ; Note the new parameter
    Return (TRUE)
; End OnResize
EndU

The new "pegPosition" routine

  pegObject Frame hWnd, idControl, pegPosition, pegBorder
    Local hButton, pBox : RECT
    ; 1. Get a handle on the button
    Invoke GetWindowItem, [hWnd], [idControl]
    Mov [hButton], Eax

    ; 2. Get the new size of the window's client area
    Invoke GetClientRect, [hWnd], Addr pBox

    Mov Ebx, [pegPosition]
    Cmp Ebx, 0
    Jz >.position_0
    Cmp Ebx, 2
    Jz >.position_2
    Cmp Ebx, 6
    Jz >.position_6
    Cmp Ebx, 8
    Jz >>.position_8

    ; An incorrect "pegPosition" parameter has been supplied.
    ; Return to the main code immediately with a False flag.
    Return (FALSE)

  .position_0
    Invoke SetLeft, [hButton], [pegBorder]
    Invoke SetTop, [hButton], [pegBorder]
    Return(TRUE)

  .position_2
    Invoke GetWidth, [hButton]		; Get the button's current width
    Add Eax, [pegBorder]		; Add the border
    Mov Ebx, [pBox.right]		; Retrieve the parent's width
    Sub Ebx, Eax			; Subtract the button's (plus border) width
    Invoke SetLeft, [hButton], Ebx	; Set the button's left position to the new value
    Invoke SetTop, [hButton], [pegBorder]
    Return(TRUE)

  .position_6
    Invoke SetLeft, [hButton], [pegBorder]
    Invoke GetHeight, [hButton]		; Get the button's current height
    Add Eax, [pegBorder]		; Add the border
    Mov Ebx, [pBox.bottom]		; Retrieve the parent's height
    Sub Ebx, Eax			; Subtract the button's (plus border) height
    Invoke SetTop, [hButton], Ebx	; Set the button's top position to the new value
    Return(TRUE)

  .position_8
    Invoke GetWidth, [hButton]		; Get the button's current width
    Add Eax, [pegBorder]		; Add the border
    Mov Ebx, [pBox.right]		; Retrieve the parent's width
    Sub Ebx, Eax			; Subtract the button's (plus border) width
    Invoke SetLeft, [hButton], Ebx	; Set the button's left position to the new value

    Invoke GetHeight, [hButton]		; Get the button's current height
    Add Eax, [pegBorder]		; Add the border
    Mov Ebx, [pBox.bottom]		; Retrieve the parent's height
    Sub Ebx, Eax			; Subtract the button's (plus border) height
    Invoke SetTop, [hButton], Ebx	; Set the button's top position to the new value
    Return(TRUE)
  EndF