summaryrefslogtreecommitdiff
path: root/examples/gui/filedialog/filedialog.lpr
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-08-17 14:35:33 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-08-17 14:35:33 +0000
commit003a991ccc0b05ce9a939d27313dd5ee0d9f4390 (patch)
tree551a6dfc94dfff01f77b84f19d5a255ce66f5606 /examples/gui/filedialog/filedialog.lpr
parent76df5b245da72230e5491c51e049c19337884ac1 (diff)
downloadfpGUI-003a991ccc0b05ce9a939d27313dd5ee0d9f4390.tar.xz
* 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.
Diffstat (limited to 'examples/gui/filedialog/filedialog.lpr')
-rw-r--r--examples/gui/filedialog/filedialog.lpr98
1 files changed, 98 insertions, 0 deletions
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.
+