473,804 Members | 3,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2212

"Nick" <an*******@disc ussions.microso ft.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 MdiChildActivat e 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 MdiChildActivat e 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.co m

"Nick" <an*******@disc ussions.microso ft.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 MdiChildActivat e 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.co m

"Nick" <an*******@disc ussions.microso ft.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 MdiChildActivat e
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*******@disc ussions.microso ft.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 menuItemNewMdiC hild = new MenuItem();
menuTest.MenuIt ems.Add(menuIte mNewMdiChild);
menuTest.Text = "Test";
menuItemNewMdiC hild.Text = "New MDI Child";
menuItemNewMdiC hild.Click +=new
EventHandler(me nuItemNewMdiChi ld_Click);
}

private int formCount = 0;
private void menuItemNewMdiC hild_Click(obje ct sender, EventArgs e)
{
Form form = new Form();
form.Text = "Form " + (++formCount).T oString();
form.MdiParent = this;
form.WindowStat e = 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*******@dis cussions.micros oft.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 menuItemNewMdiC hild = new MenuItem();
menuTest.MenuIt ems.Add(menuIte mNewMdiChild);
menuTest.Text = "Test";
menuItemNewMdiC hild.Text = "New MDI Child";
menuItemNewMdiC hild.Click +=new
EventHandler(m enuItemNewMdiCh ild_Click);
}

private int formCount = 0;
private void menuItemNewMdiC hild_Click(obje ct sender, EventArgs e) {
Form form = new Form();
form.Text = "Form " + (++formCount).T oString();
form.MdiParent = this;
form.WindowStat e = 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
5799
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 perfectly. In NS 7 there are artifacts left over from what previously occupied a given frame. If I minimize the NS browser, then mazimize it again, the NS browser repaints the contents of the frames, and everything looks correct. Is there a way -...
2
5137
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 sometimes stops advancing (does not repaint) part way thru it's cycle. If you click the MS Access window title bar during the cycle, the Access title bar switches to Access Not Responding. But if I ctrl+Break to stop the code it is indeed still...
4
1917
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" Forms!fcon.FilterOn = True Forms!fcon.Requery Stop
2
11071
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, after the Print Preview dialog is closed, the originating form doesn't repaint and the area under the Print Preview is garbled. How should this be handled? I'm not seeing how to force this originating form to do a repaint? Thanks
7
5003
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 I toggle back to Excel, it does not do that. The repaint is quick. I'm running this within a Citrix environment. The scrolling of the DataGrid is slow also. Would anyone know how I can fix or even determine what is going on? Thank you!
3
2687
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 property there is only a get function as following :
4
6580
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 instead of displaying the statistic labels. it display nothing. I have to move the JInternalFrame so that the panel display the statistic. how could that after the game finish (the player reach the key), the panel display the statistic immediately? ...
0
1146
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 in c# it's my Event ONPaint : protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center;
4
3041
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. So, whenever a new message comes in, all the previous ones move up and the new one gets added to the bottom. Now, if the operator is scrolling up to see some previous messages, and a new one comes in, we need to let the operator know. Therefore,...
0
1959
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 in all, you should see an image following your mouse. BUT. its only seen after you press play and then resize the window. this leads me to conclude that theres a problem with repaint(). can someone please help? thanks. heres my code: (EnemyShip...
0
9705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9575
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10564
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10320
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10308
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7609
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5645
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.