From 003a991ccc0b05ce9a939d27313dd5ee0d9f4390 Mon Sep 17 00:00:00 2001 From: graemeg Date: Fri, 17 Aug 2007 14:35:33 +0000 Subject: * Implemented a FileOpen and FileSave dialog. Both are the same class. It's not 100% yet. See ToDo list in header of gui_dialogs unit. * Minor bug fix in ComboBox component and added missing (required) properties. * Fixed a bug in TfpgCustomGrid.Destroy. Creating a decendant of TfpgCustomGrid caused a crash in the destructor. * Fixed bug in ListBox where scrollbar did not move with mouse wheel input. * Added a new FileDialog example project. --- examples/gui/filedialog/filedialog.lpr | 98 ++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 examples/gui/filedialog/filedialog.lpr (limited to 'examples/gui/filedialog/filedialog.lpr') diff --git a/examples/gui/filedialog/filedialog.lpr b/examples/gui/filedialog/filedialog.lpr new file mode 100644 index 00000000..a5ff4d2a --- /dev/null +++ b/examples/gui/filedialog/filedialog.lpr @@ -0,0 +1,98 @@ +program filedialog; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Classes, + fpgfx, + gui_form, + gui_dialogs, + gui_button, + gui_edit, + gui_label; + + +type + TMainForm = class(TfpgForm) + private + btnQuit: TfpgButton; + btnOpenFile: TfpgButton; + btnSaveFile: TfpgButton; + edFilename: TfpgEdit; + procedure btnQuitClick(Sender: TObject); + procedure btnOpenFileClick(Sender: TObject); + procedure btnSaveFileClick(Sender: TObject); + public + constructor Create(AOwner: TComponent); override; + end; + +{ TMainForm } + +procedure TMainForm.btnQuitClick(Sender: TObject); +begin + Close; +end; + +procedure TMainForm.btnOpenFileClick(Sender: TObject); +var + dlg: TfpgFileDialog; +begin + dlg := TfpgFileDialog.Create(nil); + try + if dlg.RunOpenFile then + edFilename.Text := dlg.FileName; + finally + dlg.Free; + end; +end; + +procedure TMainForm.btnSaveFileClick(Sender: TObject); +var + dlg: TfpgFileDialog; +begin + dlg := TfpgFileDialog.Create(nil); + try + if dlg.RunSaveFile then + edFilename.Text := dlg.FileName; + finally + dlg.Free; + end; +end; + +constructor TMainForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + WindowTitle := 'File dialog test'; + SetPosition(100, 100, 500, 400); + + btnOpenFile := CreateButton(self, 10, 10, 110, 'Open File...', @btnOpenFileClick); + btnSaveFile := CreateButton(self, 10, btnOpenFile.Bottom + 8, 110, 'Save File...', @btnSaveFileClick); + + edFilename := CreateEdit(self, 10, btnSaveFile.Bottom + 15, Width - 20, 24); + edFilename.Text := ''; + + btnQuit := CreateButton(self, 415, 370, 80, 'Quit', @btnQuitClick); + btnQuit.ImageName := 'stdimg.Quit'; + btnQuit.ShowImage := True; + btnQuit.Anchors := [anRight, anBottom]; + + btnOpenFile.TabOrder := 0; +end; + +procedure MainProc; +var + frm: TMainForm; +begin + fpgApplication.Initialize; + frm := TMainForm.Create(nil); + frm.Show; + fpgApplication.Run; +end; + +begin + MainProc; +end. + -- cgit v1.2.3-70-g09d2