summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-01-12 13:12:34 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-01-12 13:12:34 +0000
commitb0219eb7cb90e11a92ec8974e3a9e971c0e0a61b (patch)
tree95293fd0d5149315fdcccc538f9accb03a50b5d6
parentd8cbd342f020d714abcb3f66da0a43d8b4060618 (diff)
downloadfpGUI-b0219eb7cb90e11a92ec8974e3a9e971c0e0a61b.tar.xz
* Fixed MessageDialog crash on exit under Windows.
* Fixed the mbYesNoCancel button order in a MessageDialog. * Extended the FileDialog example for testing purposes of the MessageDialog class.
-rw-r--r--examples/gui/filedialog/filedialog.lpr66
-rw-r--r--src/gui/messagedialog.inc25
2 files changed, 64 insertions, 27 deletions
diff --git a/examples/gui/filedialog/filedialog.lpr b/examples/gui/filedialog/filedialog.lpr
index d61c7743..04de97b5 100644
--- a/examples/gui/filedialog/filedialog.lpr
+++ b/examples/gui/filedialog/filedialog.lpr
@@ -16,6 +16,9 @@ uses
type
+
+ { TMainForm }
+
TMainForm = class(TfpgForm)
private
{@VFD_HEAD_BEGIN: MainForm}
@@ -23,10 +26,14 @@ type
btnSaveFile: TfpgButton;
edFilename: TfpgEdit;
btnQuit: TfpgButton;
+ btnName1: TfpgButton;
+ btnName2: TfpgButton;
{@VFD_HEAD_END: MainForm}
procedure btnQuitClick(Sender: TObject);
procedure btnOpenFileClick(Sender: TObject);
procedure btnSaveFileClick(Sender: TObject);
+ procedure btnMessageBoxClick(Sender: TObject);
+ procedure btnMessageDlgClick(Sender: TObject);
public
procedure AfterCreate; override;
end;
@@ -68,12 +75,26 @@ begin
end;
end;
+procedure TMainForm.btnMessageBoxClick(Sender: TObject);
+begin
+ ShowMessage('This is some pretty cool shit');
+end;
+
+procedure TMainForm.btnMessageDlgClick(Sender: TObject);
+begin
+ TfpgMessageDialog.AboutFPGui('My title here');
+ TfpgMessageDialog.Critical('Something Critical...', 'And this is where the text goes.', mbAbortRetryIgnore, mbAbort);
+ TfpgMessageDialog.Warning('Some Warning...', 'And this is where the text goes.', mbYesNoCancel, mbNo);
+ TfpgMessageDialog.Information('Some Information...', 'And this is where the text goes.', [mbOK], mbNoButton);
+ TfpgMessageDialog.Question('Some Question...', 'Did everything work okay?', mbYesNo, mbNoButton);
+end;
+
procedure TMainForm.AfterCreate;
begin
inherited AfterCreate;
{@VFD_BODY_BEGIN: MainForm}
Name := 'MainForm';
- SetPosition(100, 100, 419, 138);
+ SetPosition(197, 147, 419, 138);
WindowTitle := 'File dialog test';
MinWidth := 300;
MinHeight := 135;
@@ -84,15 +105,8 @@ begin
Name := 'btnOpenFile';
SetPosition(8, 8, 80, 23);
Text := 'Open File...';
- AllowAllUp := False;
- Embedded := False;
FontDesc := '#Label1';
- GroupIndex := 0;
- ImageMargin := 3;
ImageName := '';
- ImageSpacing := -1;
- ModalResult := 0;
- ShowImage := True;
OnClick := @btnOpenFileClick;
end;
@@ -102,15 +116,8 @@ begin
Name := 'btnSaveFile';
SetPosition(8, 34, 80, 23);
Text := 'Save File...';
- AllowAllUp := False;
- Embedded := False;
FontDesc := '#Label1';
- GroupIndex := 0;
- ImageMargin := 3;
ImageName := '';
- ImageSpacing := -1;
- ModalResult := 0;
- ShowImage := True;
OnClick := @btnSaveFileClick;
end;
@@ -131,18 +138,33 @@ begin
SetPosition(329, 107, 80, 23);
Anchors := [anRight,anBottom];
Text := 'Quit';
- AllowAllUp := False;
- Embedded := False;
FontDesc := '#Label1';
- GroupIndex := 0;
- ImageMargin := 3;
ImageName := 'stdimg.Quit';
- ImageSpacing := -1;
- ModalResult := 0;
- ShowImage := True;
OnClick := @btnQuitClick;
end;
+ btnName1 := TfpgButton.Create(self);
+ with btnName1 do
+ begin
+ Name := 'btnName1';
+ SetPosition(148, 8, 119, 27);
+ Text := 'Message Box';
+ FontDesc := '#Label1';
+ ImageName := '';
+ OnClick := @btnMessageBoxClick;
+ end;
+
+ btnName2 := TfpgButton.Create(self);
+ with btnName2 do
+ begin
+ Name := 'btnName2';
+ SetPosition(272, 8, 131, 27);
+ Text := 'Message Dialog';
+ FontDesc := '#Label1';
+ ImageName := '';
+ OnClick := @btnMessageDlgClick;
+ end;
+
{@VFD_BODY_END: MainForm}
end;
diff --git a/src/gui/messagedialog.inc b/src/gui/messagedialog.inc
index cb838378..23497a0f 100644
--- a/src/gui/messagedialog.inc
+++ b/src/gui/messagedialog.inc
@@ -1219,6 +1219,25 @@ var
i: TfpgMsgDlgBtn;
begin
Result := 0;
+
+ // try known sets first
+ if Buttons = mbYesNoCancel then
+ begin
+ { todo: At some stage the StyleManager can give use the correct button
+ order based on the OS and Window Manager. }
+ Result := 3;
+ sl.Add(cMsgDlgBtnText[mbYes] + '=' + IntToStr(Ord(mbYes)));
+ sl.Add(cMsgDlgBtnText[mbNo] + '=' + IntToStr(Ord(mbNo)));
+ sl.Add(cMsgDlgBtnText[mbCancel] + '=' + IntToStr(Ord(mbCancel)));
+ case DefaultButton of
+ mbYes: lDefault := 0;
+ mbNo: lDefault := 1;
+ mbCancel: lDefault := 2;
+ end;
+ Exit;
+ end;
+
+ // if we got here, try all known buttons.
for i := Low(TfpgMsgDlgBtn) to High(TfpgMsgDlgBtn) do
begin
if i in Buttons then
@@ -1382,11 +1401,7 @@ end;
destructor TfpgMessageDialog.Destroy;
begin
- while FButtonList.Count > 0 do
- begin
- TfpgButton(FButtonList.Last).Free;
- FButtonList.Remove(FButtonList.Last);
- end;
+ FButtonList.Clear;
FInformativeText.Free;
inherited Destroy;
end;