cpp
class CScrollContainer : public CWnd
{
public:
CScrollContainer();
// Attributes
protected:
int m_nScrollPos; // Current scroll position
int m_nTotalHeight; // Total content height
int m_nPageHeight; // Visible area height
int m_nLineHeight; // Single line height
// Operations
public:
void SetTotalHeight(int nHeight); // Set total content height
void ScrollTo(int nPos); // Scroll to specified position
void UpdateScrollBar(); // Update scrollbar state
protected:
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnButtonClick(UINT nID);
DECLARE_MESSAGE_MAP()
};
效果:
