The following sample routines, demonstrate how your application could save the position and save of Windows displayed within an application, so the Windows can be restored to the position preferred by each User:
include "ESLReg.inc"
####################################################################################################
subroutine OpenRegistry(string: Title_SV,
string: Mode_SV,
integer: RegId_IV) is
integer RegKey_LIV is REG_CURRENT_USER
string SubKey_LSV
Company_LSV is "MyCorp"
Application_LSV is "AnESLApp"
Version_LSV is "12.4"
copy "Software\\" Company_LSV "\\" Application_LSV "\\" Version_LSV "\\" Title_SV to SubKey_LSV
call OpenReg(RegId_IV, RegKey_LIV, SubKey_LSV, Mode_SV)
if ((errorlevel != REG_E_ERRORFREE) and
((errorlevel != REG_E_NOTFOUND) and
(Mode_SV = "r")))then
send "Error opening registry for mode " Mode_SV " code " errorlevel "\n" to errorlog
end if
####################################################################################################
subroutine SavePosition(string: Object_SV) is
integer Key_LIV
Maximized_LIV
X_LIV
Y_LIV
string Mode_LSV is "w"
ValueName_LSV
Title_LSV
boolean Found_LBV
copy text of Object_SV to Title_LSV
call OpenRegistry(Title_LSV, Mode_LSV, Key_LIV)
if (Key_LIV != 0) then
copy xsize of Object_SV to X_LIV
copy ysize of Object_SV to Y_LIV
copy "Xsize" to ValueName_LSV
call WriteRegNumber(Key_LIV, ValueName_LSV, X_LIV)
copy "Ysize" to ValueName_LSV
call WriteRegNumber(Key_LIV, ValueName_LSV, Y_LIV)
copy xposition of Object_SV to X_LIV
copy yposition of Object_SV to Y_LIV
copy "Xposition" to ValueName_LSV
call WriteRegNumber(Key_LIV, ValueName_LSV, X_LIV)
copy "Yposition" to ValueName_LSV
call WriteRegNumber(Key_LIV, ValueName_LSV, Y_LIV)
call CloseReg(Key_LIV)
end if
####################################################################################################
subroutine RestorePosition(string: Object_SV) is
integer Key_LIV
ValueX_LIV
ValueY_LIV
Max_LIV
Width_LIV
Height_LIV
string Mode_LSV is "r"
ValueName_LSV
Title_LSV
Parent_LSV
boolean Max_LBV
copy text of Object_SV to Title_LSV
call OpenRegistry(Title_LSV, Mode_LSV, Key_LIV)
if (Key_LIV != 0) then
# Even if previously maximum set position to save positions
copy "Xposition" to ValueName_LSV
call ReadRegNumber(Key_LIV, ValueName_LSV, ValueX_LIV)
if (errorlevel = REG_E_ERRORFREE) then
copy "Yposition" to ValueName_LSV
call ReadRegNumber(Key_LIV, ValueName_LSV, ValueY_LIV)
end if
if (errorlevel = REG_E_ERRORFREE) then
change Object_SV position to ValueX_LIV ValueY_LIV
end if
copy "Xsize" to ValueName_LSV
call ReadRegNumber(Key_LIV, ValueName_LSV, ValueX_LIV)
if (errorlevel = REG_E_ERRORFREE) then
copy "Ysize" to ValueName_LSV
call ReadRegNumber(Key_LIV, ValueName_LSV, ValueY_LIV)
end if
if (errorlevel = REG_E_ERRORFREE) then
change Object_SV size to ValueX_LIV ValueY_LIV
end if
call CloseReg(Key_LIV)
end if
####################################################################################################
The "SavePosition" should be called as the window is closed, which could be as the Application closes. The "RestorePosition" must be called immediately after the window is made permanent.
Note. These routines do not fully allow for windows being maximized or minimized, and we would recommend that sizes and position information is relative to the parent window, so that windows are never created larger than their parents. Please contact the ESL Help Desk, if you are would like a complete set of routines to handle this requirement.