Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

60 lines
1.8 KiB
C++

// Filename: ScrollHelper.h
// S.Chan, 01 Jul 2005
#ifndef SCROLL_HELPER_INCLUDED
#define SCROLL_HELPER_INCLUDED
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CScrollHelper
{
public:
CScrollHelper();
~CScrollHelper();
// Attach/detach a CWnd or CDialog.
void AttachWnd(CWnd* pWnd);
void DetachWnd();
// Set/get the virtual display size. When the dialog or window
// size is smaller than the display size, then that is when
// scrollbars will appear. Set either the display width or display
// height to zero if you don't want to enable the scrollbar in the
// corresponding direction.
void SetDisplaySize(int displayWidth, int displayHeight);
const CSize& GetDisplaySize() const;
// Get current scroll position. This is needed if you are scrolling
// a custom CWnd which implements its own drawing in OnPaint().
const CSize& GetScrollPos() const;
// Get current page size. Useful for debugging purposes.
const CSize& GetPageSize() const;
// Scroll back to top, left, or top-left corner of the window.
void ScrollToOrigin(bool scrollLeft, bool scrollTop);
// Message handling.
void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
void OnSize(UINT nType, int cx, int cy);
private:
int Get32BitScrollPos(int bar, CScrollBar* pScrollBar);
void UpdateScrollInfo();
void UpdateScrollBar(int bar, int windowSize, int displaySize,
LONG& pageSize, LONG& scrollPos, LONG& deltaPos);
CWnd* m_attachWnd;
CSize m_pageSize;
CSize m_displaySize;
CSize m_scrollPos;
};
#endif // SCROLL_HELPER_INCLUDED
// END