Form as Child of another Form

Hi.

Maybe my first mail describing the problem was too complex.

A simple question then:

Why do edit controls don't work correctly, if created in a child form of another form?

--- snip ---
void __fastcall TForm1::Button1Click(TObject *Sender)
{
     TfrmTest* frmTest = new TfrmTest(Application);

     frmTest->Parent = this;
     frmTest->Show();
}
--- snap ---

If 'TfrmTest' contains edit-controls they no longer accept focus using the mouse.

Any help would be appreciated.

Thanks
Eike Petersen
0
Eike
7/25/2010 11:22:58 AM
embarcadero.cppbuilder.using 1848 articles. 1 followers. Follow

5 Replies
879 Views

Similar Articles

[PageSpeed] 58
Get it on Google Play
Get it on Apple App Store

> {quote:title=Eike Petersen wrote:}{quote}
> Why do edit controls don't work correctly, if created in a child form of another form?

The short answer is that forms aren't meant to be used that way.  With that said, I've created an interface or two that makes use of forms in the way you are trying.  The technique can be described as a "poor man's MDI".

You can try setting the child-parent relationship using SetParent instead.  However, it might cause other problems so you should test completely.

{code:cpp}
TfrmTest* frmTest = new TfrmTest(Application);
SetParent(frmTest->Handle, Handle);
frmTest->Show();
{code}

HTH,
Clayton
0
Clayton
7/25/2010 2:40:19 PM
Thanks for your reply. Actually I'm not really trying to use them this way. I'm trying to figure out why edit-controls behave this strange way, in my *normal* MDI-Application (with one MDI main form and several MDI childs). For some reason I get this behavior in my application *without* setting any parent-relationships manually.

I described the whole story with more detail in another posting, but sadly got no reply - so I tried to present it in a simpler way.

There must be some code in the VCL which is responsible for this effect and I was hoping someone would know about it.

Regards
Eike Petersen

Am 25.07.2010 16:40, schrieb Clayton Arends:
>> {quote:title=Eike Petersen wrote:}{quote}
>> Why do edit controls don't work correctly, if created in a child form of another form?
>
> The short answer is that forms aren't meant to be used that way.  With that said, I've created an interface or two that makes use of forms in the way you are trying.  The technique can be described as a "poor man's MDI".
>
> You can try setting the child-parent relationship using SetParent instead.  However, it might cause other problems so you should test completely.
>
> {code:cpp}
> TfrmTest* frmTest = new TfrmTest(Application);
> SetParent(frmTest->Handle, Handle);
> frmTest->Show();
> {code}
>
> HTH,
> Clayton
0
Eike
7/25/2010 2:56:08 PM
"Eike Petersen" <epetersen@removethisgmx.net> wrote in message 
news:265357@forums.embarcadero.com...
> Thanks for your reply. Actually I'm not really trying to use
> them this way. I'm trying to figure out why edit-controls
> behave this strange way, in my *normal* MDI-Application
> (with one MDI main form and several MDI childs). For
> some reason I get this behavior in my application *without*
> setting any parent-relationships manually.

Non-MDI forms are not meant to be embedded in other windows.  Input focus is 
amongst several issues that arise if you do that.  Input focus works fine in 
normal MDI child forms under normal conditions, however, so you have to be 
doing something odd in your code to interfer with proper message handling.

-- 
Remy Lebeau (TeamB)
0
Remy
7/25/2010 11:08:47 PM
Am 26.07.2010 01:08, schrieb Remy Lebeau (TeamB):
> "Eike Petersen"<epetersen@removethisgmx.net>  wrote in message
> news:265357@forums.embarcadero.com...
>> Thanks for your reply. Actually I'm not really trying to use
>> them this way. I'm trying to figure out why edit-controls
>> behave this strange way, in my *normal* MDI-Application
>> (with one MDI main form and several MDI childs). For
>> some reason I get this behavior in my application *without*
>> setting any parent-relationships manually.
>
> Non-MDI forms are not meant to be embedded in other windows.  Input focus is
> amongst several issues that arise if you do that.  Input focus works fine in
> normal MDI child forms under normal conditions, however, so you have to be
> doing something odd in your code to interfer with proper message handling.
>

Yes, I understand. But what could it be? Understanding why the problems with the input focus arise in the "poor man's MDI"-version could help me to locate the source of the problem. I don't think I'm doing something "odd". At least I have no idea what it could be...
0
Eike
7/26/2010 11:18:10 AM
Am 26.07.2010 13:18, schrieb Eike Petersen:
> Am 26.07.2010 01:08, schrieb Remy Lebeau (TeamB):
>> "Eike Petersen"<epetersen@removethisgmx.net>   wrote in message
>> news:265357@forums.embarcadero.com...
>>> Thanks for your reply. Actually I'm not really trying to use
>>> them this way. I'm trying to figure out why edit-controls
>>> behave this strange way, in my *normal* MDI-Application
>>> (with one MDI main form and several MDI childs). For
>>> some reason I get this behavior in my application *without*
>>> setting any parent-relationships manually.
>>
>> Non-MDI forms are not meant to be embedded in other windows.  Input focus is
>> amongst several issues that arise if you do that.  Input focus works fine in
>> normal MDI child forms under normal conditions, however, so you have to be
>> doing something odd in your code to interfer with proper message handling.
>>
>
> Yes, I understand. But what could it be? Understanding why the problems with the input focus arise in the "poor man's MDI"-version could help me to locate the source of the problem. I don't think I'm doing something "odd". At least I have no idea what it could be...

I think I found the cause of the problem, although I don't understand what exactly happens. I was using a TTabControl to visualize opened MDI-child forms, that was a direct child of the MDI-main form. After removing the tab-control everything appears to work fine. It seems that placing a non-form in the MDI-child area of the main form does something which confuses the focus handling of the VCL.

Thanks

Best Regards
Eike Petersen
0
Eike
7/26/2010 12:58:16 PM
Reply:

Similar Artilces:

Forms or No Forms
Hope this isn't a repeat.  I looked and didn't find anything. Say for example you had a web page with around 20 fields retrive and update to a database with differing datatypes.  Some fields will have some special controls (dropdowns, radios, buttons, etc) that interact with other parts of the page.  What is the best and/or most efficient code to make the page. Would you use a Formview bound to a standard ADO.net SQL connection and edit the templates. Use a Formview bound to an Object Data Source and edit within the templates. Or use an Object Data Source and bind the...

Assign TextBox Value From 1 Form to Another Form on another page
I have searched for days without finding the answer that Im looking for. I have created a marketing request form table called tblRequestForm with a few basic fields. [RequestFormID] , [FormTitle] , [Department] , [YourName]. I also have created another table called tblRequests that has these fields. [RequestID] , [RequestFormID] , [RequestTitle] , [RequestDescription]. I am trying to fill out the RequestForm on page1.aspx then on insert, postback the [RequestFormID] automatically into FormRequest on page2.  I am really new to this and help would be great.~Mickey...

form or page event and child forms
I need to know which event I can write code for when a user closes a form or window without submitting so that I can delete a file uploaded with the file upload control.  In other words, I need to cancel a file upload if a form is not actually submitted. Also, my file upload control is actually a control within a fileupload.ascx .  How do I access any objects like controls in a fileupload.ascx from the parent form? thanks MiltonregardsMilton Hi, The file in the file upload control won't be uploaded until the user submit the form, so you don't have to clear the file when ...

how to load child form in master form?
 hi friends.............    i want to know how to add child form in master form with code example...pls......... thanks & regardsSamuel Chandradoss John  Thanks and regardsSamuel Chandradoss John in aspx you can use only one <form runat=server> tag. why you need more than one form tags. use just User Controls.If this post was useful to you, please mark it as answer. Thank you!Regards.mimranshafiq.NET Web Developerhttp://www.dotnetclassic.com don't mistaken me.. i am talking about child web forms. not a form tag with in the page, Than...

Bilingual Forms using Forms authentication
Hello all,  i have a Bilingual site, i'm using Forms authentication for my login within the login control. I have the following problem:  the login page is defined in the web.config. I want to switch between languages, How can i use the 2 login page if i switch to another language?  thanks in advance.  If you cannot switch text on the logon page using the resource file, then make the login page refered to in the web.config redirect to one of two other logon pages depending on language.Don't forget to click "Mark as Answer" on the post that help...

how to use form tag in the content page while master page form tag is in use?
Hi there, i have created a bug report form in the content page which uses the master page template. In the master page i am using the menu which should be in the form tag. when i use the form tag in the content it gives me the error as cant use more than one form tag. how can i resolve it. i hav searched in this forum for tht.. i got links which says to disable the content page form tag as form.visible= false. In my situation i cant disable any of the form tag either inthe master page( menu with in the form tag) or content page ( bug report form with server controls with...

Streaming a form owned by another form
I have Form1 with a PageControl1 on it at design time. At runtime I do this: with TForm2.Create(Form1) do begin NewTS := TTabSheet.Create(PageControl1); NewTS.PageContaol := PageControl1; Parent := NewTS; Show; end; If I use WriteComponent(Form1) it doesn't save any of the child components for Form2. It does save Form2's properties, eg; Left, Top, etc. If I WriteComponent(Form2) it's properties and all child components are saved. Is there a way to use WriteComponent(Form1) and have Form2 properties and child components saved? Rich _ wrote: > I ha...

Copying from Child form to parent form
 Here is the thing I want to do. I have a submission.aspx page where submission of student's details will be done like student 's first name, last name etc. I need to put a hyper link (Search student) next to first name and last name text box, when we click the hyperlink it has to pop up new window, with Alphabets (A,B,C,D- hyperlinks) when we click A, the names of students with A shows up, along with a check box left to it, when we check the box and hit add, the first name will be copied into first name textbox, same thing with last name. How can I implement this? Do you have a...

data from form to form using Reference
I have a form that has three text boxes on it and a button.  When the button is clicked I want to send the data from the first form to the next form and display it.  This is what I have. Form Default protected void Button1_Click(object sender, EventArgs e)    {        Server.Transfer("default2.aspx");          }    public string EmployeeNum    {        get { return tbEmployeeNum.Text; }    }  ...

How to use data posted to another form useing streamreader
Hi I hope some1 can help I have spent hours try to work out how to respond to this code on another form What I want to do is use the code below to Post the variable strNewValue to Webform2 and then do some procceing on webform2  at the moment I am unable to recover the data that is passed to Webform2 I have tried webclient which just retruns a server error 500 I have searched and tried all sorts of bits of code but to no avail, so can any1 help please  ' Create the request back Dim req As HttpWebRequest = CType(WebRequest.Create("http://localhost/Webform2.aspx"), H...

can someone one give me difference between web form and mobile web form and which or where or when i'm using the forms?
thanks Marc Hi Marc, Based on my understanding, you want to know the differences between the ASP.NET web application and ASP.NET mobile web application. If I have misunderstood you, please feel free to let me know. The ASP.NET forms are used to develop the ASP.NET pages for desktop browsers and The ASP.NET mobile forms are used to develop the ASP.NET pages for mobile device browsers. When we create the ASP.NET mobile web forms pages, we can use nearly all the features of ASP.NET. But there are a couple of compatibility issues: Error Handling and Reporting. Tracing. Using Redi...

Forms Authentication using multiple login forms
using the following web.config declaration works for one login page - <authentication mode="Forms" > <forms name="nGAuth" loginUrl="adminLogin.aspx" protection="All" path="/" /> </authentication> but does this mechanism allow for using two or more login pages. After looking at the api doc it doens't say what to do if you have more than one type of user and need to log them in using more than one proceedure. It doesn't say if you can use multiple forms declarations either, but I tried and no luck s...

Insert form without using form control
Hi I would like to build a form without using a form control ie, formview, gridview, detailsview.  With the following code I don't get an error message but when I hit the form button the record doesn't get inserted into my table.  Is there code that I have to add to my code behind maybe on the button click event that I have to add to insert the record?  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="InsertForm.aspx.cs" Inherits="InsertForm" %><html xmlns="http://www.w3.org/1999/xhtml" ...

Web Form embedded in another Web Form
Hi,  I have programmed a Web Form which acts like a scientific calculator. I would like to embedd this calculator in the upper left hand corner of another accounting Web Form. I don't want to host the calculator on the same server as the accounting page. I.e. I want them to have distinct URLs. Classically, I would do this using frames, but is there a better way using ASP? Is there some sort of Panel which can display the webpage at a specific URL which I can just drag onto my accounting Web Form? Thanks,  P1000   Frames are the only way to embed a webform inside ano...

Web resources about - Form as Child of another Form - embarcadero.cppbuilder.using

Lessons from a week of watching 'The Force Awakens': It gets better
Editor's note: This is a review of repeated viewings of the latest Star Wars movie, and what changes over time when rewatching this ridiculously ...

The Known and Unknown Unknowns in the Republican Race Ahead
Some observations on the 2016 presidential race as we head into the dark period, i.e., the two weeks of Christmas and New Year's holidays in ...

NYPD detective among 6 American troops killed in Afghanistan
NEW YORK (AP) — A New York City police detective is one of six American troops killed in a suicide attack near Bagram Airfield in Afghanistan. ...

Blatter, Platini affair marks 'new low point' in football
Leading figures in football hit out at the disgraced Sepp Blatter and Michel Platini after they were handed eight-year bans from the sport. FIFA ...

Despite Landing In Once Piece, SpaceX's Reusable Rocket Won't Fly Again
Tonight, SpaceX successfully sent a first-stage booster to spac e, and then landed it vertically minutes later. It’s a proof of concept that ...

Apple To Start Selling Accessibility Accessories Next Year
Apple has always championed the idea of making their products as accessible as possible to people with different kinds of disabilities. So much ...

Apple cuts prices of iPhone 6s and 6s Plus in India
The average difference in prices of all iPhone 6s and 6s Plus devices between launch time and now is about 15%, a executive at a national retailer ...

How Alvin and the Chipmunks went from a '50s Christmas song to a billion-dollar franchise
From humble beginnings in a Christmas song to a billion-dollar global franchise, Alvin and the Chipmunks have come a long way. Ross Bagdasarian ...

FDA lifts lifetime ban on gay men donating blood
CNN FDA lifts lifetime ban on gay men donating blood CNN (CNN) The Food and Drug Administration has lifted its lifetime ban on accepting blood ...

Martin Shkreli fired from another pharma company after arrest
Martin Shkreli's bad month continues. After being arrested last week on charges of securities fraud, the infamous Shkreli — who came to public ...

Resources last updated: 12/22/2015 4:42:47 AM