Recent

Author Topic: How to make MDI forms?  (Read 13334 times)

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
How to make MDI forms?
« on: October 11, 2014, 03:32:18 pm »
I tried to make an MDI application Windows 2000 and Lazarus 1.2.4.
First from the forms' property 'FormStyle'.
Then with the following code taken from here

Code: [Select]
procedure TForm1.ButtonAdminClick(Sender: TObject);
begin
  windows.SetParent(ChildForm.Handle, panel2.Handle);
  SendMessage(ChildForm.Handle, WM_NCACTIVATE, WPARAM(True), 0);
  ChildForm.left := 10;
  ChildForm.Top := 10;
  ChildForm.show;
  ChildForm.SetFocus;
end;     

The parent is panel2.Handle - the child is ChildForm.

Both ways give me the error: 'Project raised exception class 'External: SIGSEGV'. In file '.\include\wincontrol.inc' at line 7237: HandleAllocated:=(FHandle <> 0);'.
What can I do? (maybe it's related to some gdb problem?)(do I have to put some library in the uses of the form for the 'windows' (windows.SetParent))?

(my goal is MDI in windows, and if possible but not necessary and in Linux)
« Last Edit: October 11, 2014, 03:38:50 pm by panoss »
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How to make MDI forms?
« Reply #1 on: October 11, 2014, 03:39:58 pm »
you make sure that the projects main form is empty with only the main menu in it. You set the forms style to fsMDIForm, You build a number of secondary forms with your grids or what not and set their formstyle to fsMDIChild. Opening all the mdi children you should see floating forms inside the main form. you can maximize,restore and minimize them as you see fit but when you move the mdi form (aka your applications main form) every single one of the child forms whould be moved together.

If you want a tabbed interface like the new version of internet explorer or firefox or chrome then you forget about the mdi always use the fsNormal style make sure to set the borderstyle to bsnone when the child forms are created you create manually a pagesheet and set the forms parent to the pagesheet with the forms alignment set to alClient.
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

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: How to make MDI forms?
« Reply #2 on: October 11, 2014, 04:27:54 pm »
MDI is completely implemented only for qt widgetset on x11, mac and win32 platforms.
Win32 needs patches to get it properly work.

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: How to make MDI forms?
« Reply #3 on: October 11, 2014, 04:29:39 pm »
I tried it and it didn't work.
Then, before the ChildForm.show I put:  ChildForm.parent:=ParentForm;
And it works!  :o
Only that clicking on the close button of the ChildForm does nothing...I have toclick on the close button of the ParentForm...
And doesn't work on linux, but that's a minor problem.
Thank you very much taazz!

Zeljko can I make it work and in Linux?
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: How to make MDI forms?
« Reply #4 on: October 11, 2014, 05:17:48 pm »
@panoss yes. I'm using Qt with mdi on all of that platforms (mac,linux,win).
You don't need any parent setup.Just mark application main form that it's fsMDIForm, and child forms as msMDIChild.

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: How to make MDI forms?
« Reply #5 on: October 11, 2014, 05:26:39 pm »
I tried to build Lazarus with Qt but it showed errors  :(.

I 've installed Qt:
Quote
ldconfig -p | grep Qt4
   libQt4Pas.so.5 (libc6) => /usr/lib/libQt4Pas.so.5
   libQt4Pas.so (libc6) => /usr/lib/libQt4Pas.so
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: How to make MDI forms?
« Reply #6 on: October 11, 2014, 05:30:15 pm »

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: How to make MDI forms?
« Reply #7 on: October 11, 2014, 05:59:46 pm »
But I 've installed it.
Here are the errors from the Lazarus build:
Quote
Linking /usr/share/lazarus/1.2.4/lazarus
/usr/bin/ld: warning: /usr/share/lazarus/1.2.4/link.res contains output sections; did you forget -T?
/usr/bin/ld: warning: libQtWebKit.so.4, needed by /usr/lib/libQt4Pas.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libQtGui.so.4, needed by /usr/lib/libQt4Pas.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libQtNetwork.so.4, needed by /usr/lib/libQt4Pas.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libQtCore.so.4, needed by /usr/lib/libQt4Pas.so, not found (try using -rpath or -rpath-link)
/usr/lib/libQt4Pas.so: undefined reference to `QPlainTextEdit::textCursor() const'
/usr/lib/libQt4Pas.so: undefined reference to `QImageReader::setFormat(QByteArray const&)'
/usr/lib/libQt4Pas.so: undefined reference to `QNetworkRequest::setHeader(QNetworkRequest::KnownHeaders, QVariant const&)'
/usr/lib/libQt4Pas.so: undefined reference to `QTreeWidget::setFirstItemColumnSpanned(QTreeWidgetItem const*, bool)'
/usr/lib/libQt4Pas.so: undefined reference to `QWebHistory::canGoForward() const'
/usr/lib/libQt4Pas.so: undefined reference to `QFont::pointSize() const'
/usr/lib/libQt4Pas.so: undefined reference to `QSpacerItem::changeSize(int, int, QSizePolicy::Policy, QSizePolicy::Policy)'
/usr/lib/libQt4Pas.so: undefined reference to `QConicalGradient::center() const'
/usr/lib/libQt4Pas.so: undefined reference to `QTreeView::setColumnHidden(int, bool)'
/usr/lib/libQt4Pas.so: undefined reference to `QSslSocket::QSslSocket(QObject*)'
/usr/lib/libQt4Pas.so: undefined reference to `QGraphicsView::items(QPainterPath const&, Qt::ItemSelectionMode) const'
/usr/lib/libQt4Pas.so: undefined reference to `QBoxLayout::setStretchFactor(QWidget*, int)'
/usr/lib/libQt4Pas.so: undefined reference to `QFrame::setMidLineWidth(int)'

blah bla bla...thousand of errors and end like this:
QFlags<QTextDocument::FindFlag>)'
/usr/lib/libQt4Pas.so: undefined reference to `QMetaObject::trUtf8(char const*, char const*, int) const'
/usr/lib/libQt4Pas.so: undefined reference to `QCalendarWidget::setMaximumDate(QDate const&)'
/usr/lib/libQt4Pas.so: undefined reference to `QGraphicsScene::items(QRectF const&, Qt::ItemSelectionMode) const'
/usr/lib/libQt4Pas.so: undefined reference to `QInputDialog::getText(QWidget*, QString const&, QString const&, QLineEdit::EchoMode, QString const&, bool*, QFlags<Qt::WindowType>)'
/usr/lib/libQt4Pas.so: undefined reference to `QTableView::setColumnWidth(int, int)'
/usr/share/lazarus/1.2.4/ide/lazarus.pp(141,1) Error: Error while linking
/usr/share/lazarus/1.2.4/ide/lazarus.pp(141,1) Fatal: There were 1 errors compiling module, stopping
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: How to make MDI forms?
« Reply #8 on: October 11, 2014, 07:00:46 pm »
I installed libQtWebKit4 but still shows the same error...
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: How to make MDI forms?
« Reply #9 on: November 28, 2014, 02:15:28 am »
In the OnClose Event of the childform, put:

  CloseAction:= caFree;

And then, don't free/release the form manually because its already taken care of.

Clicking on the close button of the ChildForm does nothing...I have toclick on the close button of the ParentForm...
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How to make MDI forms?
« Reply #10 on: November 28, 2014, 05:52:27 am »
I installed libQtWebKit4 but still shows the same error...

Because you did not pay any attention to the version requirements.
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

Derit

  • Jr. Member
  • **
  • Posts: 55
Re: How to make MDI forms?
« Reply #11 on: December 01, 2014, 02:30:45 am »
hi zeljko
you suggest use Qt, Qt  memory usage is big and not split dll use,
my dream for lazarus use mdi for win32 native
Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: How to make MDI forms?
« Reply #12 on: December 09, 2014, 06:02:33 pm »
hi zeljko
you suggest use Qt, Qt  memory usage is big and not split dll use,
my dream for lazarus use mdi for win32 native

Feel free to create patch for win32 widgetset.

 

TinyPortal © 2005-2018