3 Star 9 Fork 7

Gitee 极速下载/WinMerge

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/winmerge/winmerge
克隆/下载
MyReBar.cpp 2.03 KB
一键复制 编辑 原始数据 按行查看 历史
#include "StdAfx.h"
#include "MyReBar.h"
BEGIN_MESSAGE_MAP(CMyReBar, CReBar)
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
CMyReBar::CMyReBar()
{
}
static inline bool IsHighContrastEnabled()
{
HIGHCONTRAST hc = { sizeof(HIGHCONTRAST) };
SystemParametersInfo(SPI_GETHIGHCONTRAST, sizeof(hc), &hc, 0);
return (hc.dwFlags & HCF_HIGHCONTRASTON) != 0;
}
BOOL CMyReBar::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetClientRect(&rect);
pDC->FillSolidRect(&rect, GetSysColor(
IsHighContrastEnabled() ? COLOR_BTNFACE : COLOR_3DHIGHLIGHT));
return TRUE;
}
void CMyReBar::LoadStateFromString(const CString& state)
{
constexpr int BARCOUNT_MAX = 4;
unsigned count = 0;
unsigned id[BARCOUNT_MAX]{};
int cx[BARCOUNT_MAX]{-1, -1};
_stscanf_s(state, _T("%u,%u,%d,%u,%d,%u,%d,%u,%d"), &count, &id[0], &cx[0], &id[1], &cx[1], &id[2], &cx[2], &id[3], &cx[3]);
count = (count > BARCOUNT_MAX) ? BARCOUNT_MAX : count;
CReBarCtrl& rebar = GetReBarCtrl();
const unsigned nBarCount = rebar.GetBandCount();
for (unsigned i = 0; i < count; ++i)
{
for (unsigned j = i; j < nBarCount; ++j)
{
REBARBANDINFO rbi{ sizeof(REBARBANDINFO), RBBIM_CHILD | RBBIM_SIZE | RBBIM_STYLE };
rebar.GetBandInfo(j, &rbi);
if (id[i] != 0 && id[i] == static_cast<unsigned>(GetWindowLong(rbi.hwndChild, GWL_ID)))
{
if (j != i)
rebar.MoveBand(j, i);
if (cx[i] < 0)
{
rbi.fStyle |= RBBS_BREAK;
rbi.cx = -cx[i];
}
else
{
rbi.fStyle &= ~RBBS_BREAK;
rbi.cx = cx[i];
}
rbi.fMask &= ~RBBIM_CHILD;
rebar.SetBandInfo(i, &rbi);
}
}
}
}
CString CMyReBar::GenerateStateString()
{
CReBarCtrl& rebar = GetReBarCtrl();
const unsigned nCount = rebar.GetBandCount();
CString state;
state.AppendFormat(_T("%d"), nCount);
for (unsigned i = 0; i < nCount; ++i)
{
REBARBANDINFO rbi{ sizeof(REBARBANDINFO), RBBIM_CHILD | RBBIM_SIZE | RBBIM_STYLE };
rebar.GetBandInfo(i, &rbi);
state.AppendFormat(_T(",%u,%d"),
GetWindowLong(rbi.hwndChild, GWL_ID),
((rbi.fStyle & RBBS_BREAK) != 0) ? -static_cast<int>(rbi.cx) : rbi.cx);
}
return state;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/mirrors/WinMerge.git
git@gitee.com:mirrors/WinMerge.git
mirrors
WinMerge
WinMerge
master

搜索帮助