473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

MDI Repaint Problem

I'm creating an MDI application with multiple maximized
MDI child forms. When a child form is open, the
title/caption is merge with the MDI's title/caption. So,
if the MDI title is "Parent" and the 3rd MDI child
is "Child 3", then when the 3rd MDI child is opened, the
title becomes "Parent [Child 3]".

However, when child 3 is closed, the MDI title doesn't go
back to what it was before. It still says "Parent [Child
3]".

Is there anyway to force a refresh/repaint on the MDI
parent after a child has been closed?

Thanks.
Nick
Nov 16 '05 #1
6 2188

"Nick" <an*******@discussions.microsoft.com> wrote in message
news:28****************************@phx.gbl...
I'm creating an MDI application with multiple maximized
MDI child forms. When a child form is open, the
title/caption is merge with the MDI's title/caption. So,
if the MDI title is "Parent" and the 3rd MDI child
is "Child 3", then when the 3rd MDI child is opened, the
title becomes "Parent [Child 3]".

However, when child 3 is closed, the MDI title doesn't go
back to what it was before. It still says "Parent [Child
3]".

Is there anyway to force a refresh/repaint on the MDI
parent after a child has been closed?


Hi Nick,

I implemented this by handling the MdiChildActivate event of the parent
form and checking the ActiveMdiChild property. There may be a better
way, but at least it works.

- Magnus
Nov 16 '05 #2
Thanks for the response. Would you post some sample code,
please? I need the title to show "Parent - [Child 1]"
when child 1 is openned, and "Parent - [Child 2]" when
child 2 is openned. Then, when child 2 is closed, it
needs to go back to "Parent - [Child 1]". Currently, it
doesn't. It remains "Parent - [Child 2]".

Much Appreciated!
Nick
Hi Nick,

I implemented this by handling the MdiChildActivate event of the parentform and checking the ActiveMdiChild property. There may be a betterway, but at least it works.

- Magnus
.

Nov 16 '05 #3
Nick,

Basically, it looks like you want to set the title bar of the parent
whenever the child window gets focus. To do this, you will want to hook
into the Activate event for the child form. In the event handler, you just
get the MdiParent property for the form and set the Text property to what
you want.

Oh, and when creating the new child forms, make sure to set a property
indicating which child it is (you should have a factory that creates each
form, or have the constructor get the current number of MDI children).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Nick" <an*******@discussions.microsoft.com> wrote in message
news:19****************************@phx.gbl...
Thanks for the response. Would you post some sample code,
please? I need the title to show "Parent - [Child 1]"
when child 1 is openned, and "Parent - [Child 2]" when
child 2 is openned. Then, when child 2 is closed, it
needs to go back to "Parent - [Child 1]". Currently, it
doesn't. It remains "Parent - [Child 2]".

Much Appreciated!
Nick
Hi Nick,

I implemented this by handling the MdiChildActivate event

of the parent
form and checking the ActiveMdiChild property. There may

be a better
way, but at least it works.

- Magnus
.

Nov 16 '05 #4
It seems strange that I should need to set the MDI form's
Text property because it looks like it's automatically
handling this (just handling it incorrectly). Is this a
bug with the .Net Framework?

I also noticed that after closing child 2, if I minimize
the program and maximize it again, the title corrects
itself and correctly displays "Parent - [Child 1]". I was
hoping I could just call the form.refresh method after
closing child 2. But that didn't work either.

Nick

-----Original Message-----
Nick,

Basically, it looks like you want to set the title bar of the parentwhenever the child window gets focus. To do this, you will want to hookinto the Activate event for the child form. In the event handler, you justget the MdiParent property for the form and set the Text property to whatyou want.

Oh, and when creating the new child forms, make sure to set a propertyindicating which child it is (you should have a factory that creates eachform, or have the constructor get the current number of MDI children).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Nick" <an*******@discussions.microsoft.com> wrote in messagenews:19****************************@phx.gbl...
Thanks for the response. Would you post some sample code, please? I need the title to show "Parent - [Child 1]"
when child 1 is openned, and "Parent - [Child 2]" when
child 2 is openned. Then, when child 2 is closed, it
needs to go back to "Parent - [Child 1]". Currently, it
doesn't. It remains "Parent - [Child 2]".

Much Appreciated!
Nick
Hi Nick,

I implemented this by handling the MdiChildActivate
event of the parent
form and checking the ActiveMdiChild property. There may

be a better
way, but at least it works.

- Magnus
.

.

Nov 16 '05 #5
<an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
It seems strange that I should need to set the MDI form's
Text property because it looks like it's automatically
handling this (just handling it incorrectly). Is this a
bug with the .Net Framework?


I agree that it's strange, and I distinctly remember having this problem
myself a while back.

However, it seems that I am unable to reproduce it now. The following
code is a short but complete example that works correctly for me when
compiled with VS.NET 2003 and VS 2005 beta1. What version are you
using? I wonder if it might be a bug that exists in .NET Framework 1.0
(VS.NET 2002) but has been fixed in the later versions. I don't have
access to 1.0 right now so I can't test it.
using System;
using System.Windows.Forms;

public class MdiForm : Form
{
public MdiForm()
{
Text = "MdiExample";
IsMdiContainer = true;
Menu = new MainMenu();
MenuItem menuTest = new MenuItem();
Menu.MenuItems.Add(menuTest);
MenuItem menuItemNewMdiChild = new MenuItem();
menuTest.MenuItems.Add(menuItemNewMdiChild);
menuTest.Text = "Test";
menuItemNewMdiChild.Text = "New MDI Child";
menuItemNewMdiChild.Click +=new
EventHandler(menuItemNewMdiChild_Click);
}

private int formCount = 0;
private void menuItemNewMdiChild_Click(object sender, EventArgs e)
{
Form form = new Form();
form.Text = "Form " + (++formCount).ToString();
form.MdiParent = this;
form.WindowState = FormWindowState.Maximized;
form.Show();
}

[STAThread]
static void Main()
{
Application.Run(new MdiForm());
}
}

- Magnus
Nov 16 '05 #6
Thanks.

I think I'm using the lastest version of .Net. The
Framework is 1.1 with SP1 and the VS is 2003 (version
7.1.3088).

Thanks.
Nick
-----Original Message-----
<an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
It seems strange that I should need to set the MDI form's Text property because it looks like it's automatically
handling this (just handling it incorrectly). Is this a
bug with the .Net Framework?

I agree that it's strange, and I distinctly remember

having this problemmyself a while back.

However, it seems that I am unable to reproduce it now. The followingcode is a short but complete example that works correctly for me whencompiled with VS.NET 2003 and VS 2005 beta1. What version are youusing? I wonder if it might be a bug that exists in .NET Framework 1.0(VS.NET 2002) but has been fixed in the later versions. I don't haveaccess to 1.0 right now so I can't test it.
using System;
using System.Windows.Forms;

public class MdiForm : Form
{
public MdiForm()
{
Text = "MdiExample";
IsMdiContainer = true;
Menu = new MainMenu();
MenuItem menuTest = new MenuItem();
Menu.MenuItems.Add(menuTest);
MenuItem menuItemNewMdiChild = new MenuItem();
menuTest.MenuItems.Add(menuItemNewMdiChild);
menuTest.Text = "Test";
menuItemNewMdiChild.Text = "New MDI Child";
menuItemNewMdiChild.Click +=new
EventHandler(menuItemNewMdiChild_Click);
}

private int formCount = 0;
private void menuItemNewMdiChild_Click(object sender, EventArgs e) {
Form form = new Form();
form.Text = "Form " + (++formCount).ToString();
form.MdiParent = this;
form.WindowState = FormWindowState.Maximized;
form.Show();
}

[STAThread]
static void Main()
{
Application.Run(new MdiForm());
}
}

- Magnus
.

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Ike | last post by:
I changing the size of frames dynamically in a page (I am restricted in that I cannot perform a reload of the content of any of the frames). In MSIE, when I resize the frames, thinks repaint...
2
by: Joe A | last post by:
I'm using Access 2002 on Windows XP PC, 500 megs ram, Front end/back end app. I have a simple form that draws a thermometer to indicate progress of code that is running. The thermometer form...
4
by: Bob | last post by:
Trying to repaint a form named fcon using a new filter: 'Repaint the form with the new data Forms!fcon.FilterOn = False Forms!fcon.Filter = "RecNo = " & currecno & " AND Currentvalue = -1"...
2
by: Randy | last post by:
Hello, I've got a form which has a Print button on it. When clicked, this Print button invokes the Print Priview dialog. All this works fine. The problem I'm having is that on some computers,...
7
by: Paul | last post by:
I have a VB.NET form with a DataGrid. When I toggle to Excel (for example) and then back to my application the repaint of the DataGrid is really slow. You can see the repainting happening. When...
3
by: --== Alain ==-- | last post by:
Hi, As i did not get any answer to my previous post, i post the topic again. How can i repaint my control, when an item from my custom control collection has changed ? in my collection...
4
by: thesti | last post by:
Hi, i have problem with a JPanel in my JInternalFrame. it's like a maze game. after the game finished, i want to display game's statistic in the same panel i draw the tiles of the maze. but...
0
by: 123456mmmmmm | last post by:
Hi, I have a problem with Repaint my control. At first my control Create correctly. But with every changes like move scroll or anythings else my contrlo will be repaint. How can I avoid repainting...
4
by: drexlin | last post by:
Hi, I hope this is the correct place to post questions about visual c++ 6.0. If not, sorry. Anyway, the program I am working on takes messages from another computer and prints them on the screen....
0
by: milkay | last post by:
<I have code that uses 2 images> the program creates a window and then when u press play, it removes all components in the container. then, i add a NewPanel object. i add mouse listeners and all...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.