Microsoft KB Archive/183528

= PRB: ScrollBar and Custom Controls Do Not Have Events to Handle =

Article ID: 183528

Article Last Modified on 12/1/2003

-

APPLIES TO

 The ClassWizard, when used with:  Microsoft Visual C++ 2.0 Professional Edition

 Microsoft Visual C++ 2.1

 Microsoft Visual C++ 2.2

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

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

 Microsoft Visual C++ 4.1 Subscription</li></ul>

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

 Microsoft Visual C++ 4.2 Enterprise Edition</li></ul>

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

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

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

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

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

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

-

<div class="notice_section">

This article was previously published under Q183528

<div class="symptoms_section">

SYMPTOMS
When you double-click a Scroll Bar or custom control in the Visual C++ Dialog editor, the New Windows Message and Event Handlers dialog box appears. However, no events are displayed for the control.

On the Message Maps tab of the MFC ClassWizard dialog box, select a dialog class. The Messages list is blank for Object IDs corresponding to a Scroll Bar or custom control.

<div class="cause_section">

CAUSE
The Scroll Bar and custom controls do not send notification messages so the MFC ClassWizard cannot list any messages to map.

<div class="resolution_section">

RESOLUTION
Use the ClassWizard, as follows, to add WM_HSCROLL or WM_VSCROLL message handlers to the class of the parent window that hosts the Scroll Bar control:


 * 1) Press CTRL+W to open the MFC ClassWizard.
 * 2) On the Message Maps tab, select the dialog class in the Class name box.
 * 3) In the Object IDs list box, select the dialog class.
 * 4) In the Messages list box, select WM_HSCROLL or WM_VSCROLL, then click Add Function.

For the user-defined messages of a custom control, or the WM_CTLCOLORSCROLLBAR message, manually add message handlers to the parent window's class. For additional information, please see the following article in the Microsoft Knowledge Base:

99848 Use ON_MESSAGE Macro to Map Less-Common Messages

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

MORE INFORMATION
The Scroll Bar control does not send notification messages of the SBN_... type. However, it sends WM_HSCROLL, WM_VSCROLL, and WM_CTLCOLORSCROLLBAR messages to its parent window, allowing it to redraw according to the current scroll setting. Though these messages are not considered notifications, they have a similar effect. With the MFC ClassWizard, any window that can contain a Scroll Bar has WM_HSCROLL and WM_VSCROLL messages, and the MFC ClassWizard can add the handlers for those messages.

The custom control does not have standard notifications. Its messages are user-defined events, and the MFC ClassWizard does not know what they might be.

Steps to Reproduce Behavior

 * 1) In Visual C++, open a project that contains a dialog resource.
 * 2) Open the dialog for editing (you can double-click on its ID in ResourceView).
 * 3) From the Controls palette, add a Scroll Bar control to the dialog.
 * 4) Double-click the Scroll Bar control.

The New Windows Message and Event Handlers dialog box opens but the New Windows messages/events list is empty. Close the New Windows Message and Event Handlers dialog box.
 * 1) Press CTRL+W to open the MFC ClassWizard.
 * 2) On the Message Maps tab, select the dialog class in the Class name list box.
 * 3) In the Object IDs list box, select the Scroll Bar ID.

The Messages list is blank.

<div class="references_section">