KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility method that returns the resized width or height of a form
PRODUCT: 4D | VERSION: 13.3 | PLATFORM: Mac & Win
Published On: July 11, 2013

Here is a utility method that returns the resized width or height value of a form.

  // Method: GET_FORM_RESIZED_VALUE
  // Parameters
  // $1 - "width" or "height"
  //
  // Return
  // $0 - Resized point value
  // ----------------------------------------------------


C_LONGINT($0)
C_TEXT($1;$toget_t)
C_LONGINT(laswl;laswt;laswr;laswb)
C_LONGINT($wl;$wt;$wr;$wb)
C_LONGINT($lastvalue_l;$currentvalue_l)

If (Form event=On Load)
  GET WINDOW RECT(laswl;laswt;laswr;laswb;Current form window)
  $0:=0

Else

  If (Count parameters>=1)
    $toget_t:=$1

    GET WINDOW RECT($wl;$wt;$wr;$wb;Current form window)

    Case of
     : ($toget_t="width")
      $lastvalue_l:=laswr-laswl
      $currentvalue_l:=$wr-$wl
      laswr:=$wr
      laswl:=$wl
      $0:=$currentvalue_l-$lastvalue_l

     : ($toget_t="height")
      $lastvalue_l:=laswb-laswt
      $currentvalue_l:=$wb-$wt
      laswb:=$wb
      laswt:=$wt
      $0:=$currentvalue_l-$lastvalue_l

    End case
  End if
End if


Recommendation
To use this method properly, be sure to execute it once during the On Load form event to allow the starting values to be set.