Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

keeping user settings - form placement 1

Status
Not open for further replies.

GAORR

Programmer
Nov 22, 2001
48
CA
Assume an app had 5 forms, 1 being the main form and when closed would close all the others. Also assume the user had all forms opened and each moved to a position of their prefernece on the screen. How would one 'remember' where these forms were last placed such that the next time the app is run and the forms displayed they would be displayed in the same position as when the app was closed.

Thanks for your time.
 
One approach might be to get the Top, Left, Height, and Width properties of each form immediately prior to being unloaded, and then to store these value in the Registry.

Good Luck
 
On your Form_Unload event of each form add the following code. Just a note it is wise to make sure that the Top and Left aren't negative numbers. I had problems where if a user minimized the form, and then right clicked to close the form, it would show the form at -30000 top, and -30000 left. So it appeared that the form was lost.
[tt]
' Save Form Settings
strTemp = frmMain.Top
If Val(strTemp) > 0 Then
SaveSetting "MyApp", "Config", "FormTop", strTemp
Else
SaveSetting "MyApp", "Config", "FormTop", "100"
End If
strTemp = frmMain.Left
If Val(strTemp) > 0 Then
SaveSetting "MyApp", "Config", "FormLeft", strTemp
Else
SaveSetting "MyApp", "Config", "FormLeft", "100"
End If
[/tt]
Then on the form Load procedure you reset the position of the form.
[tt]
' Get Form Settings
strTemp = Trim(GetSetting("MyApp", "Config", "FormTop"))
If Val(strTemp) > 0 Then
frmMain.Top = Val(strTemp)
End If
strTemp = Trim(GetSetting("MyApp", "Config", "FormLeft"))
If Val(strTemp) > 0 Then
frmMain.Left = Val(strTemp)
End If
[/tt] Craig, mailto:sander@cogeco.ca

"Procrastination is the art of keeping up with yesterday."

I hope my post was helpful!!!
 
There is another very important thing to remember:
Screen resolution​

If your screen resolutionis let's say 1600 by 1200 and when you close your forms some forms are in the lower right corner, if user then changes resolution let's say to 1024 by 768 and then loads the form it will be displayed minimized and you cannot do anything with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top