.
Download Source Code and Example
Environment: VC++ 5.0 SP3, commctrl.dll 4.71 or above.
Up to date commctrl.h/comctl32.lib (From Latest Platform SDK)
Microsoft. Internet Explorer Version 4.0 introduces a new
visual technology called flat scroll bars. Functionally,
flat scroll bars behave just like normal scroll bars. The only
difference is they are not displayed three-dimensionally. Flat
scroll bar APIs are implemented in version 4.71 and later of
Comctl32.dll.

Here’s a Thin Wrapper around the Flat ScrollBar API.
Header File
class CFlatScrollBar
{
// Construction
public:
CFlatScrollBar();
// Attributes
public:
CWnd *m_pWnd;
// Operations
public:
BOOL EnableScrollBar(int, UINT);
BOOL ShowScrollBar(int code, BOOL);
BOOL GetScrollRange(int code, LPINT, LPINT);
BOOL GetScrollInfo(int code, LPSCROLLINFO);
int GetScrollPos(int code);
BOOL GetScrollProp(int propIndex, LPINT);
int SetScrollPos(int code, int pos, BOOL fRedraw);
int SetScrollInfo(int code, LPSCROLLINFO, BOOL fRedraw);
int SetScrollRange(int code, int min, int max, BOOL fRedraw);
BOOL SetScrollProp(UINT index, int newValue, BOOL);
BOOL InitializeFlatSB(CWnd *);
HRESULT UninitializeFlatSB();
// Implementation
public:
virtual ~CFlatScrollBar();
protected:
};
Implementation File
CFlatScrollBar::CFlatScrollBar()
{
m_pWnd = NULL;
}
CFlatScrollBar::~CFlatScrollBar()
{
m_pWnd = NULL;
}
/////////////////////////////////////////////////////////////////////////////
// CFlatScrollBar message handlers
BOOL CFlatScrollBar::EnableScrollBar(int wSBflags,UINT wArrows)
{
return ::FlatSB_EnableScrollBar(m_pWnd->GetSafeHwnd(),wSBflags,wArrows);
}
BOOL CFlatScrollBar::ShowScrollBar(int code, BOOL bShow)
{
return ::FlatSB_ShowScrollBar(m_pWnd->GetSafeHwnd(),code, bShow);
}
BOOL CFlatScrollBar::GetScrollRange(int code, LPINT lpMinPos, LPINT lpMaxPos)
{
return ::FlatSB_GetScrollRange(m_pWnd->GetSafeHwnd(),code,lpMinPos,lpMaxPos);
}
BOOL CFlatScrollBar::GetScrollInfo(int code, LPSCROLLINFO lpsi)
{
return ::FlatSB_GetScrollInfo(m_pWnd->GetSafeHwnd(),code,lpsi);
}
int CFlatScrollBar::GetScrollPos(int code)
{
return ::FlatSB_GetScrollPos(m_pWnd->GetSafeHwnd(),code);
}
BOOL CFlatScrollBar::GetScrollProp(int propIndex, LPINT pValue)
{
return ::FlatSB_GetScrollProp(m_pWnd->GetSafeHwnd(),propIndex, pValue);
}
int CFlatScrollBar::SetScrollPos(int code, int pos, BOOL fRedraw)
{
return ::FlatSB_SetScrollPos(m_pWnd->GetSafeHwnd(),code,pos,fRedraw);
}
int CFlatScrollBar::SetScrollInfo(int code, LPSCROLLINFO lpsi, BOOL fRedraw)
{
return ::FlatSB_SetScrollInfo(m_pWnd->GetSafeHwnd(),code,lpsi,fRedraw);
}
int CFlatScrollBar::SetScrollRange(int code, int min, int max, BOOL fRedraw)
{
return ::FlatSB_SetScrollRange(m_pWnd->GetSafeHwnd(),code,min,max,fRedraw);
}
BOOL CFlatScrollBar::SetScrollProp(UINT index, int newValue, BOOL fRedraw)
{
return ::FlatSB_SetScrollProp(m_pWnd->GetSafeHwnd(),index,newValue,fRedraw);
}
BOOL CFlatScrollBar::InitializeFlatSB(CWnd *pWnd)
{
m_pWnd = pWnd;
return ::InitializeFlatSB(pWnd->GetSafeHwnd());
}
HRESULT CFlatScrollBar::UninitializeFlatSB()
{
return ::UninitializeFlatSB(m_pWnd->GetSafeHwnd());
}
To use CFlatScrollBar on a CEdit Control inside a CDialog:
BOOL CFlatScrollDlg::OnInitDialog()
{
CDialog::OnInitDialog();
...
scrollbar.InitializeFlatSB(&m_edit);
scrollbar.EnableScrollBar(SB_BOTH,ESB_ENABLE_BOTH);
...
}
Last updated: 16 June 1998