Home · News · FAQ · Forums · Privacy Policy · Members List · Contact May 19 2013 02:46:59
Login

Username

Password


Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Games
Manic Miner
Blagger
Jet Set Willy
Kiwitris
Cheese, Louise!
Daily Sudoku
Third-party showcase
Mountain Party
The Pyramid Maze
Many more...
Other things
Hangman
Delphi Tips/Tutorials
Future Games
Last Seen Users
matt01:11:38
flower04:29:35
ukkasukkatak04:34:43
jimbo04:39:22
discusb04:46:55
nemaanadomi04:53:56
jonnyark04:56:36
doochessisade06:16:28
speccyfan07:31:02
rateseiplit08:18:42
bavaqueuedded09:13:49
Shoutbox
You must login to post a message.

jongtfc
15 May 2013
So i've done it again (in my quickest ever time - time-saving deaths at Tool Shed & Under Megatree)

jongtfc
15 May 2013
I got a 104 in jsw and it wouldn't submit :'(

matt
10 May 2013
IF YOU HAD TROUBLE SUBMITTING SCORES... PLEASE TRY AGAIN - THEY SHOULD BE WORKING NOW!!

gascoyne
26 March 2013
@kfckarl...yes, don't go there!

prestocundies123
25 January 2013
I LOVE GAMES AND THAT IS ALL I HAVE TO SAY

kfckarl
09 January 2013
Can anyone help with "Into the depths" and "Crikey"??

khalid
09 January 2013
Wont Display Jet Willy Game

khalid
09 January 2013
ddd

gascoyne
08 November 2012
Hey Johan, which tavern is number 11? You are doing a lot of dying there....want some help?

asukaku
12 October 2012
hey ..

madwe
18 September 2012
Dirge?

superimax
06 September 2012
how do i enter "die mortal" on the jet set willy game ?

pvalums
14 August 2012
How do u play jetset Willy

fat_croc
13 August 2012
re-addicted but struggling to solve the hidden levels on jsw, especially 'into the depths' and 'back..'

asukaku
25 July 2012
hello ..

Shoutbox Archive

Delphi Tips and Tutorials
Tip #2: Saving the position and size of a window between instances

If you want to save the position of your window so that it starts up in the same place as when the user closed it down, the following code will save the window position to the registry. You could put a call to SaveFormPositionToRegistry in the FormDestroy event of your main form. Change the registry key to something more appropriate to your application.

  procedure TfrmExample.SaveFormPositionToRegistry;
  var
    r: TRegistry;
  begin
    r := TRegistry.Create;
    try
      r.RootKey := HKEY_CURRENT_USER;
      if r.OpenKey('\Software\darnkitty.com\Example\Options', True) then
      begin
        r.WriteInteger('PosTop', Top);
        r.WriteInteger('PosLeft', Left);
        r.WriteInteger('PosWidth', Width);
        r.WriteInteger('PosHeight', Height);
        r.CloseKey;
      end;
    finally
      r.Free;
    end;
  end;

The following code will read in the saved values and position the window in the correct place. Once again, change the registry key to something more appropriate to your application.

  procedure TfrmExample.LoadFormPositionFromRegistry;
  var
    r: TRegistry;
  begin
    r := TRegistry.Create;
    try
      r.RootKey := HKEY_CURRENT_USER;
      r.Access := KEY_READ;
      if r.OpenKey('\Software\darnkitty.com\Example\Options', False) then
      begin
        try
          Top := r.ReadInteger('PosTop');
          Left := r.ReadInteger('PosLeft');
          Width := r.ReadInteger('PosWidth');
          Height := r.ReadInteger('PosHeight');
        except
        end;

        r.CloseKey;
      end;
    finally
      r.Free;
    end;
  end;

You would put a call to LoadFormPositionFromRegistry in the FormCreate event of your main form. Remember also to add the Registry unit to the uses clause in your form or else the code will not compile.

Note that there is a try..except block around the ReadIntegers. This is to cover the chance that the key exists and is successfully opened, but the four integers do not exist yet (this may happen the first time the user runs the application). Since this is purely a cosmetic procedure, in my opinion, there is no need to re-raise any exception or otherwise do anything with it.

<< Previous tip Back to tips and tutorials Next tip >>
Google





Current high scores    

 Manic Miner
rod-dy40014
gascoyne37328
whammydiver35999
kookoo6329169
tophambeauclerc29070
gooey27440
bole26600
more... 
 Jet Set Willy
jongtfc23m22*104*
gascoyne18m2570
lookoutforteng1m4813
niallmc732m1110
mickjwright771m438
matt2m364
more... 
 Blagger
discusb30067
jimbo23858
wooze7697
lookoutforteng2862
matt200
more... 
 Kiwitris
nicomic43767
gascoyne21286
wooze19715
lookoutforteng17706
ianfriz3235
matt1407
dave40
more... 
 Cheese, Louise!
more... 

 JSW Endurance
jongtfc  33m 00s
rlee  127m 35s
more... 
Games developed by g2 Technology Ltd Powered by PHP-Fusion version 6 © 2003-2005