Lazarus

Programming => General => Topic started by: dietmar on July 02, 2017, 06:39:23 pm

Title: MDI deprecated?
Post by: dietmar on July 02, 2017, 06:39:23 pm
Hi,

in a german Lazarus forum, they say MDI is deprecated, because Windows has to be changed to reflect this behaviour.
Is that really true? If yes, what alternative can I use when I want several forms open next to each other?

Dietmar
Title: Re: MDI deprecated?
Post by: Leledumbo on July 02, 2017, 06:58:59 pm
Hi,

in a german Lazarus forum, they say MDI is deprecated, because Windows has to be changed to reflect this behaviour.
Is that really true? If yes, what alternative can I use when I want several forms open next to each other?

Dietmar
AFAIR, yes. They prefer TDI to MDI nowadays.
Title: Re: MDI deprecated?
Post by: marcov on July 02, 2017, 07:06:20 pm
Microsoft has deprecated MDI for new applications long, long ago (maybe even in Windows 98 times)
Title: Re: MDI deprecated?
Post by: Thaddy on July 02, 2017, 07:24:16 pm
Microsoft has deprecated MDI for new applications long, long ago (maybe even in Windows 98 times)
Correct. Actually Windows 95!  https://docs.microsoft.com/en-us/cpp/mfc/sdi-and-mdi
More than 20 years ago in favor of SDI (single document interface).
The tabbed document interface was introduced to mitigate some usability problems with SDI (which docs are opened?) and is from a later date.
MS sinned against their own advice, though, e.g. excel up to but not including 2007.

From Joel Spolski (in 2002):
"Here are the usability problems people have with MDI:

* They accidentally minimize a child window, e.g. by double clicking it's title bar, and don't know what they've done. Then they think the other windows are lost.

* They get into a state where the child windows are not even visible because the main window is too small or scrolled away, and don't know what they've done. Then they think the window is lost, and choosing it from the Window list does nothing.

* They close the app when they meant to close a child window because the X's icons are so close.

There are a whole range of other pathologies. Programmers are very logical people and understand MDI quickly. Most end users just don't get it and usability on these apps is terrible.

Joel Spolsky "
http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&ixpost=2748

I can confirm the last line:
Together with my then emplorer we did some usability tests in a software testlab in Delft (WITlab TU Delft 1997-1998) for our nextgen product. Usability experience by end users with MDI was horrible. Our then core product was MDI...... :( %) :-[ :-[ I subsequently designed a TDI/SDI based interface, but around that time/soon after I left the company.
It was also the only time in my carreer we overshot the development budget by - a lot - more than multiplied with Pi. Excellent technology previews and proof of concept, though.. O:-)

WITlab means "Work and Integration Laboratory". It is still a world leader in usability.
Title: Re: MDI deprecated?
Post by: jc99 on July 02, 2017, 08:11:40 pm
I'd put it that way, MDI as meaning Win 3.1 - MDI is sooooo dead, burried and rotten away. ... it evolved to
MDI in case of a modern Interface to handle multible Documents/Forms in more or less a single Container-Window with docking and tabbed Views is very much alive, look at your webbrowser.
So which MDI are you talking about ?
Title: Re: MDI deprecated?
Post by: Thaddy on July 02, 2017, 08:18:44 pm
I'd put it that way, MDI as meaning Win 3.1
So which MDI are you talking about ?
There is - by computer science convention - just one MDI. The first one. Don't mix things up. It is also not confined to ms windows 3.1.

https://en.wikipedia.org/wiki/Multiple_document_interface
Title: Re: MDI deprecated?
Post by: dietmar on July 02, 2017, 08:33:28 pm
For my project, it is essential to build an app which shows several open forms on one screen and to have them communicate with each of the others.

Example: Firefox with all his tabbed browsers, is that a TDI?
My App should work like this:
https://www.dropbox.com/s/ffuupzrplaapyqq/crazy.png?dl=0
(having several windows in one application visible).

Hope I described it correctly...

Dietmar
Title: Re: MDI deprecated?
Post by: Ondrej Pokorny on July 02, 2017, 08:36:54 pm
You need a docking solution. E.g. AnchorDocking.
Title: Re: MDI deprecated?
Post by: guest60499 on July 02, 2017, 09:19:45 pm
For my project, it is essential to build an app which shows several open forms on one screen and to have them communicate with each of the others.

Example: Firefox with all his tabbed browsers, is that a TDI?
My App should work like this:
https://www.dropbox.com/s/ffuupzrplaapyqq/crazy.png?dl=0
(having several windows in one application visible).

You could simply create multiple forms that are not in an MDI container. Personally I think this ends up being worse than using MDI, but it's not "deprecated."

Which really makes me want to comment on Microsoft's opinion on MDI: I don't think it's considered depcrecated, and at the very least it is extremely unlikely they will ever remove it (it is supported in the desktop system at a very low level). Their statements as I understood them the last time I read about MDI are more to the effect that the format produces interfaces which are typically confusing for users and unless you do testing on your own with other formats you are probably best off avoiding it. Start here. (https://msdn.microsoft.com/en-us/library/windows/desktop/ms632591(v=vs.85).aspx)

If you must use a GUI then you might want to consider using a TreeView to show elements that change a main panel's contents. Good examples are PuTTY and most IDE options/settings windows. This is similar to a tabbed interface but differs in how the tabs are presented. This format is popular enough that there are browser extensions that present tabs as a tree. It's nearly impossible to misunderstand it or to be confused by it.

I view docking windows in much the same way I view multiple windows (often times you can creating freestanding windows with anchor docking) and MDI. It makes the screen very noisy. At least with MDI you can layer windows and know that they are associated with a process.

The last option is to not use a GUI. I wish this option was more popular. Some tasks and workflows are poorly suited to GUIs simply because of how much information they produce and/or the limited ways you can allow a user to interact with the information the process needs. This is why most programming languages are still text based.
Title: Re: MDI deprecated?
Post by: Thaddy on July 02, 2017, 09:33:21 pm
You need a docking solution. E.g. AnchorDocking.

Yes
I view docking windows in much the same way I view multiple windows
True. A docking interface has much in common and many similarities with MDI with many drawbacks removed (but not all).
Quote
The last option is to not use a GUI. I wish this option was more popular. Some tasks and workflows are poorly suited to GUIs simply because of how much information they produce and/or the limited ways you can allow a user to interact with the information the process needs. This is why most programming languages are still text based.
In the case of OP this is not an option as becomes clear from his screenshot.

Go with a docked interface...
Title: Re: MDI deprecated?
Post by: jc99 on July 02, 2017, 10:15:04 pm
I'd put it that way, MDI as meaning Win 3.1
So which MDI are you talking about ?
There is - by computer science convention - just one MDI. The first one. Don't mix things up. It is also not confined to ms windows 3.1.

https://en.wikipedia.org/wiki/Multiple_document_interface  (https://en.wikipedia.org/wiki/Multiple_document_interface)
You see mentioning MDI people start the shitstorm ...
Win 3.1 was meant as an example. M$ declared that deprecated since Win95.
So was the mentioning of the webbrowser.
I want several up to a lot of documents/forms handled in a modern way by a good UI. How do you call it ?
And How to do it in Lazarus.
Suggestion:
Let's call it MFHS (Multi-Form-Handling-System) so it's not confused with MDI (the one like in win 3.X).
Title: Re: MDI deprecated?
Post by: dietmar on July 02, 2017, 10:20:16 pm
THank you for all you contributions. Ich will try the anchordrocking as well as the "Multiple forms". In the last case, does such a form has properties which are absolutely essential?

Best regards,
DIetmar
Title: Re: MDI deprecated?
Post by: Thaddy on July 02, 2017, 10:32:13 pm
You see mentioning MDI people start the shitstorm ...
If you do it in the wrong context and with the wrong beliefs? Yes, there is that risk. I don't think it is that bad and confined to just a few individuals, though. Maybe even one.. 8-) O:-)

Note that even I choose an (true) MDI interface sometimes over something else. Rare, but sometimes still valid. But not in this case.
Title: Re: MDI deprecated?
Post by: guest60499 on July 03, 2017, 01:41:51 am
THank you for all you contributions. Ich will try the anchordrocking as well as the "Multiple forms". In the last case, does such a form has properties which are absolutely essential?

Best regards,
DIetmar
The only property I know of is WM_SYSMENU, I believe this style gives it a normally sized top bar (on Windows) but prevents the minimize and maximize buttons from showing. You might also want to use WM_POPUP which does much the same but gives the window a thinner top bar (on Windows).

For Linux I can't think of anything that matters.

In the case of OP this is not an option as becomes clear from his screenshot.

Go with a docked interface...
Can you (or the OP, if he reads this) link it? I didn't see it, but my point was basically "just because you have a GUI now doesn't mean you need one to present textual information."

The picture I did find was of a sound editing program, so if he needs to display graphics for that then I can understand needing some way to usefully manage those displays.
Title: Re: MDI deprecated?
Post by: sam707 on July 03, 2017, 02:00:28 am
my 10 cents :

multiple TFrame gliding on the TForm client sky did always do the job for  me
Title: Re: MDI deprecated?
Post by: dietmar 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
Title: Re: MDI deprecated?
Post by: jc99 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 ?
Title: Re: MDI deprecated?
Post by: sam707 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
Title: Re: MDI deprecated?
Post by: jc99 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 (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.*
Title: Re: MDI deprecated?
Post by: dietmar on July 03, 2017, 10:15:03 pm
Thank you all for your tips and your patience!

Dietmar
Title: Re: MDI deprecated?
Post by: jamie 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..
Title: Re: MDI deprecated?
Post by: jc99 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 ...
Title: Re: MDI deprecated?
Post by: jamie 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;                                     
Title: Re: MDI deprecated?
Post by: jamie 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;                             
Title: Re: MDI deprecated?
Post by: jc99 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  ?!
Title: Re: MDI deprecated?
Post by: jamie 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?
Title: Re: MDI deprecated?
Post by: Thaddy 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.
Title: Re: MDI deprecated?
Post by: taazz 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;
Title: Re: MDI deprecated?
Post by: vfclists 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
Title: Re: MDI deprecated?
Post by: Thaddy 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.
Title: Re: MDI deprecated?
Post by: jc99 on July 09, 2017, 03:24:08 pm
I just forked the LMDI-Package to my repository,
it's now under
https://github.com/joecare99/Public/tree/master/Components/LMDI
TinyPortal © 2005-2018