KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to organize open windows in development mode
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac & Win
Published On: April 13, 2017

When opening too many windows while developing, it will be difficult for a developer to keep track all open windows on the screen in a structured way. The code below will help save time for the developer and also organize all different open windows such as Forms, Form methods, Methods, Triggers, and Object Methods.

// ----------------------------------------------------------
// Method name : organizeWindows
// Description : Method will organize open windows
// ----------------------------------------------------------
C_LONGINT($element_l)
C_LONGINT($height_l)
C_LONGINT($left_l)
C_LONGINT($shift_l)
C_LONGINT($top_l)
C_LONGINT($width_l)
C_LONGINT($winRef_l)
C_TEXT($title_t)
ARRAY LONGINT($windowRefs_al;0)

$left_l:=80
$top_l:=100
$width_l:=800
$height_l:=600

$winRef_l:=Frontmost window

While ($winRef_l >0)

  $title_t:=Get window title($winRef_l)

  If (($title_t="Method:@")\
    | ($title_t="Form Method:@")\
    | ($title_t="Form:@")\
    | ($title_t="Trigger:@")\
    | ($title_t="Object Method:@"))

     APPEND TO ARRAY ($windowRefs_al;$winRef_l)

  End if

  $winRef_l:=Next window ($winRef_l)

End while

$shift_l:=0

For ($element_l;1;Size of array($windowRefs_al))

  SET WINDOW RECT($left_l+$shift_l;\
    $top_l+$shift_l;\
    $left_l+$width_l+$shift_l;\
    $top_l+$height_l+$shift_l;\
    $windowRefs_al{$element_l})

  $shift_l:=$shift_l+20

  If ($shift_l>=100)

    $shift_l:=0

  End if

End for



- Here is an example of open windows



- This can be done using the "Execute Method" window:



- After executing the method as shown below, it will organize all the open windows in development mode: