How to add "What's this?" button to the dialog (not the title bar)?

Hi experts,
I would like the CDialog I am using to be minimizable.
I would also like a ?-button. This doesn't have to be in
the title bar, it may be a regular CButton. It should however
have the same functionallity as the ?-button that could be
in the title bar if it wasn't for minimize and maximize.
Any ideas?
Who is Participating?
In the resource editor, set the properties
Under the "Styles" tab set checks in "TitleBar" "System menu," and "Minimize Box"
Under the "Extended Styles" tab, put a check in the "Context menu" checkbox.

That shows all four buttons, but Maximize is disabled.  

   PRB: Context Help Not Compatible with Min or Max Button;en-us;135787

says ... this behavior is by design"
(but the article itself is incorrect in that the minimize button *is* allowed and thus (apparenttly) compatible.

And I agree... dialog boxes are intended to float above an app...  One would never want to maximize one.

I tried several tricks to force the maximize to be enabled, but
(which works to disable the minimize button) does not work to enable the maximize button.

In theory, you could draw your own button on the caption (title bar), but that is something of a pain, and, anyway, as I said, it should not be necessary.

-- Dan
Roshan DavisCommented:
For adding context help button in title bar...

   BOOL CMyDialog::OnInitDialog()
        LONG style = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);
        style |= WS_EX_CONTEXTHELP;
        ::SetWindowLong(m_hWnd, GWL_EXSTYLE, style);
        return TRUE;

allmerAuthor Commented:
as I understand it is not possible to have a minimize, maximize and help button in the titlebar.
How can I add a button to the dialog that has the same functionallity as the help button in
the titlebar?
I tried the adding the code, but the ?-button didn't show up.
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

allmerAuthor Commented:
Thanks Dan,
I am fine with not beeing able to maximize the Dialog.
I didn't code any resize functionallity anyway.

Problem is that I don't have context menu option in fact I
don't see extended styles at all.
And under Misc I cannot set context help when I set the
other parameters that you suggested.
Am I missing something here?
allmerAuthor Commented:
it seems to work on some computers.
I have examples for it working in XP and
also examples for it not working in XP.

I would really like to mirror the ? functionallity to a regular CButton on my dialog.
Something like:
void CMyDlg::OnBnClickedButtonF1Help() {
   //Make the ?-pointer appear and behave
  //as if the ? in the titlebar would have been clicked.

That would be perfect.
Alas, that will be rather tricky.  I can give you a general outline, but I don't have any code for you:

1) Call SetCapture()
2) Call SetCursoe to set the mouse cursor to look different.
3) Provide a handler for WM_MOUSEMOVE and other mouse events
4) When you get a WM_LBUTTONDOWN, based on the location, figure out which button or control is at the location clicked
5) Call ReleaseCapture();
6) Take some action such as displaying a page of your help.
7) Also you need to be able to detect the ESC key to let the User get out of the captured mouse mode if he decides not to use it.

All in all, it is not worth it.  
I suggest just using the built-in/standard handling of the standard [?] button in the title bar.

-- Dan
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.