Recent

Author Topic: MDI deprecated?  (Read 18836 times)

dietmar

  • Full Member
  • ***
  • Posts: 170
Re: MDI deprecated?
« Reply #15 on: July 03, 2017, 10:07:21 am »
Sounds interesting... can you provide a little information about how this "gliding" is done or what you meant with it.

After studying more of Lazarus Wikipedia, it sounds fo me that frames are placed onto an form - but "gliding"? ;)

Regards,
Dietmar
Lazarus 2.2.0RC1 with FPC 3.2.2 (32 Bit) on Windows10 (64Bit)

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: MDI deprecated?
« Reply #16 on: July 03, 2017, 12:08:01 pm »
My solution looks like this:
Define a LMDBasepanel (not necesary a TPanel-descendand) (This is the panel all the MLDI-Forms can move on)
Then define a Form-Descendant like LMDIChild-Form with the LMDI-Header
Use this as a "Normal" Form and put on it whatever you like.

This LMDIChild-form does one part oft the magic, when the parent is NOT the TLMDBasePanel(-Descendent) it displayes and behaves as a "normal" Form.
But if the parent is a TLMDBasePanel(-Descendent) it hides itself, and copies all its items(components) to a new generated (child-)panel on that Parent-Panel.

The movement and minimizing/maximising is done by the LMDI-Header.
Does this sound interesting ?
« Last Edit: July 03, 2017, 12:10:01 pm by jc99 »
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

sam707

  • Guest
Re: MDI deprecated?
« Reply #17 on: July 03, 2017, 05:19:55 pm »
@dietmar .. ask google "easing curves", pick some equations, embed them on clicks an move/resize events around little timing delays, (i do especialy use the elastic motion easing curve) AND you'll get a "tablet like" gliding UI in laz.

I do point how I make/made it, its up to you to write your own code. It's not that much difficult.

Qt framework often use them
« Last Edit: July 03, 2017, 05:23:25 pm by sam707 »

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: MDI deprecated?
« Reply #18 on: July 03, 2017, 06:29:30 pm »
Sounds interesting... can you provide a little information about how this "gliding" is done or what you meant with it.

After studying more of Lazarus Wikipedia, it sounds fo me that frames are placed onto an form - but "gliding"? ;)
Proof of concept:
https://github.com/joecare99/Public/blob/master/Projects/bin/x86_64-win64/Prj_MDIPreTest.exe
Source:
https://github.com/joecare99/Public/tree/master/Examples/Source/MDIPretest
https://github.com/joecare99/Public/tree/master/Examples/FPC -> prj_MDIPretest.*
« Last Edit: July 03, 2017, 06:36:53 pm by jc99 »
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

dietmar

  • Full Member
  • ***
  • Posts: 170
Re: MDI deprecated?
« Reply #19 on: July 03, 2017, 10:15:03 pm »
Thank you all for your tips and your patience!

Dietmar
Lazarus 2.2.0RC1 with FPC 3.2.2 (32 Bit) on Windows10 (64Bit)

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: MDI deprecated?
« Reply #20 on: July 05, 2017, 11:02:33 pm »
One of my projects has multiple editor forms within the parent form. I create them as I needed added
forms. The forms are the standard TcustomForm based and I can design the single form in the IDE and
create multiple instances of it at runtime..
 
 The first issue I had was assigning the parent. Using The   standard methods causes some problems in the
LCL GUI code if you are using a Form with all of its icons like in a standalone form. The parented form seems
to have issue with some messages not reaching all of the child controls..  So I used the direct approach of
assigning the parent.. Windows.SetParent(....); that works.

 Then the issue of minimized iconic windows not tracking with the parent window if you resize the parent
window...
  I wrote some code for that too to correct the issue..

 So now this app has many forms with in a FORM all looking like stand alone forms except for one other
item I notice, the child forms do not use your preferred desktop settings, which I like.. They look like the
days of Windows XP forms. But those are only the child forms that do that.

 If interested I can post the code here needed to correct the iconic view of the forms when parent is resized..
The only true wisdom is knowing you know nothing

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: MDI deprecated?
« Reply #21 on: July 05, 2017, 11:35:34 pm »
If interested I can post the code here needed to correct the iconic view of the forms when parent is resized..
Please post your approach, any help is welcome ...
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: MDI deprecated?
« Reply #22 on: July 06, 2017, 02:31:18 am »
In the below code of the WmSize message I did this to adjust the iconic form to stay aligned at the
bottom of the TPanel. A Panel Is being used in this case to host the FORMS I create.

procedure TForm1.wmSize(var Msg: TMessage);
Var
 L,H :integer;
 WS :WINDOWPLACEMENT;
begin
  Inherited wmsize(TLMsize(Msg));
  H := GetSystemMetrics(SM_CYMINSPACING);
  If H and $0F <> 0 Then H := (H and $FFFFFFF0)+$10;//Seems we need to abey 16 byte page size in heitgh;
  For L := 0 To Panel1.ComponentCount-1 do
  Begin
   if (Panel1.Components[L] is Tform) Then
    With TForm(Panel1.Components[l]) do
     Begin
      Ws.Length := SizeOf(WS);
      GetWindowPlaceMent(Handle, WS);
      If WindowState= wsMinimized then
       Begin
        WS.ptMinPosition.y := Panel1.Height-H;
        WS.Flags := WPF_SETMINPOSITION;
        Ws.ShowCmd := SW_MINIMIZE;
        SetWindowPlacement(Handle, WS);
       End Else
      if WS.rcNormalPosition.Top > Panel1.Height Then
       Begin
        WS.rcNormalPosition.Top := Panel1.Height-H;
        Ws.RCNormalPosition.Bottom -=H;
        SetWindowPlacement(Handle, Ws);
       end;
     end;
  end;
End;                                     
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: MDI deprecated?
« Reply #23 on: July 06, 2017, 02:47:06 am »
also this is a section of that same app that initiates a for as a child form...

 btw, I did some mixed Object and Class coding so don't get thrown off here ;)

constructor TWinList.Init(AParent:PWindowsObject; AListTray:PTray);
 begin
  Inherited Create(Aparent);
  Caption := 'Operand Stack';
  Hint := Caption;
  ShowHint := True;
  SetBounds(0,0,150,150);
  Windows.Setparent(Handle, Aparent.handle);  // << here is where I used a direct window call.
  fListWindow := TlistBox.Create(self);
  fListWindow.parent := Self;
  fListWindow.Align := alClient;
  fListWindow.Sorted := False;
  Tray:=AListTray;
  WindowState := wsMinimized;
  Show;
 end;                             
The only true wisdom is knowing you know nothing

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: MDI deprecated?
« Reply #24 on: July 06, 2017, 06:55:07 am »
In the below code of the WmSize message I did this to adjust the iconic form to stay aligned at the
bottom of the TPanel. A Panel Is being used in this case to host the FORMS I create.
PLZ next time put the code in CODE-Tags so it wouls look like :
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 abey 16 byte page size in heitgh;
  9.   For L := 0 To Panel1.ComponentCount-1 do
  10.   Begin
  11.    if (Panel1.Components[L] is Tform) 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.  
I assume TForm1 is you MDI-Main-Form

Code: Pascal  [Select][+][-]
  1. constructor TWinList.Init(AParent:PWindowsObject; AListTray:PTray);
  2.  begin
  3.   Inherited Create(Aparent);
  4.   Caption := 'Operand Stack';
  5.   Hint := Caption;
  6.   ShowHint := True;
  7.   SetBounds(0,0,150,150);
  8.   Windows.Setparent(Handle, Aparent.handle);  // << here is where I used a direct window call.
  9.   fListWindow := TlistBox.Create(self);
  10.   fListWindow.parent := Self;
  11.   fListWindow.Align := alClient;
  12.   fListWindow.Sorted := False;
  13.   Tray:=AListTray;
  14.   WindowState := wsMinimized;
  15.   Show;
  16.  end;                      
  17.  
But TWinList ? TWinList is your Child form  ?!
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: MDI deprecated?
« Reply #25 on: July 07, 2017, 12:06:17 am »
Yes, the TwinList is the child form. It is a class based from Tform..
As you can see I set the owner and I also use the same owner to set the parent in this case.

 Setting the parent using the preferred method seems to have issues in Lazarus but works in Delphi..
 
  This is old code and it maybe possible the issue of setting the parent is fixed?
The only true wisdom is knowing you know nothing

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: MDI deprecated?
« Reply #26 on: July 07, 2017, 09:25:56 am »
That Delphi code happened to work by accident, btw. It relies on implementation detail that happens to work in most but not all cases.
Handle creation can be postponed until use otherwise. This was/is to prevent allocating Windows resources before actual use.
At least in Delphi you should call TWincontrol.HandleNeeded to ensure that there already is a valid handle.
I believe the same goes for Lazarus.

A good place to call it is in imho the AfterConstruction event.
« Last Edit: July 07, 2017, 09:31:26 am by Thaddy »
Specialize a type, not a var.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: MDI deprecated?
« Reply #27 on: July 07, 2017, 10:16:24 am »
That Delphi code happened to work by accident, btw. It relies on implementation detail that happens to work in most but not all cases.
Handle creation can be postponed until use otherwise. This was/is to prevent allocating Windows resources before actual use.
At least in Delphi you should call TWincontrol.HandleNeeded to ensure that there already is a valid handle.
here is the delphi 2007 gethandle method.
Quote
function TWinControl.GetHandle: HWnd;
begin
  HandleNeeded;
  Result := FHandle;
end;
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
Re: MDI deprecated?
« Reply #28 on: July 07, 2017, 02:13:47 pm »
The real issue is for whom MDI has been deprecated. When you develop your own apps which require multiple windows and the task bar contains an icon for every window opened in your application, that is when you begin to see the value of MDI.

Frankly I think the MDI deprecation has more to do with fashion than sense. For me it smacks of the practice of dumbing things down for the majority when there are people who have used it and can see its benefits.

In the original versions of Microsoft Word and Excel for instance, it was much easier to have to taskbar items for Microsoft Word and Excel seperately, then you could select the icon and choose the documented you wanted. Right now I find it messy using those programs because their icons are all over the place. It would be fairly easy to implement the ability to select the application's icon and get a list of which document within the application window you want to select and accomplish that right from the task bar.

Anyway if you want MDI in Lazarus you can use Qt widgetset. Given the way GTK is going Qt may be the better option as they are more committed to cross-platform development than the GTK developers
Lazarus 3.0/FPC 3.2.2

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: MDI deprecated?
« Reply #29 on: July 07, 2017, 05:21:27 pm »
That Delphi code happened to work by accident, btw. It relies on implementation detail that happens to work in most but not all cases.
Handle creation can be postponed until use otherwise. This was/is to prevent allocating Windows resources before actual use.
At least in Delphi you should call TWincontrol.HandleNeeded to ensure that there already is a valid handle.
here is the delphi 2007 gethandle method.
Quote
function TWinControl.GetHandle: HWnd;
begin
  HandleNeeded;
  Result := FHandle;
end;
HandleNeeded will fail if called to early. That's the problem.
But anyway it should not fail in Lazarus as per my suggestion.
Specialize a type, not a var.

 

TinyPortal © 2005-2018