Download Source Code and Example
This code provides a simple way of adding full AutoScroll capability to pretty much any window, I have provided a demo program which also incorporates the all of the code you need. I believe it works the same way as Internet Explorer, that is all of the behaviour I have seen from IE. The cursor changes in every direction just as it does in IE, it uses the pointers and origin bitmaps pretty much the same as IE, these are the cursors and bitmaps supplied with the Intellipoint SDK with slight modificatiosn to the bitmaps.
static const UINT uOriginWindowUpdateMessage = ::RegisterWindowMessage( OWND_WINDOW_UPDATE );
LRESULT CPanningWindowView::OnOriginWindowUpdate(WPARAM
, LPARAM lParam)
//
// Process the update message sent by the
origin window.
// You only need to respond to this message
if you want to do extra or different scrolling
{
//
// psizeDistance will
contain the distance the cursor is from the origin. We then use
// this to calculate the
new scroll position and the amount to scroll our window.
const CSize *psizeDistance
= reinterpret_cast<const CSize *>( lParam );
#ifdef _DEBUG
afxDump<<_T("CPanningWindowView::OnOriginWindowUpdate
size")<<*psizeDistance<<_T("\n");
#endif // _DEBUG
//
// Return
1 to signal to COriginWnd that you have handled the scrolling, return 0
if you
// want
COriginWnd to perform the scrolling.
return 0;
}
The demo project shows all of this behaviour in the source file PanningWindowView.cpp.
This code imroves over the other examples posted to codeguru in the following areas:
Last updated: 13 June1998
Goto HomePage |
|
Contact me: zafir@home.com
|