![]() |
Languages »
C# »
Windows Forms
Intermediate
License: The Code Project Open License (CPOL)
Access Parent Statusbar from a childBy LimeyRedneckUpdate the parent's status bar panel(s) from a child MDI form |
C#, VC7.1, .NET, WinXP, MFC, VS.NET2003, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
Like many others I have been searching for a way to access the statusbar on a MDI parent form from a child in the simplest and least code intensive manner.
Again, like most others I have found that this appears to be like the Holy Grail .... someone knows but is not telling.
Well after wasting my time on searches and finding all kinds of advice on reflection, events etc I decided to do some coding - hacking in the old sense.
The following code works quite nicely, but has only been tested on an XP Pro system using VSNet2K3.
Assuming a status bar with 1 panel ....
public System.Windows.Forms.StatusBarPanel pfrm_sbp1 = null;
pfrm_sp1.Text = "How did he do that?";
Form2 newMDIChild = new Form2();
newMDIChild.MdiParent = this;
newMDIChild.pfrm_sp1 = statusBarPanel1;
newMDIChild.Show();Of course, you could do this via other more secure mechanisms (please do) - make the reference variable private with get/set functions, perhaps make it an array of panel references, but you get the basic idea now don't you.
Anything more pervasive would benefit from a more comprehensive and better design here's an excellent article (link) to guide you if you decide to go further down into the internals of inter window communications.
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 30 Nov 2004 Editor: Nishant Sivakumar |
Copyright 2004 by LimeyRedneck Everything else Copyright © CodeProject, 1999-2009 Web20 | Advertise on the Code Project |