In order for this site to work correctly, and for us to improve the site, we need to store a small file (called a cookie) on your computer.
By continuing to use this website, you agree to our cookies and privacy policy.
Home page Home page Home page Home page
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel

QTIPS - Moving Objects the EASY way.

A system routine of long standing called MOVE.WINDOW has really come into its own in version 3.x with the advent of mouse control. Now that users can drag and drop windows and popups etc. with a click of the mouse, they expect the same functionality of your own pop-up calculators, calendars and other R/Basic routines. Having now seen one developer too many struggle with VSPACE, Mouse_Sub, and InRect (not to mention the "is the down/up/left/right request outside the current screen dimensions" problem) the time has finally arrived to document the simple solution. (And yes, I was once one of those unfortunate developers!).

Pre version 3, MOVE.WINDOW took six parameters as shown below.

0001       MOVE.WINDOW(X1, Y1, X2, Y2, Image, ReturnKeyStroke)

These parameters function as follows:

X1 X co-ord of the top left hand corner of the area to move. Y1 Y co-ord of the top left hand corner of the area to move. X2 X co-ord of the bottom right hand corner of the area to move. Y2 Y co-ord of the bottom right hand corner of the area to move. Image The image (as captured by VIDEO.RW) of the entire screen, excluding the status line. This image should be captured BEFORE drawing the object which you subsequently wish to move. Return MOVE.WINDOW uses this parameter to pass back to the calling program the scan code for the keystroke which was used to exit move mode. $!RE!$ With ARev version 3, MOVE.WINDOW now takes nine parameters.

0001       MOVE.WINDOW(X1, Y1, X2, Y2, MouseX, MouseY, Image, Shadow, Mouse)

The additional/changed parameters now function as follows: $!PRe!$ MouseX Normally assigned to null on your own call to MOVE.WINDOW, this parameter returns the X co-ordinate of the mouse at the moment when move mode is terminated, in decimal format.

MouseY As MouseX, but (surprise), the Y co-ordinate.

Shadow Passed as true or false. If true, a border shadow will automatically be drawn at the new position when the move is complete (assuming that your environment is set for shadows).

Mouse The final parameter appears to be used by the system to indicate whether a mouse click initiated move mode (true), or whether good old CF8 was used (false). Moving appears to function identically, however, regardless of this last setting.

For a simple demonstration of the ease and power of this routine in ARev 3, simply run the following program, click and hold near the top left of the screen, and drag away...

0001    Call Video.RW(0, 0, @CrtWide-1, @CrtHigh-1, "R", Image)
0002    Call Move.Window(1, 1, 25, 8, "", "", Image, 1, "")

(and yes, I know Video.RW is a function, but who can be bothered declaring it in a code snippet!). One final warning - obviously, after any move operation, you'll need to reload the special areas recognised by InRect to reflect the new positioning but this is easily accomplished. Wait for the V3 calculator and calendar on Utility Disk 5 for full details!

(Volume 4, Issue 8, Pages 14,15)
Pixel Footer R1 C1 Pixel