Solved

Application restarting at the same location

Posted on 1998-08-04
5
150 Views
Last Modified: 2010-05-03
I want my application to start at the same location from where it is closed. To be brief if the user moves the window to some other location and quit the application, when he restarts the application it should start from where it is quited.
 I want to konw how I can get the co-ordinates while applicaiton termination, save them in registry and use them while restart.
0
Comment
Question by:monalisa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 9

Accepted Solution

by:
cymbolic earned 10 total points
ID: 1467727
You have to define your own scheme for detailing where you are in your program.  VB does not support any identification method regarding which routine you are in.  Your best bet is to have a common variable, that you set each time you enter a routine, then save when the app is terminated.  On the front end, you'll need a case statement to start the saved routine when your program is loaded.  

You are on the right track for human useability.  It's unfortunate that so many of our expensive commercial programs are too dumb to do the same thing.

In terms of saving and restoring your memory variable, you can use the registry by using the GetSetting and SaveSetting routines provided in VB. These are in the help system and provide direct update and access to the registry.  Also, you could just as well use a small file saved in your App.Path directory to retain and return your variable, accessed and updated by file i/o.  
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1467728
In the main form's unload event, place the following code:
Private Sub Form_Unload(Cancel As Integer)
  SaveSetting appname := "MyApp", section := "Startup", key := "Top", setting := Me.Top
  SaveSetting appname := "MyApp", section := "Startup", key := "Left", setting := Me.Left
  SaveSetting appname := "MyApp", section := "Startup", key := "Height", setting := Me.Height
  SaveSetting appname := "MyApp", section := "Startup", key := "Width", setting := Me.Width
End Sub

Then, in the code which starts your app (Sub Main?), place the following code:
Sub Main()

  Dim fTop As Single
  Dim fLeft As Single
  Dim fHeight As Single
  Dim fWidth As Single

  fTop = GetSetting(appname := "MyApp", section := "Startup", key := "Top", default := Form1.Top)
  fLeft = GetSetting(appname := "MyApp", section := "Startup", key := "Left", default := Form1.Left)
  fHeight = GetSetting(appname := "MyApp", section := "Startup", key := "Height", default := Form1.Height)
  fWidth = GetSetting(appname := "MyApp", section := "Startup", key := "Width", default := Form1.Width)

  Form1.Move fLeft, fTop, fWidth, fHeight
End Sub
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1467729
cymbolic:
Huh?
0
 

Author Comment

by:monalisa
ID: 1467730
I am sorry for the delayed response, lot of thanks for your help.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1467731
Unless you understood cymbolic's answer (I believe it was an answer to another question), please reject it sp that I may post my answer.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Getting warning: You are about to delete 1 row(s) 9 61
Spell Check in VB6 13 147
fso.FolderExists("\\server\HiddenFolder$") 4 96
VBA - If Bookmark = "XXBOOKMARKXX" then 15 66
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question