Home · News · FAQ · Forums · Privacy Policy · Members List · Contact January 16 2018 12:30:23
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
Crossroads II
The Brick Maze
Escape From ASCII Castle
Third-party showcase
Mountain Party
The Pyramid Maze
Many more...
Other things
Hangman
Delphi Tips/Tutorials
Word Search Generator
Last Seen Users
andrewbroad09:20:13
hoderster12:25:03
_steve_22:00:38
matt 1 day
kelltaire 1 day
discusb 2 days
mickheaton 3 days
megawolt 5 days
russ1291 1 week
paulallenlives 1 week
jimmy53 1 week
Shoutbox
You must login to post a message.

matt
20 November 2017
Having trouble playing the Java games? You'll probably need to use Internet Explorer - Firefox and Chrome no longer support Java. http://www.darnkitty.com/
java-help.php


megawolt
24 January 2017
Hi, guys! Nice to see you still playing here, it is hard to understand the kind of hobby)) but it is great

michael57
26 November 2016
CINDERELLA AIDAN

flakothedog
25 September 2016
Been a while (3 years). Good to see the all-time records are still going strong.

matt
14 May 2016
JAVA problems? Games won't load? Please go here: http://www.darnkitty.com/
java-help.php


xzavierg
05 April 2016
im the best the king of the brick maze

frankef
27 September 2015
hello

megawolt
11 August 2015
Back to second division battles))

gascoyne
21 March 2015
Back from hols & I see the top of the table battle has been hotting up....work to do!

slimboats
20 March 2015
That manic miners quite a cool game, its good fun!

jetsetdanny
16 March 2015
Thanks, discusb!

discusb
15 March 2015
Hats off to you sir.

jetsetdanny
15 March 2015
Return of the King

chrusciel
08 February 2015
hi sunny sunday

chrusciel
07 February 2015
crezy climber

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
discusb51814
paulallenlives34112
mickheaton31268
loz8130260
knucklesandwich28902
megawolt28795
whammydiver28343
more... 
 Crossroads II
lookoutforteng554040
russ1291536210
sonnuvah436135
matt46310
more... 
 Jet Set Willy
lookoutforteng5m2725
more... 
 Blagger
lookoutforteng14579
bungholio7678
more... 
 The Brick Maze
russ129134120
knucklesandwich12625
more... 
 ASCII Castle
lookoutforteng30310
knucklesandwich18440
matt2880
more... 
 JSW Endurance
more... 
Games developed by g2 Ltd Powered by PHP-Fusion version 6 © 2003-2005