How to fill the 'gaps' when sheets are closed caused by the ever cascaded opening of sheets

Back Up Next

Author: Eric Aling
Accessed:

Annoying, isn't. Every time you open and close a sheet, the next time you open it, it's opened on the 'next' position. With this little algorithm, coded only in your highest window ancestor, open gaps will be used instead of taking the next cascaded position. You must have an ancestor window for this from which you inherit your sheets. In this ancestor do the following: Declare the following SHARED variables:


/* hold the number of open sheets */ 
integer si_count 

/* array with info if a position is ued or not */
integer si_win[] 

Declare the following INSTANCE variable:


int ii_count /* the current screen number */

In the open event code:


integer li_i 

/* increase the number of sheets */ 

si_count++

/* check if there is a gap */ 

FOR li_i = 1 TO UpperBound(si_win)
	IF si_win[li_i] = 0 THEN
		ii_count = li_i
		EXIT
	END IF 
NEXT 

/* if there is, li_count will it, otherwise, all is full and a new position is created at the end */ 

IF ii_Count = 0 THEN ii_Count = si_Count 

/* save in the array that this new position is used */ 

si_win[ii_count] = 1 

/* move the window to the new position */

This.Move((ii_count - 1) * 75,(ii_count - 1) * 75)

In the close event code:


/* free the position */ 

si_win[ii_count] = 0 

/* decrease the number of open sheets */ 

si_count --

Voila!

Back Up Next