 |
|
 |
I want to see the program looks on screen.
I would like ExtendedInterface.DLL.
Thank you.
|
|
|
|
 |
|
 |
Well it is a nice tool but with Visual Studio 2005 Express i have one prob.
If i want set the StatusMessage property for the StatusStripPanel it dosent works and every time if i clickt teh combobox in the StatusMessage property to select a StatusStripPanel, the combobox is empty.
Works the StatusMessage dll with VisualStudio 2005 Express?
thanks and regards,
Nico
|
|
|
|
 |
|
 |
ok i have found the probs and here is the right way so taht it works with the MenuStrip! Normal the StatusMeassge.dll was create for the old MenuBar and StatusBar controls but in the newer frameworks we have the menustrip and statusstrip controls. so here is the StatusMessage.cs for teh Strip controlls.
using System;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace ExtendedInterface
{
///
/// Extended Interface to allow status messages from a menu item to appear in the status bar automatically
///
[ProvideProperty( "StatusMessage", typeof(Component)) ]
public class StatusMessage : Component, IExtenderProvider
{
Hashtable m_Dictionary = new Hashtable( );
///
/// Assign the message that will appear in the StatusBarPanel when a MenuItem is selected
///
public void SetStatusMessage( Component pComponent, string strMessage )
{
if( ! m_Dictionary.Contains( pComponent ))
{
m_Dictionary.Add( pComponent, strMessage );
ToolStripMenuItem pMenuItem = pComponent as ToolStripMenuItem;
if( pMenuItem != null )
pMenuItem.MouseHover += new EventHandler( Handle_MenuSelect );
}
else
{
m_Dictionary[ pComponent ] = strMessage;
}
}
///
/// Retrieve the message that will appear in the StatusBarPanel when a MenuItem is selected
///
public string GetStatusMessage( Component pComponent )
{
if( m_Dictionary.Contains( pComponent ))
return (string) m_Dictionary[ pComponent ];
return null;
}
///
/// Definition of the components that will be extended
///
public bool CanExtend( object pComponent )
{
return( pComponent is ToolStripMenuItem );
}
private ToolStripStatusLabel m_StatusBar;
///
/// Assign the StatusBarPanel that will display the menu's message
///
public ToolStripStatusLabel StatusBar
{
get{ return m_StatusBar; }
set{ m_StatusBar = value; }
}
private void Handle_MenuSelect( Object pControl, EventArgs e )
{
if( StatusBar == null )
return;
if( m_Dictionary.Contains( pControl ))
StatusBar.Text = (string) m_Dictionary[ pControl ];
}
}
}
i hope it works for you
regards,
nico
|
|
|
|
 |
|
 |
Hi,
overall, you did a fine job, but I found a little bug.
If I make more toolbars (not just one) than it's ClikEvent() don't run.
So I changed the SetToolbarFunction() in ToolbarFunction.cs to this:
if( ! m_Dictionary.Contains( pComponent ))
{
m_Dictionary.Add( pComponent, pMenuItem );
ToolBarButton pToolBarButton = pComponent as ToolBarButton;
m_ToolBar = pToolBarButton.Parent as ToolBar;
if (m_ToolBar != null)
{
if( ! m_Toolbars.Contains( m_ToolBar ))
{
m_Toolbars.Add(m_ToolBar, 0);
m_ToolBar.ButtonClick += new ToolBarButtonClickEventHandler( Handle_ToolbarButtonClick );
}
}
}
else
{
m_Dictionary[ pComponent ] = pMenuItem;
}
You have to add a new global variable:
Hashtable m_Toolbars = new Hashtable();
Bye
|
|
|
|
 |
|
 |
Nice article, but I feel this is far too longwinded...this is the top of my head and furthermore I'm in a internet cafe which is 10km away from where I live, sleep, eat .NET, I cycled in btw! !!! This is a more simpler elegant solution - Why not trap the MenuStart/MenuComplete/MenuSelect Event, e.g.
private void myMenu_MenuStart(object sender, EventArgs e){
// declare this variable as private....
this.OrigStatusMsg = this.statusBar.Text;
this.statusBar.BorderStyle = StatusBorderStyle.None; // Turn off the status bar style
}
private void myMenu_MenuComplete(object sender, EventArgs e){
this.statusBar.BorderStyle = StatusBorderStyle.Sunken; // Restore the status bar style
this.statusBar.Text = this.OrigStatusMsg;
}
Then trap the MenuSelect event for the menu...
private void myMenu_MenuSelect(object sender, EventArgs e){
if (sender == myMenu_File_Open) this.statusBar.Text = "Click on this to launch File/Open dialog...";
if (sender == myMenu_File_Exit) this.statusBar.Text = "Click on this to exit this application";
// etc
}
This albeit is a much more simpler way of doing this...utilise the existing .NET stuff... BTW Please accept my apologies if i got the method signature wrong....
Just my 2cents,
Best Regards,
Tom
|
|
|
|
 |
|
 |
Yeah, but this method, while it may seem shorter requires you to use a LOT of if statements and trapping a ton of events for every menu you use. The way described in the article uses 1 component for every menu in the entire project, which is much more elegant and saves a lot of code space in your project. Plus, IExtenderProvider is existing .NET stuff. Nobody's inventing a new wheel.
|
|
|
|
 |
|
 |
The author's way of doing it is awesome. It's exactly what I wanted.
The original poster in this thread has suggested a way of doing that would work, but it's not elegant, and by that I mean that it involves a lot of diddling around at design time and a big mass of ugly code.
What I did learn from the original poster here is to trap the MenuClosed event. This is not mentioned in the article, I believe, and it's important, because otherwise you end up with stupid message stuck permanently in your status bar, and spend an hour trying to figure out how you messed up.
The only nagging problem with the author's implementation is localization, it's not a major issue for me.
bruce
|
|
|
|
 |
|
 |
I've added [Localizable(true)]directly before both GetStatusMessage and SetStatusMessage functions, rebuilt the dll, removed all reference of the original dll from my project toolbox and code. Finally I added the new dll back in and set the attribute on a menuitem.
My test form has Localizable set to true.
Visual Studio 2003 still adds the code:
this.statusMessage.SetStatusMessage(this.menuItemMainTools, "Access to tools menu");
rather than getting it from the resource file, which it does for the other properties:
this.menuItemMainTools.Text = resources.GetString("menuItemMainTools.Text");
Any ideas what I've missed?
|
|
|
|
 |
|
 |
The click-event don't clear the status-text... I know this is a small issue to resolve manually, but it would be nice to have this integrated in the dll.
Anyone knowing how to do that without 'consuming' the WM_CLICK message (or whatever it's called..)?'
BTW: Thank's for an exxellent intro to the IExtenderProvider interface, nice job!
Per Rollvang
|
|
|
|
 |
|
 |
In the SetStatusMessage function of the StatusMessage class, add the following:
>>> Existing line of code
pMenuItem.Select += new EventHandler(Handle_MenuSelect);
>>> New line of code
pMenuItem.Click += new EventHandler(Handle_MenuClick);
Then, add the code for Handle_MenuClick:
private void Handle_MenuClick(Object pControl, EventArgs e)
{
if (null == StatusBar)
{
return;
}
StatusBar.Text = "";
}
|
|
|
|
 |
|
 |
However, this doesn't seem to handle the problem that occurs when you display a menu, then press the ESC key to clear it; the status bar text remains set at the last value. Any ideas?
|
|
|
|
 |
|
 |
Just a guess - try the same approach but on the "Lose Focus" event (no idea what its called, but I assume it exists)
|
|
|
|
 |
|
 |
Docking menu is also missed out from the previous version. Once created the main menu will always appear on the top of the form. Any solution make it dockable in C#..?
Mahantesh
|
|
|
|
 |
|
 |
Hi Mahantesh
You got any solution for this docking menu bar, i am looking for this feature, i think u got some solution regarding this...
Please help me....
Thanks in advance
Sreenivasulu Palavarapu
Lera Technologies,
Secunderabad.
|
|
|
|
 |
|
 |
2 Questions:
1. When hoovering the menu (just in File, Window, etc.) the status bar/panel does not show the message. How do you do that?
2. I am happy you show us how to use extended interface. I am wondering if you could use that in 'tabbed mdi'. Any suggestion?
Thanks
Roel
|
|
|
|
 |
|
 |
re #2:
http://www.codeproject.com/csharp/MDIStatusbar.asp[^]
"A successful business provides the solution dictated by intelligence, common sense, and fiscal responsibility. This simple filter eliminates 99% of your options, including government"
"A successful business provides the solution dictated by intelligence, common sense, and fiscal responsibility. This simple filter eliminates 99% of your options, including government"
|
|
|
|
 |
|
 |
Hi
This is great work..
I am also getting the same problem.
When hoovering the menu (just in File, Window, etc.) the status bar/panel does not show the message. How do you do that?
Thanks in advance...
Sreenivasulu Palavarapu
Lera Technologies,
Secunderabad.
|
|
|
|
 |
|
 |
Hello Phillip,
overall, you did a fine job!
but one thing seems to be not properly working: the StatusMessage in not localizable. that is, when I edit StatusMessage for menu item, it is represented in InitializeComponent via
this.stmHint = new ExtendedInterface.StatusMessage();
this.ttpHint = new System.Windows.Forms.ToolTip(this.components);
this.stmHint.SetStatusMessage(this.mniFileExit, "Closes application");
rather than
this.ttpHint.SetToolTip(this.button1, resources.GetString("button1.ToolTip"));
as it is for ToolTip. as you see, I have to manually change string in SetStatusMessage to resources.GetString() call.
evidently, ToolTip component has this problem solved. I wouldn't ask if I had source codes to ToolTip; but all I have is some VCPP sources for class with the same name which is apparently not doing the same thing.
any ideas how to overcome this?
|
|
|
|
 |
|
 |
found the cure myself. add [Localizable(true)] before GetStatusMessage and SetStatusMessage methods of ExtendedInterface.StatusMessage component.
|
|
|
|
 |
|
 |
This stuff seems great.
Srinivas
|
|
|
|
 |
|
 |
Great Article!
I just wanted to mention what to do if you already have text in the status bar panel before your menuItems change that text.
If you want the text that was in the status bar to resore
There are two events on your form (that contain the menu) you can handle.
MenuStart and MenuComplete.
private void MainForm_MenuStart(object sender, System.EventArgs e)
{
this._statusTextCache = this.TextPanel.Text;
}
private void MainForm_MenuComplete(object sender, System.EventArgs e)
{
this.TextPanel.Text = this._statusTextCache;
}
Amber Star
|
|
|
|
 |
|
 |
Nice,
didn't know these events !
|
|
|
|
 |
|
 |
Another way is to toogle panels visibility in these events:
private void MainForm_MenuStart(object sender, System.EventArgs e)
{
this.statusBar.Text = string.Empty;
this.statusBar.ShowPanels = false;
}
private void MainForm_MenuComplete(object sender, System.EventArgs e)
{
this.statusBar.ShowPanels = true;
}
Yoy will need also to modify the StatusMessage class, assigning the StatusBar property to an StatusBar control instead of an StatusBarPanel:
private StatusBar m_StatusBar;
public StatusBar StatusBar
{
get{ return m_StatusBar; }
set{ m_StatusBar = value; }
}
This way you don't need an special StatusBarPanel to show menu messages.
jefrubio
|
|
|
|
 |
|
 |
How do I add the code to enable Localization?
|
|
|
|
 |
|
 |
I'd be very surprised if it didn't work as is. Are you having any problems at the moment?
|
|
|
|
 |