Recent

Author Topic: MDI Application problem  (Read 21013 times)

xtm

  • New Member
  • *
  • Posts: 12
MDI Application problem
« on: November 27, 2020, 10:13:59 am »
Hi,

i have some problem with an MDI application, which i'm worrking on.

I'd also added TPageControl to MDIChild.

I'd made MainFrm as MDI Form, Child as MDI Child. I've implemented such code:

Code: Pascal  [Select][+][-]
  1. KontaFrm:=TKontaFrm.Create(Self);
  2.   KontaFrm.Parent:=MainFrm.MainPanel;
  3.   {$ifdef WINDOWS}
  4.   KontaFrm.Top:= 0;
  5.   KontaFrm.Left:= 0;
  6.   KontaFrm.Width:= MainFrm.MainPanel.Width - 4;
  7.   KontaFrm.Height:= MainFrm.MainPanel.Height - 4;
  8.   {$else}
  9.   KontaFrm.Align:= alClient;
  10.   {$endif}
  11.   if eKmPasek.Text<>'' then KontaFrm.Konta.Text:=eKmPasek.Text;
  12.   KontaFrm.NazwaOkna;
  13.   KontaFrm.PKFiltr.Text:=KontaFrm.Konta.Text;
  14.   KontaFrm.DKFiltr.Text:=KontaFrm.Konta.Text;
  15.   KontaFrm.OpFiltr.Text:=KontaFrm.Konta.Text;
  16.   KontaFrm.Strony.ActivePage:=KontaFrm.Operacje;
  17.   eKmPasek.Clear;
  18.   KontaFrm.Show;
  19.   KontaFrm.SetFocus;

Problem is, that i can select, switch, focus on Edits, Cobmobox fields with only TAB button. It's no reaction on mouse clicks. Left click doesn't get control active, and right click runs no system popupmenu. There is simply no reaction on mouse clicks.

Where can be a problem? Thank's for all help.

xtm

  • New Member
  • *
  • Posts: 12
Re: MDI Application problem
« Reply #1 on: November 27, 2020, 02:52:56 pm »
It was not really elegant, but still only way, that's worked.

I've added OnClick event with SetFocus method to every Control, which was on MDIChild (luckily there was not much of it).

If anyone will have better solution, a'm all ears.

Thaddy

  • Hero Member
  • *****
  • Posts: 10784
Re: MDI Application problem
« Reply #2 on: November 27, 2020, 03:25:40 pm »
Just a remark: MDI applications are deprecated (by microsoft) for the past 20 years and never worked well with Lazarus.
I suggest to re-engineer to an SDI lay-out. Unless you want your software to have an old school look deliberately.
« Last Edit: November 27, 2020, 03:27:43 pm by Thaddy »

PeterX

  • Sr. Member
  • ****
  • Posts: 380
Re: MDI Application problem
« Reply #3 on: May 16, 2021, 10:55:14 am »
There's a lot of people out there that say MDI is dead.

Doing a Forum Search with 'MDI' gives a long list of matches ..
https://forum.lazarus.freepascal.org/index.php?action=search;advanced;search=MDI

Today I saw that it works a little bit, with qt5 ..
https://forum.lazarus.freepascal.org/index.php/topic,51066.msg374371.html#msg374371

« Last Edit: May 16, 2021, 11:37:43 am by PeterX »
usually using latest Lazarus release version with Windows 10

jamie

  • Hero Member
  • *****
  • Posts: 4568
Re: MDI Application problem
« Reply #4 on: May 16, 2021, 05:35:43 pm »
Only those that don't understand it will reject it, mean while they attempt the same thing by putting forms inside of forms which for me also works well.. But I like to use a borderless form so I can design my own border and caption area.
The only true wisdom is knowing you know nothing

PeterX

  • Sr. Member
  • ****
  • Posts: 380
Re: MDI Application problem
« Reply #5 on: May 16, 2021, 06:19:58 pm »
.. mean while they attempt the same thing by putting forms inside of forms which for me also works well..
I have a very old project which I can't simply "re-engineer to an SDI lay-out".
...
..
Today I tried some of these TABbed and SomethingElse .. solutions, but nothing looked usable for me.

And today I tried this:   make a TPanel the Parent of one of my "MDIChild" window .. and it worked.
My Child Window is only visible inside the TPanel area.

Next I have to find a way to manage my few TForms that have been Delphi MDI child windows, long time ago ..
usually using latest Lazarus release version with Windows 10

jamie

  • Hero Member
  • *****
  • Posts: 4568
Re: MDI Application problem
« Reply #6 on: May 16, 2021, 06:29:00 pm »
use this to set the parent for windows instead of the Parent property...

Windows.SetParent(TheNewchildForm.handle, TheParentForm.Handle);

and after each change to the borderstyle you will need to reset the Parent via this method..

The only true wisdom is knowing you know nothing

PeterX

  • Sr. Member
  • ****
  • Posts: 380
Re: MDI Application problem
« Reply #7 on: May 16, 2021, 08:59:43 pm »
use this to set the parent for windows instead of the Parent property...

Windows.SetParent(TheNewchildForm.handle, TheParentForm.Handle);

and after each change to the borderstyle you will need to reset the Parent via this method..
Thanks a lot !

I would have spent hours and hours to dig that out ..  Thumbs up !
usually using latest Lazarus release version with Windows 10

PeterX

  • Sr. Member
  • ****
  • Posts: 380
Re: MDI Application problem
« Reply #8 on: May 16, 2021, 11:29:54 pm »
Hm, looks easy at first. But then ..


[example project] ...
« Last Edit: May 16, 2021, 11:35:27 pm by PeterX »
usually using latest Lazarus release version with Windows 10

PeterX

  • Sr. Member
  • ****
  • Posts: 380
Re: MDI Application problem
« Reply #9 on: May 16, 2021, 11:55:17 pm »
attachement, with comments in Title Bar ..
usually using latest Lazarus release version with Windows 10

PeterX

  • Sr. Member
  • ****
  • Posts: 380
Re: MDI Application problem
« Reply #10 on: May 17, 2021, 10:34:59 am »
Just found this :

http://www.oocities.org/br/hipernetjr/lmdi/index_ptbr.html

I will take a look at this sourcecode, maybe I will find what I am missing.
(I also do not need the full Delphi MDI functionality to make my program running ..)
usually using latest Lazarus release version with Windows 10

PeterX

  • Sr. Member
  • ****
  • Posts: 380
Re: MDI Application problem
« Reply #11 on: May 17, 2021, 09:12:58 pm »
Funny thing to play around with ..

usually using latest Lazarus release version with Windows 10

jamie

  • Hero Member
  • *****
  • Posts: 4568
Re: MDI Application problem
« Reply #12 on: May 18, 2021, 01:00:40 am »
if you use a borderless window for the child forms you can process the LM_NCHITTEST so that you can send back modified info for example for the location of where the mouse is.. For example, you can report it to be over a caption area, a drag area etc..

 With this, you can create a custom form that has a special title bar, Thumb Tac etc...

 It's a change from the boring windows standard forms which by the way, do not follow the themes when you do that..  :o

 But who likes those themes anyways....
 
 I could most likely punch out a quick demo on how to create a form to look this way...
The only true wisdom is knowing you know nothing

PeterX

  • Sr. Member
  • ****
  • Posts: 380
Re: MDI Application problem
« Reply #13 on: May 18, 2021, 12:37:59 pm »
I could most likely punch out a quick demo on how to create a form to look this way...
Yes please !

Because I only found this, here in the Forum ..
https://forum.lazarus.freepascal.org/index.php/topic,34633.msg227372.html#msg227372


In the meantime I got forward a little bit.
I can send a ( simulated ''maximized'' ) Child Window to the back, to make the other ones visible again ..
« Last Edit: May 18, 2021, 12:40:18 pm by PeterX »
usually using latest Lazarus release version with Windows 10

PeterX

  • Sr. Member
  • ****
  • Posts: 380
Re: MDI Application problem
« Reply #14 on: May 18, 2021, 09:41:44 pm »
.. you can process the LM_NCHITTEST so that you can send back modified info for example for the location of where the mouse is..
message LM_NCHitTest helped me setting the focus to the actual ChildWindow, thanks !

Code: Pascal  [Select][+][-]
  1. procedure TChildForm.LMNCHitTest(var Msg: TLMNCHitTest);
  2. begin
  3.    inherited;
  4.    Self.BringToFront;
  5.    if Self.Focused = FALSE
  6.      then Self.SetFocus;
  7. ...
  8. ..
  9.  

But it detects the Mouse Pointer ( .. position) only over the frame of the ChildWindow, not over the TMemo ..
« Last Edit: May 18, 2021, 09:46:22 pm by PeterX »
usually using latest Lazarus release version with Windows 10

 

TinyPortal © 2005-2018