restorewindowpos Method
Class: tsbaseform
Expand/Collapse source code of procedure restorewindowpos Source Code
LPARAMETERS tcEntry
LOCAL  lcBuffer, ;
      lcOldError, ;
      lnTop, ;
      lnLeft, ;
      llError, ;
      lnCommaPos, ;
      lcEntry

IF PCOUNT() = 0
  lcEntry = thisform.Caption
ELSE
  lcEntry = tcEntry
ENDIF

lcBuffer = SPACE(10) + CHR(0)
lcOldError = ON('ERROR')

*-- Read the window position from the INI file
IF GetPrivStr("WindowPositions", lcEntry, "", ;
               @lcBuffer, LEN(lcBuffer), ;
               CURDIR() + INIFILE) > 0
  *-- If an error occurs while parsing the string, 
  *-- just ignore the string and use the form's 
  *-- defaults
  ON ERROR llError = .T.
  lnCommaPos = AT(",", lcBuffer)
  lnTop  = VAL(LEFT(lcBuffer, lnCommaPos - 1))
  lnLeft = VAL(SUBSTR(lcBuffer, lnCommaPos + 1))
  ON ERROR &lcOldError
  IF !llError
    thisform.Top = lnTop
    thisform.Left = lnLeft
  ENDIF
ENDIF