I have a custom made dialog winform. On it I have a label, textbox and 2 buttons (OK and Cancel). It also declares and defines overloaded execute methods for passing different parameter list.
Dialog Winform is called as follows:
var theDialog := new InputMsgBox;
if theInputB.Execute('Awesome StackOverflow','Enter Text?',s,var s) = DialogResult.OK then
begin
Invalidate;
SetText(s);
end;
Dialog Winform execute is defined as follow:
method InputMsgBox.Execute(Title, theMessage, defaultanswer:string;var thevalue:string): DialogResult;
begin
result := DialogResult.Cancel;
Requesttext.Text:=themessage;
Requesttext.Enabled:=true;
Requesttext.Visible:=true;
InputTextBox.Text:=defaultanswer;
InputTextBox.Enabled:=true;
InputTextBox.Visible:=true;
CancelBtn.Enabled:=true;
CancelBtn.Visible:=true;
Okbtn.Enabled:=true;
Okbtn.Visible:=true;
self.ShowDialog;
Result := self.DialogResult;
thevalue:=InputTextBox.Text;
end;
When execute method returns back to the caller, it always returns DialogResult.Cancel even when you click on OKBtn.
The Buttons' dialogresult are set accordingly.
I have set the AcceptButton and CancelButton on the Dialog winform.
I can't figure out why the showdialog method is always returning DialogResult.Cancel.
UPDATE After doing some test, I found out that my other custom-made dialog window works fine when display by calling showdialog = DialogResult.Ok. So, I checked both of them to see if there are some differences in their properties setting and there is absolutely no difference. I don't understand it. Thanks in advance,