OnResize:
UseData winMainProcedure
Invoke pegObject, [hWnd], IDC_WINMAIN_BTN0, 0, 4
Invoke pegObject, [hWnd], IDC_WINMAIN_BTN1, 1, 4
Invoke pegObject, [hWnd], IDC_WINMAIN_BTN2, 2, 4
Invoke pegObject, [hWnd], IDC_WINMAIN_BTN3, 3, 4
Invoke pegObject, [hWnd], IDC_WINMAIN_BTN4, 4, 4
Invoke pegObject, [hWnd], IDC_WINMAIN_BTN5, 5, 4
Invoke pegObject, [hWnd], IDC_WINMAIN_BTN6, 6, 4
Invoke pegObject, [hWnd], IDC_WINMAIN_BTN7, 7, 4
Invoke pegObject, [hWnd], IDC_WINMAIN_BTN8, 8, 4
Return (TRUE)
; End OnResize
EndU
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, 1
Jz >>.position_1
Cmp Ebx, 2
Jz >>.position_2
Cmp Ebx, 3
Jz >>.position_3
Cmp Ebx, 4
Jz >>.position_4
Cmp Ebx, 5
Jz >>.position_5
Cmp Ebx, 6
Jz >>.position_6
Cmp Ebx, 7
Jz >>.position_7
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_1
Invoke GetWidth, [hButton] ; Get the button's current width
Mov Ebx, [pBox.right] ; Retrieve the parent's width
Sub Ebx, Eax ; Subtract the button's (plus border) width
Shr Ebx, 1 ; Divide Ebx by 2
Invoke SetLeft, [hButton], Ebx ; Set the button's left position to the new value
Invoke SetTop, [hButton], [pegBorder]
Return(TRUE)
.position_2
Invoke GetWidth, [hButton] ; Get the button's current width
Add Eax, [pegBorder] ; Add a 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_3
Invoke SetLeft, [hButton], [pegBorder]
Invoke GetHeight, [hButton] ; Get the button's current height
Mov Ebx, [pBox.bottom] ; Retrieve the parent's height
Sub Ebx, Eax ; Subtract the button's (plus border) height
Shr Ebx, 1 ; Divide Ebx by 2
Invoke SetTop, [hButton], Ebx ; Set the button's top position to the new value
Return(TRUE)
.position_4
Invoke GetWidth, [hButton] ; Get the button's current width
Mov Ebx, [pBox.right] ; Retrieve the parent's width
Sub Ebx, Eax ; Subtract the button's (plus border) width
Shr Ebx, 1 ; Divide Ebx by 2
Invoke SetLeft, [hButton], Ebx ; Set the button's left position to the new value
Invoke GetHeight, [hButton] ; Get the button's current height
Mov Ebx, [pBox.bottom] ; Retrieve the parent's height
Sub Ebx, Eax ; Subtract the button's (plus border) height
Shr Ebx, 1 ; Divide Ebx by 2
Invoke SetTop, [hButton], Ebx ; Set the button's top position to the new value
Return(TRUE)
.position_5
Invoke GetWidth, [hButton] ; Get the button's current width
Add Eax, [pegBorder] ; Add a 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
Mov Ebx, [pBox.bottom] ; Retrieve the parent's height
Sub Ebx, Eax ; Subtract the button's (plus border) height
Shr Ebx, 1 ; Divide Ebx by 2
Invoke SetTop, [hButton], Ebx ; Set the button's top position to the new value
Return(TRUE)
.position_6
Invoke SetLeft, [hButton], [pegBorder]
Invoke GetHeight, [hButton] ; Get the button's current height
Add Eax, [pegBorder] ; Add a 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_7
Invoke GetWidth, [hButton] ; Get the button's current width
Mov Ebx, [pBox.right] ; Retrieve the parent's width
Sub Ebx, Eax ; Subtract the button's (plus border) width
Shr Ebx, 1 ; Divide Ebx by 2
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 a 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 a 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 a 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