🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #5408

MDI without MDI

#5408
From: Thorsten Kettner
Date: Mon, 22 Aug 2005 07:47
44 lines
2493 bytes
Hi all,
I want to create child forms in my form. My form itself is a
child form of an SDI app, hence I must do without MDI.

Here is my test scenario: I have TForm1 as a main form and a 
small TForm2, both containing a TEdit, a TCheckBox and a button.
I create one or more TForm2 dynamically with this script:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  static int ChildLeft = 20;

  TForm2* pNewForm = new TForm2(this);
  pNewForm->Left = ChildLeft;
  pNewForm->Top = 50;
//  pNewForm->Parent = this;
  ::SetParent(pNewForm->Handle, Handle);
  pNewForm->Show();

  ChildLeft += 20 + pNewForm->Width;
}

I had to change the parent assignment pNewForm->Parent = this;
to ::SetParent(pNewForm->Handle, Handle); because the former
prevented my sub forms from being activated (click in the edit
box and nothing happens). Using the API call solved this problem,
but another one occured:

When dragging the child form by using its titlebar, the drag
position is wrong, i.e. while moving it the form is drawn at a 
wrong position, but when releasing the mouse button the form is 
put into the right place. Seems the problem is due to mixing 
screen and client related coordinates. This is as well noticable 
when setting Left and Top after SetParent - the child form gets 
drawn at another position!

I don't know if the problem is in VCL or Windows. I tried inter-
cepting WM_MOVING, WM_MOVE and even WM_WINDOWPOSCHANGING as well
as WM_WINDOWPOSCHANGED, but that didn't help.

Is there an easy way to solve the problem?

My system: BCB6 Ent, Win NT.
Technical Details
Message-ID: <430982f9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.inode.at!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,e6e8a404167d95ab,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Thorsten Kettner" <QUESTIONBYthorsten.kettner@otto.de>
Sender: "Thorsten Kettner" <QUESTIONBYthorsten.kettner@otto.de>
Reply-To: "Thorsten Kettner" <QUESTIONBYthorsten.kettner@otto.de>
Subject: MDI without MDI
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 80.85.196.93     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <430982f9$1@newsgroups.borland.com>
Date: 22 Aug 2005 00:47:05 -0700
X-Trace: newsgroups.borland.com 1124696825 207.105.83.66 (22 Aug 2005 00:47:05 -0700)
Lines: 44
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.inode.at!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail