Поделиться через


Changing the behavior of the Help Button

If you're playing around with the Visual Studio 2005 Beta 2, you'll notice the appearance of a help button at the top of the dialogs. Rather than taking up 75x23 pixels of real estate, the dialogs in Visual Studio have chosen to repurpose the "?" button in the title bar.  Instead of going into the "What's this?" contextual help mode, clicking this button for dialogs in VS 2005 should bring up full-fledged help.

If you want to use the same help style in your application set these properties on Form:
MaximizeBox = false;
   MinimizeBox = false;
HelpButton = true;

We can tweak the Everett HelpProvider sample to see how to enable this new "help mode"

At the bottom of the constructor from the above sample add these few lines:

this.helpProvider1.SetShowHelp(this, true); // enable help for the entire dialog
this.HelpButtonClicked += new CancelEventHandler(Form1_HelpButtonClicked);
this.helpLabel.Text = "Using the HelpButtonClicked event, we can directly show help for this dialog when someone presses the ? button";

And this funny handler:

          void Form1_HelpButtonClicked(object sender, CancelEventArgs e) {
e.Cancel = true; // Cancel the "What's this?" mode

            // directly call OnHelpRequested for the form:
OnHelpRequested(new HelpEventArgs(Point.Empty));
}

And for extra fun, you can also now manually show/hide the icon via

   ShowIcon = false;

Comments

  • Anonymous
    June 21, 2005
    It's really unfortunate, the trend away from What's This help. Check out the comments (e.g. mine and Chuck Martin's) at: http://blogs.msdn.com/apblog/archive/2005/05/20/420590.aspx

    What's This is very useful when you need help on a particular control. Sure beats having to dig/search through a help window for info about the control.
  • Anonymous
    June 21, 2005
    You bring up good points, it's definately a style thing which folks may or may not want to emulate in their apps.

    (Personal opinion: If I'm in a situation where I have to resort to What's This help, I usually need more help than what can be covered in a sentence. For this reason, I've gotten used to never pushing the ? button.)
  • Anonymous
    July 13, 2005
    I'm one of the two or three people principally responsible for the '?' buttons in Visual Studio. I think it would be great if 'What's This' Help was used effectively, but I've never seen it employed in such a way that actually made it useful to me.