Microsoft KB Archive/244232

= How To Add Context Help Button (? Button) to Title Bar of CPropertySheet =

Article ID: 244232

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Professional Edition

 Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q244232

<div class="summary_section">

SUMMARY
In order to add the Context Help Button(?) to the top right corner of a CPropertySheet so that it shows up on all the tabs of the sheet, you need to override the OnInitDialog method of the CPropertySheet and call the ModifyStyleEx function with the first parameter of 0 and the second set to WS_EX_CONTEXTHELP.

<div class="moreinformation_section">

MORE INFORMATION
The following steps can be used to add the context help button to a MFC property sheet.

<ol> Using AppWizard create a default dialog based application called "Sample" and add a button resource to it. Using ClassWizard, add a BN_CLICKED handler for this button.</li> Insert a Property Sheet Resource, by choosing Project, Add to Project, Components and Controls..., Visual C++ Components, now select Property Sheet and click Insert</li> Click OK on the dialog box that is displayed. This will bring up another wizard to choose the type of the property sheet.</li> Select the Property Sheet radio button and click Next. Take default setting on the next screen and click Next.</li> On the next screen where it says "What class would you like to give access to this property sheet?", choose CSampleDlg. Take the default settings on the next two screens and click Finish. Click Close in the Components and Controls Gallery dialog box.</li>  Go to the Button Handler and add the following code: void CSampleDlg::OnButton1 {   CMyPropertySheet pSheet; pSheet.DoModal; }                       </li> Using ClassView, override the OnInitDialog virtual function by right-clicking CMyPropertySheet and selecting Add Virtual Function.... Select OnInitDialog on the left and click the Add and Edit button.</li>  Add the following code to the OnInitDialog virtual function: BOOL CMyPropertySheet::OnInitDialog {   BOOL bResult = CPropertySheet::OnInitDialog; ModifyStyleEx(0, WS_EX_CONTEXTHELP); return bResult; }                       </li></ol>

Build the project and run it. If you click the the button on the dialog box, you should notice the property sheet gets displayed with the Context Help Button(?).

Additional query words: Context Help, Question mark button

Keywords: kbcshelp kbdlg kbhowto kbuidesign KB244232

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.