views:

387

answers:

2

We have an MDI form which contains some number of child forms which have varying captions showing the currently loaded document's filename. When the child forms are maximized their title text gets placed in the parent window's title bar which often results in the text being too long to fit in the bar and Windows is nice enough to add ellipses and truncate the text.

However, when you hover over the title bar of the main window, it shows a tooltip with what should be the entire string, but instead the tooltip often contains a small fraction of the string. For example, if the main form's text was:

Program1 - Filename:[Really_long_filename_that_doesnt_fit.file]

It would appear as the following in the tooltip:

Program1 - Filename:[Really_long_filename_t

Edit: It always truncates the tooltip at exactly 100 characters, which leads me to believe that it's some upper limit specified somewhere.

Is there a way to change this so it displays the entire string, or if not, to disable the tooltip altogether?

Any language is acceptable, although we're doing this in C#.

A: 

I wish I had something more helpful for you, but unfortunately, I don't think that there's a way around this. You may either shorten your filenames or have to deal with it :(

Jason
Unfortunately, the filenames of the files we work with are generated by a custom FPGA and have long machine-generated filenames.
Ron Warholic
:( i'm sorry guy... sometimes the best answer is the one that saves you a lot of time looking for one that doesn't exist. for your sake i hope some supergenius has a way to figure it out for you, but my experience says that's just a UI "feature" included in the forms :\
Jason
+1  A: 

This uses a manual tooltip and timer to show / hide a caption when the mouse moves over the title bar.

public partial class Form1 : Form
{
    private ToolTip toolTip = new ToolTip();
    private Timer toolTipTimer = new Timer();
    private bool canShowToolTip = true;

    protected override void WndProc(ref Message m)
    {
        switch (m.Msg)
        {
            case 0x2A0: // WM_NCMOUSEHOVER
                return;
            case (int)0x00A0: // WM_NCMOUSEMOVE
                if (m.WParam == new IntPtr(0x0002)) // HT_CAPTION
                {
                    if (canShowToolTip)
                    {
                        canShowToolTip = false;
                        toolTip.Show(this.Text, this, this.PointToClient(Cursor.Position), toolTip.AutoPopDelay);
                        toolTipTimer.Start();
                    }
                }
                return;
        }
        base.WndProc(ref m);
    }

    public Form1()
    {
        InitializeComponent();
        Form child = new Form();
        child.Text = "Program1 - Filename:[Really_long_filename_that_doesnt_fit.file] AAAAAAAAAAAAAAAAAAAA BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";
        child.MdiParent = this;
        child.Show();
        toolTip.AutoPopDelay = 5000;
        toolTipTimer.Interval = toolTip.AutoPopDelay;
        toolTipTimer.Tick += delegate(object sender, EventArgs e)
        {
            canShowToolTip = true;
        };
    }
}
John JJ Curtis
The filename itself is well over 100 characters so even stripped to the bare minimum it will be truncated.
Ron Warholic
I'm not getting the WM_NCMOUSELEAVE event and subsequently I only see the tooltip once. It seems like it may work if I can iron out some kinks.
Ron Warholic