Recent

Author Topic: Window inside Form  (Read 11231 times)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Window inside Form
« Reply #15 on: August 25, 2017, 01:10:26 pm »
As always I have to question the usefulness of such a notion. Why do you want a floating window inside a form what is the purpose? fill free to ignore me its mostly curiosity.
Hi taazz, that's a good point. I thought about it again and I think what I really need is, that this little window does not hide behind the main window - so it should always stay on top. Which is easy with the formStyle Property and the value fsSystemStayOnTop. Thanks for that question :-)
Ah the floating toolbar design. Do not use fsstayontop, I despise half assed solutions like that but that is only me apparently.
There are 2 magical properties that you can use to have any form stay over an other form and only that form. PopupParent and popupmode. Lets assume that you have two forms form1 is the basic work area of your application and Form2 is your toolbox. You want to have form2 never get behind form1, you go to form2 and on the object inspector you set the popupmode to pmExplicit and the popupParent to Form1, from now on form2 will always stay on top of form1
« Last Edit: August 25, 2017, 01:12:09 pm by taazz »
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

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Window inside Form
« Reply #16 on: August 25, 2017, 01:24:31 pm »
I could never get the MDI interface to show anything on the form.. This is on
Windows.
 In Delphi it works.. If there something special I need to do then I wish someone would
step up to the plate and say so..

 In the mean time, I was able to get what looks like a MDI app running with some
additions to the app to fix some small issues.

 when you create the form and set all of its boundaries and so on, I had to use the
Windows.SetParent function to set the parent .. It seems the handle or something is ready
yet in the form for a proper LCL style of code.

 and also, I had to fix the Minimize to icon position if you change the size of the parent form.
 If interested we can talk more about it.

 P.S.
  When I did this, I lost the themes  for these forms and they looked like standard XP forms inside the parent.

MDI is fully supported with Qt widgetset under Linux, Win32 and Mac.
It looks like QT is the most stable widget set. I wonder what the problem is on win32.
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

Thaddy

  • Hero Member
  • *****
  • Posts: 19388
  • Glad to be alive.
Re: Window inside Form
« Reply #17 on: August 25, 2017, 01:45:35 pm »
It looks like QT is the most stable widget set. I wonder what the problem is on win32.
Other than that it is deprecated by MS ions ago, I often wondered the same thing. But I remember it was also very hard to get MDI to work on KOL (2003/2004).
We ended up partially mimicking it.... I never use MDI anymore, so I may be mistaken (not the KOL part)
« Last Edit: August 25, 2017, 01:47:34 pm by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 882
Re: Window inside Form
« Reply #18 on: August 25, 2017, 02:19:22 pm »
Other than that it is deprecated by MS ions ago, I often wondered the same thing. But I remember it was also very hard to get MDI to work on KOL (2003/2004).
We ended up partially mimicking it.... I never use MDI anymore, so I may be mistaken (not the KOL part)
MDI was popular in the past, because processes costed more resources, than threads. But MDI is unsafe. Simply because crashed thread = crashed application. Shared address space => bad thing. That's why I have an idea of new executable file type - plugin. It should have it's own separate address space, but nothing should be mapped to it by default - all things should be explicitly provided by host application.
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

sam707

  • Guest
Re: Window inside Form
« Reply #19 on: August 25, 2017, 02:26:50 pm »
N.B.

LCL and its cousin VCL are a little bit 'windows centric' in the 'control object' design approach. Meaning these frameworks essentially use OSes 'handles' and the native handlers API when possible.

On the other hand, Qt was designed with a metalanguage intensively using 'forked' signals and slots for about everything with no real need for OSes handles (much independant and tricky, so).

The 2 philosophies and approaches differs a lot and there is NO way to compare stability betweend handlers and signals
« Last Edit: August 25, 2017, 02:32:38 pm by sam707 »

Thaddy

  • Hero Member
  • *****
  • Posts: 19388
  • Glad to be alive.
Re: Window inside Form
« Reply #20 on: August 25, 2017, 02:27:30 pm »
Other than that it is deprecated by MS ions ago, I often wondered the same thing. But I remember it was also very hard to get MDI to work on KOL (2003/2004).
We ended up partially mimicking it.... I never use MDI anymore, so I may be mistaken (not the KOL part)
MDI was popular in the past, because processes costed more resources, than threads. But MDI is unsafe. Simply because crashed thread = crashed application. Shared address space => bad thing. That's why I have an idea of new executable file type - plugin. It should have it's own separate address space, but nothing should be mapped to it by default - all things should be explicitly provided by host application.

That's called a pipe  :P
objects are fine constructs. You can even initialize them with constructors.

sam707

  • Guest
Re: Window inside Form
« Reply #21 on: August 25, 2017, 02:29:31 pm »
M. D. I.

multiple documents interface ... huh... you attempt to write a desktop oldschool way? LOL

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Window inside Form
« Reply #22 on: August 25, 2017, 02:33:18 pm »
Other than that it is deprecated by MS ions ago, I often wondered the same thing. But I remember it was also very hard to get MDI to work on KOL (2003/2004).
We ended up partially mimicking it.... I never use MDI anymore, so I may be mistaken (not the KOL part)
MDI was popular in the past, because processes costed more resources, than threads. But MDI is unsafe. Simply because crashed thread = crashed application. Shared address space => bad thing. That's why I have an idea of new executable file type - plugin. It should have it's own separate address space, but nothing should be mapped to it by default - all things should be explicitly provided by host application.
nope sorry, MDI started as the main window on windows 3, long before win95 and preemptive multi tasking when only cooperative multi tasking was used it was the time when an application froze for some reason windows froze down with it. It has nothing to do with threads VS process (where threads kick processes batt in every case, by the way :P ).
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

sam707

  • Guest
Re: Window inside Form
« Reply #23 on: August 25, 2017, 02:43:01 pm »
welcome back to the future around 1751 AD

https://www.youtube.com/watch?v=yrvhaAAbEyQ

program man ager was KING on top M.D.I. (windows 3.1)

enjoy the video, little archaeologists  :P

and the so called minimization stack of M.D.I icons! don't puke! HAHAHAH
« Last Edit: September 07, 2017, 01:48:01 pm by sam707 »

sam707

  • Guest
Re: Window inside Form
« Reply #24 on: August 25, 2017, 02:55:45 pm »
SO!

as you understood in the video,

before windows XP you had choice between eplorer.exe and progman.exe (from after w3.1 to millenium)

and progman.exe was holding most of the M.D.Inetrface native API

since windows XP, only explorer survived, and M.D.I. is hard to mimic but of no interest for about 15 years
« Last Edit: August 25, 2017, 02:58:18 pm by sam707 »

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 882
Re: Window inside Form
« Reply #25 on: August 25, 2017, 03:36:28 pm »
That's called a pipe  :P
On Linux? Because on Windows pipe - is just console-like way to send data between processes. I mean, creating process for every single plugin - is still very costly thing. But this is the only way to do it, if you want to have separate address spaces for your plugins, i.e. if you want them to be 100% safe, so crash of any plugin won't crash whole application and unsafe 3rd party plugins won't be able to steal any confidential data from core of your application. Some middle ground should be found between simple dll plugin (possibly using threads) and having plugin container process for every single plugin.

I've just tried to implement MDI on Lazarus via old trick, I've been using on Delphi - i.e. the fact, that each thread has it's own message queue and form is bound to thread, it's created in. But Lazarus doesn't allow both Application.Run and Application.Process messages to be run in any other thread, except main one. :'(

Yeah, due to some reasons Memo can't get input focus (I have to right-click it) and sometimes application crashes at the end (due to some sync issues, I guess), but at least it compiles and works.
Code: Pascal  [Select][+][-]
  1.   TForm1 = class(TForm)
  2.     Button1: TButton;
  3.     procedure Button1Click(Sender: TObject);
  4.   private
  5.     { Private declarations }
  6.   public
  7.     { Public declarations }
  8.   end;
  9.  
  10.   TMDIThread = class(TThread)
  11.   protected
  12.     FFormClass:TFormClass;
  13.     FParent:TForm;
  14.     procedure Execute;override;
  15.   public
  16.     constructor Create(AFormClass:TFormClass;AParent:TForm);
  17.   end;
  18.  
  19. var
  20.   Form1: TForm1;
  21.  
  22. constructor TMDIThread.Create(AFormClass:TFormClass;AParent:TForm);
  23. begin
  24.   FreeOnTerminate := True;
  25.   FFormClass := AFormClass;
  26.   FParent := AParent;
  27.   inherited Create(False);
  28. end;
  29.  
  30. procedure TMDIThread.Execute;
  31.   var MDIApplication:TApplication;
  32.   MDIForm:TForm;
  33. begin
  34.   MDIApplication := TApplication.Create(nil);
  35.   MDIApplication.CreateForm(FFormClass, MDIForm);
  36.   MDIForm.Parent := FParent;
  37.   MDIForm.Show;
  38.   MDIApplication.Run;
  39.   MDIApplication.Free;
  40. end;
  41.  
  42. procedure TForm1.Button1Click(Sender: TObject);
  43. begin
  44.   TMDIThread.Create(TForm2, Self);
  45. end;
  46.  
« Last Edit: August 25, 2017, 05:07:18 pm by Mr.Madguy »
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

sam707

  • Guest
Re: Window inside Form
« Reply #26 on: August 25, 2017, 05:58:45 pm »
rong way @Mr Mad

it would work if TApplication's core used 'threadvar' declspec so that each application would manage its own memory heap's variables in its own thread local storage.

when switching contexts between threads, they use automatically different stacks but the same global memory heap except for threadvar declared variables

it works like this for historical reasons + delphi compatibility + time switching contexts consumption.

that gives you clues why you afford CRASHES, and why your plugins living totally in a separate address space can not being done this way (except if you rewrite the TApplication entity core with threadvar definition blocks (also large parts of the LCL, to become thread safe).

It would be a Titan's work LOL
« Last Edit: August 25, 2017, 06:05:45 pm by sam707 »

dubst3pp4

  • Jr. Member
  • **
  • Posts: 86
  • Retro computing ~ GNU/Linux
    • me on Mastodon
Re: Window inside Form
« Reply #27 on: August 28, 2017, 04:07:49 pm »
Ah the floating toolbar design. Do not use fsstayontop, I despise half assed solutions like that but that is only me apparently.
There are 2 magical properties that you can use to have any form stay over an other form and only that form. PopupParent and popupmode. Lets assume that you have two forms form1 is the basic work area of your application and Form2 is your toolbox. You want to have form2 never get behind form1, you go to form2 and on the object inspector you set the popupmode to pmExplicit and the popupParent to Form1, from now on form2 will always stay on top of form1
Thanks taazz, works like a charm! :-)
Jabber: xmpp:marc.hanisch@member.fsf.org -- Support the Free Software Foundation: https://my.fsf.org/donate

 

TinyPortal © 2005-2018