Ignore:
Timestamp:
Dec 22, 2016, 6:01:41 PM (8 years ago)
Author:
chronos
Message:
  • Added: Remember forms dimensions.
  • Added: Remember recent opened files.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r27 r28  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
    9   ExtCtrls, ComCtrls, types, LCLType;
     9  ExtCtrls, ComCtrls, types, LCLType, ULastOpenedList, URegistry, Registry;
    1010
    1111type
     
    1414
    1515  TFormMain = class(TForm)
     16    LastOpenedList1: TLastOpenedList;
    1617    MainMenu1: TMainMenu;
    1718    MenuItem1: TMenuItem;
     
    4041    Timer1: TTimer;
    4142    procedure FormActivate(Sender: TObject);
     43    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    4244    procedure FormCreate(Sender: TObject);
    4345    procedure FormDestroy(Sender: TObject);
    4446    procedure FormShow(Sender: TObject);
     47    procedure LastOpenedList1Change(Sender: TObject);
    4548    procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    4649      Shift: TShiftState; X, Y: Integer);
     
    6467    MousePos: TPoint;
    6568    Activated: Boolean;
     69    procedure OpenRecentClick(Sender: TObject);
    6670  public
    6771    procedure EraseBackground(DC: HDC); override;
     
    9498end;
    9599
     100procedure TFormMain.OpenRecentClick(Sender: TObject);
     101begin
     102  Core.ProjectOpen(TMenuItem(Sender).Caption);
     103end;
     104
    96105procedure TFormMain.EraseBackground(DC: HDC);
    97106begin
     
    120129    TempBitmap.SetSize(View.SrcRect.Right - View.SrcRect.Left,
    121130      View.SrcRect.Bottom - View.SrcRect.Top);
    122     //TempBitmap.BeginUpdate(True);
     131    TempBitmap.BeginUpdate(True);
    123132    TempBitmap.Canvas.Brush.Color := clBlack;
    124133    TempBitmap.Canvas.FillRect(0, 0, TempBitmap.Width, TempBitmap.Height);
    125134    View.DestRect := Bounds(0, 0, PaintBox1.Width, PaintBox1.Height);
    126     //Bitmap.PaintToCanvas(TempBitmap.Canvas, View.SrcRect);
    127     Bitmap.PaintToBitmap(TempBitmap, View.SrcRect);
    128     //TempBitmap.EndUpdate(False);
     135    Bitmap.PaintToCanvas(TempBitmap.Canvas, View.SrcRect);
     136    //Bitmap.PaintToBitmap(TempBitmap, View.SrcRect);
     137    TempBitmap.EndUpdate(False);
    129138    PaintBox1.Canvas.StretchDraw(View.DestRect, TempBitmap);
    130139    //PaintBox1.Canvas.Draw(0, 0, TempBitmap);
     
    147156end;
    148157
     158procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
     159begin
     160  Core.PersistentForm1.Save(Self);
     161  LastOpenedList1.SaveToRegistry(RegContext(HKEY(Core.ApplicationInfo1.RegistryRoot),
     162    Core.ApplicationInfo1.RegistryKey + '\RecentFiles'));
     163end;
     164
    149165procedure TFormMain.FormDestroy(Sender: TObject);
    150166begin
     
    154170procedure TFormMain.FormShow(Sender: TObject);
    155171begin
     172  Core.PersistentForm1.Load(Self);
     173  LastOpenedList1.LoadFromRegistry(RegContext(HKEY(Core.ApplicationInfo1.RegistryRoot),
     174    Core.ApplicationInfo1.RegistryKey + '\RecentFiles'));
     175end;
     176
     177procedure TFormMain.LastOpenedList1Change(Sender: TObject);
     178begin
     179  LastOpenedList1.LoadToMenuItem(MenuItemRecentFiles, OpenRecentClick);
    156180end;
    157181
Note: See TracChangeset for help on using the changeset viewer.