Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2005-04-27
6
Medium Priority
?
362 Views
Last Modified: 2013-11-20
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?
Thanks,
Jens
0
Comment
Question by:allmer
  • 3
  • 2
6 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 13874246
For adding context help button in title bar...

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

~roshan
0
 
LVL 5

Author Comment

by:allmer
ID: 13874438
Thanks,
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.
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 1000 total points
ID: 13890759
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
   http://support.microsoft.com/default.aspx?scid=kb;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
   GetSystemMenu(...)
   EnableMenuItem(...)
(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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 5

Author Comment

by:allmer
ID: 13892487
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?
Jens
0
 
LVL 5

Author Comment

by:allmer
ID: 13907384
Hi,
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.
Jens
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 13911575
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
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question