Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-11

TForm.ModalResult := mrOk problem

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

FreeMan

Hello,
I have a strange problem.
I have last svn fpc and lazarus on kubuntu 13.10 x64

FRM_Log_In := TFRM_Log_In.Create(AOwner);
Result := FRM_Log_In.ShowModal;

"FRM_Log_In.ModalResult := mrOk;" this code work on my system, work mean, form close and move to after "FRM_Log_In.Showmodal;" "FRM_Log_In.ModalResult := mrCancel;" working too. I have a virtualbox and installed kubuntu 13.10 x64 there too. not install any fpc or lazarus.
when copy my application to virtualbox, form showing and all component (label, edit, etc) work fine. "FRM_Log_In.ModalResult := mrCancel;" working too but
"FRM_Log_In.ModalResult := mrOk;" never and ever working :)) no any exception, its work like this code not working. I mean for the test, I add showmessage('hello'); after this line, message not showing. But application is still working normal.
And this is just in virtualbox system, on my system everytking is okey. Has anyone have idea ??
Thank you

FreeMan
to FreeMan

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."

25-11-2013 16:45 tarihinde, FreeMan yazd?:

Show quoted text 31 lines
Hello, I have a strange problem. I have last svn fpc and lazarus on kubuntu 13.10 x64 FRM_Log_In := TFRM_Log_In.Create(AOwner); Result := FRM_Log_In.ShowModal; "FRM_Log_In.ModalResult := mrOk;" this code work on my system, work mean, form close and move to after "FRM_Log_In.Showmodal;" "FRM_Log_In.ModalResult := mrCancel;" working too. I have a virtualbox and installed kubuntu 13.10 x64 there too. not install any fpc or lazarus. when copy my application to virtualbox, form showing and all component (label, edit, etc) work fine. "FRM_Log_In.ModalResult := mrCancel;" working too but "FRM_Log_In.ModalResult := mrOk;" never and ever working :)) no any exception, its work like this code not working. I mean for the test, I add showmessage('hello'); after this line, message not showing. But application is still working normal. And this is just in virtualbox system, on my system everytking is okey. Has anyone have idea ?? Thank you -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
zeljko
to FreeMan
FreeMan wrote 9 lines
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."
It should work. Where do you exactly set ModalResult := mrOK ?

z.

Show quoted text 41 lines
25-11-2013 16:45 tarihinde, FreeMan yazd?: > Hello, > I have a strange problem. > I have last svn fpc and lazarus on kubuntu 13.10 x64 > > FRM_Log_In := TFRM_Log_In.Create(AOwner); > Result := FRM_Log_In.ShowModal; > > "FRM_Log_In.ModalResult := mrOk;" this code work on my system, work > mean, form close and move to after "FRM_Log_In.Showmodal;" > "FRM_Log_In.ModalResult := mrCancel;" working too. > I have a virtualbox and installed kubuntu 13.10 x64 there too. not > install any fpc or lazarus. > when copy my application to virtualbox, form showing and all component > (label, edit, etc) work fine. "FRM_Log_In.ModalResult := mrCancel;" > working too but > "FRM_Log_In.ModalResult := mrOk;" never and ever working :)) no any > exception, its work like this code not working. I mean for the test, I > add showmessage('hello'); after this line, message not showing. But > application is still working normal. > And this is just in virtualbox system, on my system everytking is okey. > Has anyone have idea ?? > Thank you > > > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Antonio Fortuny
to FreeMan: on /lazarus/lcl/forms.pp line 662: property ModalResult : TModalResult read FModalResult…

Le 25/11/2013 16:33, FreeMan a ?crit :

Show quoted text 10 lines
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.

FreeMan
to Antonio Fortuny

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?:

Show quoted text 48 lines
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 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus