SavePAram




Sub LoadWindowPos(Window As Object, AppID As String _
Section As String, Key As String, Optional NoSize)
'Loads the position of a window saved by SaveWindowPos from

'the registry/ini

'If no size if specified the size of the window is not

'changed.

Dim PosString As String, Settings() As String, intSet(0 To 3) As Integer
If IsMissing(NoSize) Then NoSize = False
PosString = GetSetting(AppID, Section, Key, "")
If PosString = "" Then Exit Sub
ParseString PosString, Settings()
With Window
If 0 >= UBound(Settings) Then intSet(0) = .Left Else intSet(0) = CInt(Settings(0))
If 1 >= UBound(Settings) Then intSet(1) = .Top Else intSet(1) = CInt(Settings(1))
If Not NoSize Then
If 2 <= UBOUND(SETTINGS) THEN INTSET(2) = .WIDTH ELSE INTSET(2) _
= CINT(SETTINGS(2))
IF 3 <= UBOUND(SETTINGS) THEN INTSET(3) = .HEIGHT ELSE INTSET(3) _
= CINT(SETTINGS(3))
.MOVE INTSET(0), INTSET(1), INTSET(2), INTSET(3)
ELSE
.MOVE INTSET(0), INTSET(1)
END IF
END WITH
END SUB

SUB SAVEWINDOWPOS(APPID AS STRING, WINDOW AS OBJECT, SECTION _
AS STRING, KEY AS STRING)
'SAVE THE SIZE AND POSITION OF A WINDOW IN THE REGISTRY/INI

DIM INISETTING AS STRING
WITH WINDOW
INISETTING = .LEFT & " " & .TOP & " " & .WIDTH & " " & .HEIGHT
END WITH
SAVESETTING APPID, SECTION, KEY, INISETTING
END SUB

Window specifies a form, AppID, Section and Key specify the
Ini or registry entry in which the value should be stored and
NoSize specifies that the window should not be resized.
The ParseString function can be found below.










( saveparam.html )- by Paolo Puglisi - Modifica del 17/12/2023