4

Is there a way that I can force the help question mark button to be visible on a form that is not a dialog in Delphi 2010?

I want to use the help question mark so that a user can click it then go to a control, but by default it is only available if the border style is dialog, but our application does not use dialog forms

I was looking at Overriding the CreateParams procedure but I am not sure what code to put in it to force the button to show?

Paul

Paul
  • 2,773
  • 7
  • 41
  • 96

2 Answers2

7

According to MSDN, this is not a Delphi-specific limitation, but it is imposed by WinAPI. As you may know, the help question mark is turned on by WS_EX_CONTEXTHELP style, which cannot be combined with WS_MAXIMIZEBOX and WS_MINIMIZEBOX styles. So you can have a non-dialog form and display the question mark, provided that the form does not have maximize and minimize buttons in its caption. If you need the maximize and minimize buttons as well, then I think you should subclass the window and provide custom nonclient paint (drawing the question mark on your own) and nonclient hit-test processing.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
Stan
  • 8,683
  • 9
  • 58
  • 102
  • Thanks Stan, that looks like its going to be very nasty to code! I have no idea where to start! Do you know how I could produce the same functionality using a seperate button? Our application uses a page control, we already have a close button on the right hand side which allows the user to close the active page, so I am thinking that we could add a help question mark button, and when the user clicks it the behaviour then goes to the standard windows behaviour – Paul Feb 08 '12 at 13:30
  • Paul, I suspect you could probably rig something with `SetCapture` and `Screen.Cursor := scHelp`, but this sounds like a full-fledged question rather than something to be covered in the comments of some other answer. You should check whether anyone has already asked about manually putting a form into "help mode," and then ask about it yourself if you don't find the answer. – Rob Kennedy Feb 08 '12 at 13:54
1

You want a help button in the top (grabber) non-client area of a non-modal window that appears beside maximize and minimize?

Use TJvCaptionButton (included in the JEDI VCL) on your form, put a help question mark bitmap on the control button, and have that open the help to a particular page, from an integer help context like this:

Application.HelpContext(aHelpContext);

Because it paints in the non-client area of the window, you might experience some strange behaviour on some Windows theme settings; I don't think Jedi JvCaptionButtons look quite native on Win7 with Aero enabled, for example.

Update The linked question below in comments mentions putting the form into help-mode like this, contributed by DavidH:

  SendMessage(Handle, WM_SYSCOMMAND, SC_CONTEXTHELP, 0);

end;

Warren P
  • 65,725
  • 40
  • 181
  • 316
  • Hi Warrren, ideally I need to mimic the behaviour of the windows ? button i.e the user clicks the question mark then onto a control, once they have clicked on the control, the help for the control is displayed in a popup window. – Paul Feb 09 '12 at 14:40
  • And you asked a separate question for that: http://stackoverflow.com/questions/9212917/how-do-i-put-a-form-in-to-help-mode – Warren P Feb 09 '12 at 15:30