PRB: Problem with ScrollBar Control While Activated In-place

ID: Q108942


The information in this article applies to:
  • Microsoft OLE Libraries for Windows and Win32s, versions 2.0, 2.01


SUMMARY

It is not possible to use a ScrollBar child control inside a window that will be used as the in-place window in a container application.


SYMPTOMS

The ScrollBar control does not generate WM_VSCROLL or WM_HSCROLL messages to its parent window.


CAUSE

One way to understand this problem is to examine the case where you have an OLE container application that inserts an in-place capable object into itself using the Insert Object menu option.

When the object is created, and if the container application allows the object to embed itself in-place in the container application, it will set the parent of its editing window to be a window that belongs to the container.

Therefore, a situation occurs where two applications are running; that is, the container and the server. The server application created and owns the window procedure for a window that the object lives in; however, the parent of this window is a window of the container application.

Imagine now that the object's editing window (created by the server and parented by the container) contains a ScrollBar child control. When the user clicks the ScrollBar control by using the left mouse button, a WM_LBUTTONDOWN message is generated that gets handled internally by Windows's ScrollBar child control code.

This code makes a check to ensure that the message queue that has just delivered this message is also owned by the current active application. If they are not, the message will not be processed further and scroll bar messages will not be sent to the ScrollBar control's parent.

This is the case with the in-place scenario described above, and the root of the problem.

The active application is the container application but the message queue that delivered the scroll bar message belongs to the server application.

Also note that this problem does not apply to in-place editing windows that have scroll bars that were created using the WS_HSCROLL or WS_VSCROLL style. The message processing for these scroll bars is slightly different from ScrollBar child controls.


RESOLUTION

Instead of creating a child control with the "scrollbar" class, create a new window class (for example, MYSCROLL) whose window procedure forwards WM_VSCROLL and WM_HSCROLL messages to its parent.

Then you can create windows of this class with either WS_HSCROLL or WS_VSCROLL. Then position these windows the same way you would position ScrollBar controls. When you enable/disable the scroll bar, use the SB_HORZ, SB_VERT flags in the call to EnableScrollBar.

NOTE: You must have one row of pixels of the little window's client area visible or Windows will hide the horizontal scroll bar. This does not apply to the vertical scroll bar; that is, you do not need to have a column of pixels visible.

Additional query words: 2.00 2.01

Keywords : kbole kbprg kbInplaceAct kbOLE200 kbGrpCom kbDSupport kbprb
Version : WINDOWS:2.0,2.01
Platform : WINDOWS
Issue type :


Last Reviewed: October 26, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.