Lazarus

Programming => LCL => Topic started by: badmintonfan on January 26, 2023, 05:42:08 am

Title: [Solved]error release when memo.setfocus
Post by: badmintonfan on January 26, 2023, 05:42:08 am
What's wrong on my code?
Title: Re: error release when memo.setfocus
Post by: dseligo on January 26, 2023, 06:34:39 am
What's wrong on my code?

You can't focus controls in OnCreate event. Put your code in OnShow event.
Title: Re: error release when memo.setfocus
Post by: badmintonfan on January 26, 2023, 10:38:36 am
What's wrong on my code?

You can't focus controls in OnCreate event. Put your code in OnShow event.
I did it alreay,but the same error message had been released
Title: Re: error release when memo.setfocus
Post by: KodeZwerg on January 26, 2023, 11:22:07 am
Never ever explicit check for "True" or "False". That is really bad code up there.
Code: Pascal  [Select][+][-]
  1. if (not Edit1.Enabled) then Memo1.SetFocus;
Title: Re: error release when memo.setfocus
Post by: dseligo on January 26, 2023, 10:36:24 pm
What's wrong on my code?

You can't focus controls in OnCreate event. Put your code in OnShow event.
I did it alreay,but the same error message had been released

It doesn't look like you did that in your original post. You try to focus Memo1 in method named FormCreate, which is default when you double click on form or if you click on OnCreate event in object inspector.

I think you didn't do put your code in OnShow event properly. I mean: if you get this error, then focusing in OnCreate is still happening.

I suggest you make small project that shows this behaviour and post it here.
Title: Re: error release when memo.setfocus
Post by: VTwin on January 27, 2023, 12:59:28 am
It is almost impossible to help if you do not post the project or code.
Title: Re: error release when memo.setfocus
Post by: badmintonfan on January 27, 2023, 05:36:04 am
It is almost impossible to help if you do not post the project or code.
Please look at it
Title: Re: error release when memo.setfocus
Post by: dseligo on January 27, 2023, 05:40:29 am
It is almost impossible to help if you do not post the project or code.
Please look at it

I suggest to you again: make small project that shows this behaviour and post it here.
If you don't want to, you could check in object inspector that OnCreate event points to FormCreate method and not to FormShow method.
Everything else is pure guessing from our side.
Title: Re: error release when memo.setfocus
Post by: badmintonfan on February 06, 2023, 04:36:08 am
It is almost impossible to help if you do not post the project or code.
Please look at it

I suggest to you again: make small project that shows this behaviour and post it here.
If you don't want to, you could check in object inspector that OnCreate event points to FormCreate method and not to FormShow method.
Everything else is pure guessing from our side.
I finally found the issue,it's my mistake,thanks a lot!
TinyPortal © 2005-2018