This method checks the position of a window on a timer. If the location or size of the window has changed, it is reported in the texteditor. The resizehandler function in Liberty BASIC captures the resize event, but not the event of the user moving a window. This API method traps both events.
nomainwin struct Rect, nX1 as long, nY1 as long,_ nX2 as long, nY2 as long texteditor #1.t, 10,10,200,150 Open "Test" for window as #1 #1 "trapclose [quit]" hWin=hwnd(#1) Calldll #user32, "GetWindowRect",_ hWin as long, Rect as struct, ret as boolean ulx=Rect.nX1.struct uly=Rect.nY1.struct lrx=Rect.nX2.struct lry=Rect.nY2.struct #1.t "UpperLeftX is: ";str$(ulx) #1.t "UpperLeftY is: ";str$(uly) #1.t "LowerRightX is: ";str$(lrx) #1.t "LowerRightY is: ";str$(lry) #1.t "Width is ";str$(lrx-ulx) #1.t "Height is ";str$(lry-uly) timer 1000, [checkSize] wait [quit] timer 0 close #1 end [checkSize] Calldll #user32, "GetWindowRect",_ hWin as long, Rect as struct, ret as boolean ulx2=Rect.nX1.struct uly2=Rect.nY1.struct lrx2=Rect.nX2.struct lry2=Rect.nY2.struct 'check new values against previous values 'if there is a change, reset values and report them if (ulx2<>ulx) or (uly2<>uly) or (lrx2<>lrx) or (lry2<>lry) then ulx=ulx2:uly=uly2:lrx=lrx2:lry=lry2 #1.t "!cls" #1.t "UpperLeftX is: ";str$(ulx) #1.t "UpperLeftY is: ";str$(uly) #1.t "LowerRightX is: ";str$(lrx) #1.t "LowerRightY is: ";str$(lry) #1.t "Width is ";str$(lrx-ulx) #1.t "Height is ";str$(lry-uly) end if wait