Recent

Author Topic: MDI Application problem  (Read 24841 times)

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: MDI Application problem
« Reply #15 on: May 18, 2021, 10:33:33 pm »
But it detects the Mouse Pointer ( .. position) only over the frame of the ChildWindow, not over the TMemo ..

Of course, because "over the memo" it's clear that you're in the client area. N(on)C(lient)HitTest is only sent to give you the oportunity of ignoring or processing hits in the non-client area (borders frame, caption bar, etc.)
« Last Edit: May 18, 2021, 10:35:20 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

PeterX

  • Sr. Member
  • ****
  • Posts: 404
Re: MDI Application problem
« Reply #16 on: May 18, 2021, 10:57:18 pm »
.. N(on)C(lient)HitTest ..
Okay .. helps to know what it means ..  :o

But how to catch "any" message to recognize that I am "anywhere" in my ClientWindow ?

Probably by hacking into
Code: Pascal  [Select][+][-]
  1.     procedure WndProc( var TheMessage: TLMessage); override;

??
usually using latest Lazarus release version with Windows 10

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: MDI Application problem
« Reply #17 on: May 19, 2021, 12:36:12 am »
I am a little confused as to what you want at this time... BUt, here is some code that shows you how to get mouse inputs. Here I use the left button down but you use others like the mouse move etc..

 If you use mouse move then you need to call other functions to see what control is under it of course..
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,Lmessages;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     procedure Button1Click(Sender: TObject);
  17.   private
  18.  
  19.   public
  20.    Procedure UserInput(sender:Tobject; Msg:Cardinal);
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.lfm}
  29.  
  30. { TForm1 }
  31. Procedure Tform1.UserInput(sender:Tobject; Msg:Cardinal);
  32. Begin
  33.   If Msg = LM_LBUTTONDOWN THen beep;
  34. end;
  35.  
  36. procedure TForm1.Button1Click(Sender: TObject);
  37. begin
  38.  Application.AddOnUserInputHandler(@UserInput, true);
  39. end;
  40.  
  41. end.
  42.  
  43.  
The only true wisdom is knowing you know nothing

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: MDI Application problem
« Reply #18 on: May 19, 2021, 12:55:53 am »
Hello.

For MDI and docking forms you may use mseide-msegui.

Here a MSE-MDI Demo video.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

PeterX

  • Sr. Member
  • ****
  • Posts: 404
Re: MDI Application problem
« Reply #19 on: May 19, 2021, 01:02:30 am »
I am a little confused as to what you want at this time...
In my earlier Code Examples, even when selecting another ChildWindow than the first one,
the Input Focus stayed on the first created ChildWindow.
=> So when hitting the Keyboard, the Chars still appeared in the TEdit of the first created ChildWindow.

Now, in my last code example '04',  I (mis)used LM_NCHitTest to change the Input Focus (=> TMemo) to the actually selected ChildWindow.

But now, still the Focus only changes if I cross the borders/frame of another ChildWindow.
=> I want the Input Focus to move to the ChildWindow where the mouse is over.
( Does this violate any Microsoft UserInterface GuideLines ? .. )

The misbehaviore appears when two ChildWindows do overlap
(and so I do not touch any border of a underlying ChildWindow when moving the mouse cursor)
 .. in my Code Example.


.. difficult to describe in words, I should be able to upload a video of that misbehaviore
(or You compile my last Example and play around with it, moving and touching the ChildWindows with Your Mouse Pointer ..)

Probably Your
Code: Pascal  [Select][+][-]
  1. Application.AddOnUserInputHandler(@UserInput, true);
is the way out for me. I'll try that tomorrow ..  O:-)
« Last Edit: May 19, 2021, 01:16:51 am by PeterX »
usually using latest Lazarus release version with Windows 10

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: MDI Application problem
« Reply #20 on: May 19, 2021, 01:32:21 am »
I just created a simple app with two forms, use the second for as the child forms...

first form has a button to create these child forms.

The child forms has a TEDIT on them...

When I put a few in the window and use the mouse to click between them, the EDIT control for the one I clicked on becomes focused.

So that must not be your problem..

I think what you want is to wave the mouse across the forms and have them automatically jump forward and become focused without clicks, is that it ?
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: MDI Application problem
« Reply #21 on: May 19, 2021, 02:07:32 am »
Ok, I put this in a project... because it got to tedious otherwise..

This shows how to move over the forms and it detects what forms they are and it will also pass through the children controls..

this only works in the client area..

if you want also the non-client response too, then you need to use the LM_NCMouseMove or hittest.

I have a TEDIT on the forms hugging the side of the client so you can see how if you hover over a child first before a client area it will still be able to seek down through until it finds the window.

Demo Attached;
The only true wisdom is knowing you know nothing

PeterX

  • Sr. Member
  • ****
  • Posts: 404
Re: MDI Application problem
« Reply #22 on: May 19, 2021, 10:58:09 am »
I think what you want is to wave the mouse across the forms and have them automatically jump forward and become focused without clicks, is that it ?
Originally this was not my intention.

The root of the problem was
that when selecting another ChildWindow than the first created ChildWindow,
the Input Focus stayed on the first created ChildWindow.

But this actual resulting behaviore - ChildWindow on MouseOver becomes the first in z-order, plus gets Input Focus - is indeed a nice thing  :)
But I really don't know if this behaviore was intended by Microsoft GUI Guidelines ..  :D
« Last Edit: May 19, 2021, 02:56:47 pm by PeterX »
usually using latest Lazarus release version with Windows 10

PeterX

  • Sr. Member
  • ****
  • Posts: 404
Re: MDI Application problem
« Reply #23 on: May 19, 2021, 08:45:28 pm »
Demo Attached;
assimilated ..  8-)

usually using latest Lazarus release version with Windows 10

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: MDI Application problem
« Reply #24 on: May 20, 2021, 02:53:58 am »
The trunk has working MDI for windows.

its a simple matter, a main form that is a parent MDI, a child form that is a the childMDI..

just set the formStyle property...

Each time you create a Child MDI it becomes a child window of the parent MDI.

TMyCHildMDI.Create(MyParentMDI);

It gets added...
you will need to adjust the frame size and position so that it appears in the window.
The only true wisdom is knowing you know nothing

PeterX

  • Sr. Member
  • ****
  • Posts: 404
Re: MDI Application problem
« Reply #25 on: May 20, 2021, 11:34:05 am »
The trunk has working MDI for windows.
I have an old Delphi 5 Template project in my repository  (the original Delphi 5 Template)
that waits for being compiled successfully under Lazarus ..

But I don't like this much working with a Lazarus trunk version ..
So I'd prefer waiting for this win32 MDI code being releaed with one of the next official Lazarus releases.

https://bugs.freepascal.org/view.php?id=36582
« Last Edit: May 20, 2021, 08:38:21 pm by PeterX »
usually using latest Lazarus release version with Windows 10

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: MDI Application problem
« Reply #26 on: May 20, 2021, 03:31:48 pm »
There is still a problem with mdi as I noticed that still exist even with the trunk.
And that is if minimize a child it does as you expect however, if resize the parent in the state the min child form does not follow its parent.

 I fixed this myself in the parent resize event to keep this updated.
The only true wisdom is knowing you know nothing

PeterX

  • Sr. Member
  • ****
  • Posts: 404
Re: MDI Application problem
« Reply #27 on: May 20, 2021, 08:36:37 pm »
There is still a problem with mdi as I noticed that still exist even with the trunk.
And that is if minimize a child it does as you expect however, if resize the parent in the state the min child form does not follow its parent.

 I fixed this myself in the parent resize event to keep this updated.
I found this problem today, too.
But coudn't find out how to fix this.

I was not able to move the minimized ChildWin,
to "dock" it to the bottom of the "Client Area".
How did You solve that ?  :o
usually using latest Lazarus release version with Windows 10

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: MDI Application problem
« Reply #28 on: May 20, 2021, 11:04:54 pm »
Because I am too tired to code this out using the basic routes of LCL so I copied something from a project..

In this project the child forms were being parented via a TPANEL which works the same I guess so if you are doing something different just change the naming...
 This isn't perfect but enough to give you some ideas and I used the Message method so you need to implement or override the WMSIZE message..
Code: Pascal  [Select][+][-]
  1. procedure TForm1.wmSize(var Msg: TMessage);
  2. Var
  3.  L,H :integer;
  4.  WS :WINDOWPLACEMENT;
  5. begin
  6.   Inherited wmsize(TLMsize(Msg));
  7.   H := GetSystemMetrics(SM_CYMINSPACING);
  8.   If H and $0F <> 0 Then H := (H and $FFFFFFF0)+$10;//Seems we need to obey 16 byte page size in heigth;
  9.   For L := 0 To Panel1.ComponentCount-1 do
  10.   Begin
  11.    if (Panel1.Components[L] is TCustomForm) Then
  12.     With TForm(Panel1.Components[l]) do
  13.      Begin
  14.       Ws.Length := SizeOf(WS);
  15.       GetWindowPlaceMent(Handle, WS);
  16.       If WindowState= wsMinimized then
  17.        Begin
  18.         WS.ptMinPosition.y := Panel1.Height-H;
  19.         WS.Flags := WPF_SETMINPOSITION;
  20.         Ws.ShowCmd := SW_MINIMIZE;
  21.         SetWindowPlacement(Handle, WS);
  22.        End Else
  23.       if WS.rcNormalPosition.Top > Panel1.Height Then
  24.        Begin
  25.         WS.rcNormalPosition.Top := Panel1.Height-H;
  26.         Ws.RCNormalPosition.Bottom -=H;
  27.         SetWindowPlacement(Handle, Ws);
  28.        end;
  29.      end;
  30.   end;
  31. End;                                          
  32.  
The only true wisdom is knowing you know nothing

PeterX

  • Sr. Member
  • ****
  • Posts: 404
Re: MDI Application problem
« Reply #29 on: May 20, 2021, 11:28:06 pm »
Got it, thanks !

Now I need to clean up my code, before uploading.
usually using latest Lazarus release version with Windows 10

 

TinyPortal © 2005-2018