-
Aug 23rd, 2009, 03:30 PM
#1
Thread Starter
New Member
Form size and position.
Hello everybody, can anybody tell me, what do I need to do to make my forms position and size remembered. Example: User opens a program on his PC, resize the form, and positions it anywhere he wants, closes the program, then reopens it, and the form opens in position where it was when it was closed, also with the same size when it was closed.
-
Aug 23rd, 2009, 04:45 PM
#2
Fanatic Member
Re: Form size and position.
1. You need your program to create a file and write form size and screen coordinates to it.
2. On your Form_Load event, you open that file, read form size and position data from it and adjust your form properties with new data.
-
Aug 23rd, 2009, 04:53 PM
#3
Thread Starter
New Member
Re: Form size and position.
And, how do i do that, I am a beginner in Visual Basic after all. How would you do that? I suppose that it has something to do with Visual Basic Scripting... ???
-
Aug 23rd, 2009, 06:19 PM
#4
Re: Form size and position.
I use an ini file, but you can also use the registry. read about file handling in the code bank.
Using the registary:
http://www.planet-source-code.com/vb...29083&lngWId=1
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
-
Aug 23rd, 2009, 06:38 PM
#5
Re: Form size and position.
Here is a quick sample using the SaveSetting and GetSetting functions to save the values to the registry.
Code:
Private Sub Form_Load()
Dim lngLeft As Long
Dim lngTop As Long
Dim lngWidth As Long
Dim lngHeight As Long
lngLeft = Val(GetSetting(App.EXEName, "Settings", "Left", "0"))
lngTop = Val(GetSetting(App.EXEName, "Settings", "Top", "0"))
lngWidth = Val(GetSetting(App.EXEName, "Settings", "Width", "0"))
lngHeight = Val(GetSetting(App.EXEName, "Settings", "Height", "0"))
If lngWidth > 0 Then
Me.Move lngLeft, lngTop, lngWidth, lngHeight
End If
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
SaveSetting App.EXEName, "Settings", "Left", Me.Left
SaveSetting App.EXEName, "Settings", "Top", Me.Top
SaveSetting App.EXEName, "Settings", "Width", Me.Width
SaveSetting App.EXEName, "Settings", "Height", Me.Height
End Sub
-
Aug 24th, 2009, 09:05 AM
#6
Thread Starter
New Member
Re: Form size and position.
Thanks a lot, this is a complete solution for what i need!!!
-
Aug 24th, 2009, 02:13 PM
#7
Re: Form size and position.
Now that we've helped you, you can help us by marking the thread as resolved. If you have JavaScript enabled you can do that easily by pulling down the Thread Tools menu and selecting the Mark Thread Resolved item. Also if someone has been particularly helpful you have the ability to affect their forum "reputation" by rating their post. Only those ratings that you give after you have 20 posts will actually count, but in all cases the person you rate will see your rating and know that you appreciate their help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|