首页
社区
课程
招聘
win32 listview in rebar
发表于: 2013-7-23 16:24 3391

win32 listview in rebar

2013-7-23 16:24
3391
请教各位前辈,listview安装在rebar控件内,合适吗?

我觉得rebar可以管理子窗口的size和pos非常方便,应该可行,

可是看很多发布的软件,都没有这么做,rebar内放置最多的就是toolbar和combobox,

不知道是什么原因, 自己也实现一下,确实有些问题阻碍,

比如如果想布局整齐,每个子窗口必须有可调整尺寸的小把手,否则子窗口的尺寸和位置就未知了


BOOL CUserData::CreateReBar(HWND hParent,HINSTANCE hInstance)
{
	DWORD dwStyleEx = WS_EX_TOOLWINDOW;

	DWORD dwStyle = WS_VISIBLE|WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS | CCS_NODIVIDER  |
		RBS_VARHEIGHT | RBS_BANDBORDERS|RBS_FIXEDORDER|RBS_AUTOSIZE;

	hReBar = CreateWindowEx(dwStyleEx,REBARCLASSNAME,NULL,dwStyle,0,0,0,0,hParent,NULL,hInstance,NULL);

	if (!hReBar) return FALSE;


	if (!CreateToolBar(hReBar,hInstance)) return FALSE;


	REBARBANDINFO rbbi = {0};

	

	rbbi.cbSize		= sizeof(REBARBANDINFO);
	rbbi.fMask		= RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_STYLE;
	rbbi.fStyle		= RBBS_BREAK|RBBS_CHILDEDGE|RBBS_FIXEDSIZE;
	rbbi.hwndChild  = hToolBar;
	rbbi.cxMinChild = 0;
	rbbi.cyMinChild = HIWORD(SendMessage(hToolBar,TB_GETBUTTONSIZE,0,0));

	if (!SendMessage(hReBar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&rbbi)) return FALSE;
	


	if (!CreateListView(hReBar,hInstance)) return FALSE;

	RECT rcParent;

	GetClientRect(hParent,&rcParent);

	rbbi.cbSize		= sizeof(REBARBANDINFO);
	rbbi.fMask		= RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_STYLE;
	rbbi.fStyle		= RBBS_BREAK|RBBS_CHILDEDGE|RBBS_FIXEDSIZE;
	rbbi.hwndChild  = hListView;
	rbbi.cxMinChild = 0;
	rbbi.cyMinChild = 500;

	if (!SendMessage(hReBar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&rbbi)) return FALSE;


	if (!CreateStatusBar(hReBar,hInstance)) return FALSE;

	RECT rcStatus;

	GetWindowRect(hStatus,&rcStatus);

	rbbi.cbSize		= sizeof(REBARBANDINFO);
	rbbi.fMask		= RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_STYLE;
	rbbi.fStyle		= RBBS_BREAK|RBBS_CHILDEDGE|RBBS_FIXEDSIZE;
	rbbi.hwndChild  = hStatus;
	rbbi.cxMinChild = 0;
	rbbi.cyMinChild = rcStatus.bottom - rcStatus.top;

	if (!SendMessage(hReBar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&rbbi)) return FALSE;

	return TRUE; 
}





如果可行最好能给个例子看看,小弟谢了

[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 0
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回
//