Recent

Author Topic: "Child" form is uneditable  (Read 2979 times)

Joek

  • New Member
  • *
  • Posts: 27
"Child" form is uneditable
« on: April 02, 2021, 05:23:51 pm »
This has certainly been addressed several times, but I really couldn't find a solution to my problem: when I open a form in a form, the child form becomes uneditable. Everything is OK separately. I attached a sample. MDIForm and MDIChild settings do not resolve the issue. Can anyone advise me?

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: "Child" form is uneditable
« Reply #1 on: April 02, 2021, 06:42:37 pm »
Hi!

Don't try to create the child form!
It is already created : look in the project1.lpr

On your click you have to do with the child:

* Set top and left
* Child.Parent := MainForm;
* child.Show   - NOT: child.showModal

That's all

Winni




Joek

  • New Member
  • *
  • Posts: 27
Re: "Child" form is uneditable
« Reply #2 on: April 02, 2021, 07:44:11 pm »
Oops... This error occurred while creating an example quickly. Modify Project1.lpr to create only the MainForm. Your board doesn't work - the form won't appear in MainForm, however the application won't end with an error. This means that the form is hidden in the background. I need to create formulas at runtime.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: "Child" form is uneditable
« Reply #3 on: April 02, 2021, 10:24:11 pm »
Hi!

My code works like a charme - I did it a lot of times.

Perhaps you placed the child outside  the screen:
If you set Child as a parent to the MainForm then you place the child relative to the MainForm.
This means if you set top/left of the child to 0/0 it appears in the topleft corner of the mainform.

Winni

dseligo

  • Hero Member
  • *****
  • Posts: 1682
Re: "Child" form is uneditable
« Reply #4 on: April 02, 2021, 10:45:24 pm »
My code works like a charme - I did it a lot of times.
I tried your code and it doesn't work, it has same problem as OP is experiencing.
I attached test project. Button in child form can be pressed, but Edit is not reacting.

I use Lazarus 2.0.10 on Windows 10.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: "Child" form is uneditable
« Reply #5 on: April 02, 2021, 11:37:01 pm »
My code works like a charme - I did it a lot of times.
I tried your code and it doesn't work, it has same problem as OP is experiencing.
I attached test project. Button in child form can be pressed, but Edit is not reacting.

I use Lazarus 2.0.10 on Windows 10.

Hi!

Your code works without a problem.
To make it better visible I changed the color of the child to red.
No other changes.
The Edit component works like it should.

See attachment

Winni

PS.:  Lin64, Laz 2.0.12, fpc 3.2

Joek

  • New Member
  • *
  • Posts: 27
Re: "Child" form is uneditable
« Reply #6 on: April 02, 2021, 11:39:08 pm »
For Winni:
I fixed a problem with the "invisible" window. You can already see where it should be, but ... it doesn't solve my problem - TEdit can't be edited.

For Dseligo:
Yes, I confirm, your Mditest behaves the same for me, I use Win7, Lazarus 2..0.10

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: "Child" form is uneditable
« Reply #7 on: April 02, 2021, 11:50:52 pm »
Hi!

Strange, strange ...

Tested the code with Win7 and Edit1 does not work.
I add a procedure for Edit1.onClick and  that works.

Don't know  why Windows again wants a special treatment.

Winni

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: "Child" form is uneditable
« Reply #8 on: April 03, 2021, 01:22:04 am »
Hi!

I looked in the code of a running App where I did exactly what the example is doing and solved the problem:

You have to set the borderstyle of the child to bsNone !!

Then you can use the Edit component also in Windows!

Winni

dseligo

  • Hero Member
  • *****
  • Posts: 1682
Re: "Child" form is uneditable
« Reply #9 on: April 03, 2021, 01:43:38 am »
Hi!

I looked in the code of a running App where I did exactly what the example is doing and solved the problem:

You have to set the borderstyle of the child to bsNone !!

Then you can use the Edit component also in Windows!

Winni
Yes, it's working in Windows 10 if I set Borderstyle to bsNone.
Although, then border icons and ability to resize and move MDI form is lost. Which greatly limits the purpose of MDI form.
And it looks just like screenshot you sent from Linux.

Joek

  • New Member
  • *
  • Posts: 27
Re: "Child" form is uneditable
« Reply #10 on: April 03, 2021, 11:31:12 am »
Thank you Jamie! Your example was inspiring (Windows.SetParent (f.Handle, Handle)). I didn't find any weird things on your app. Edit1 can be focused with the mouse.
I present an abbreviated version of the functional procedure for creating and opening a child window in Lazarus / Win7.
But why so many complications for such a simple thing? Bad mark for Lazarus ...
Thanks to all for your help!!!
Code: Pascal  [Select][+][-]
  1. procedure TMainForm.FormChildClick(Sender: TObject);
  2. var
  3.   f: TFChild1;
  4. begin
  5.    f := TFChild1.Create(self);
  6.    f.BorderStyle:=bsSizeToolWin;
  7.    Windows.SetParent(f.Handle, Handle);
  8.    f.Left := 0;
  9.    f.Top := 0;
  10.    f.Show;
  11. end;

Joek

  • New Member
  • *
  • Posts: 27
Re: "Child" form is uneditable
« Reply #11 on: April 03, 2021, 11:39:55 pm »
For newcomers who are groping, like me. I'm adding a functional skeleton to call forms from the mainform. Have fun!
Thanks again Jamie!

 

TinyPortal © 2005-2018