[Lazarus] TForm.ModalResult := mrOk problem FIXED

FreeMan freeman35 at delphiturkiye.com
Tue Nov 26 12:58:54 CET 2013


Thank you for your answer
nearly 5-6 six hours trace all my code line by line, I found problem, 
Problem is in my code.
for ModalResult := MrOk need user & password control then can set, so 
its in procedure, user & password check in my component(I was write 
nearly 7 years ago in delphi) I convert it to lazarus.
this is my old code in my component db site, linux permission is so high 
exeption work correctly.
   try
..........
   except
    Result := [lerr_LoginName, lerr_Password, lerr_ReadInfo, 
lerr_Expired, lerr_InActive];
   end;

this is new code, if application can't access or any connetion problem, 
error now popup to user
   try
...........
   except
    on E: Exception do begin
      Result := [lerr_LoginName, lerr_Password, lerr_ReadInfo, 
lerr_Expired, lerr_InActive];
       MessageDlg(PChar(Application.Title), E.Message, mtError, [mbOK], 0);
    end;
   end;


My mistake is: "if LoginResult = [lerr_LoginName]then"  this my old 
code. this is not correct, it has to be (lerr_LoginName in LoginResult)  
because more then one set items return and not aqual to one.

On my system (lazarus db etc.)has permission so no error, its work, but 
test system not setted correctly, I can't debug just add 
showmessage(''). No any error and no normal working and I been false 
alarm :)
Problem on me :( not enoughcalculate probability

26-11-2013 11:40 tarihinde, Antonio Fortuny yazdı:
>
> Le 25/11/2013 16:33, FreeMan a écrit :
>> on /lazarus/lcl/forms.pp
>> line 662:
>> property ModalResult : TModalResult read FModalResult write 
>> FModalResult;
>> TCustomForm class property. its just variable
>>
>> on virtualbox system:
>> I add TButton on form and TButton.ModalResult set to MrOk. and click 
>> to Button then similar work TForm.ModalResult := MrOk.
>> I don't wanna use tbutton, How to run My code "F.ModalResult := MrOk."
>>
> I can reasonably suspect that the code ran from another form will not 
> have any impact on the form to be closed. In a normal way the form to 
> be closed responds first to any event (windows local event queue). 
> When the event code which has been fired finishes with something like
>
>     [Self.]ModalResult := mrCancel
>
> the forms manager does its job an does whatever has to be done with 
> the ModalResult. Most of the time the form is closed when called with 
> ShowModal. Without ShowModal the form still displays.
> So when you execute (in FormMain):
>
> TFormMain.SomeProcedure;
> begin
>     OtherForm.ModalResult := mrOK
> end;
>
> nothing happens with OtherForm as no event was running.
> If you need the form itself to close follonwing a ShowModal, you have 
> to create an internal event like the one a timer fires. This is my way 
> to proceed when I need to manage a timeout on a form but always under 
> the range of a previous ShoModal.
>
> Hope this hepls to understand.
>
> Antonio.
>
>
>
> -- 
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>





More information about the Lazarus mailing list