Flat Scroll Bar Common Control | CodeGuru

Flat Scroll Bar Common Control

.   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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Aug 5, 1998
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

.

 
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

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.