写toolbar的一些小的问题。

编程小白_大场 2013-03-18 02:30:51
我要做成这一种,正在改代码,但是改的不知道哪里错了。帮我看一下,有一个资源一直找不到。

我的这个东西在我的资源里。大虾帮我看一下。好吧。非常感谢。
http://download.csdn.net/detail/sadasasdasd/5153827
...全文
345 25 打赏 收藏 转发到动态 举报
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
zrdongjiao 2013-03-19
  • 打赏
  • 举报
回复
引用 17 楼 schlafenhamster 的回复:
你在 资源 编辑中 试试, 不可能 把 分隔条 放 第一个 按钮 前 (左边)!
这里说的第一个按钮 应该是从0,1,2...n 中的1吧, 索引是从0开始
schlafenhamster 2013-03-19
  • 打赏
  • 举报
回复
你在 资源 编辑中 试试, 不可能 把 分隔条 放 第一个 按钮 前 (左边)!
shandongmn 2013-03-19
  • 打赏
  • 举报
回复
引用 15 楼 sadasasdasd 的回复:
引用 2 楼 shen_wei 的回复:下载需要积分??这个就没有人愿意帮忙了,你懂额!! 你的这个可以new CToolBar 在初始化时创建ToolBar http://www.codeproject.com/Articles/6622/CToolbarDialog-dialog-with-floating-toolbar 引用 5 楼 zhoujiel……
帮忙看看13楼
  • 打赏
  • 举报
回复
引用 2 楼 shen_wei 的回复:
下载需要积分??这个就没有人愿意帮忙了,你懂额!! 你的这个可以new CToolBar 在初始化时创建ToolBar http://www.codeproject.com/Articles/6622/CToolbarDialog-dialog-with-floating-toolbar
引用 5 楼 zhoujielunzhimi 的回复:
解决了吗?顶一个
引用 9 楼 schlafenhamster 的回复:
你自己一点没做? 还花了我一分。 你要说明 哪里 有问题,要 靠 自己, 别人 只是 帮忙。
引用 12 楼 yangyi_33855 的回复:
引用 11 楼 schlafenhamster 的回复:不需要在位图上绘制分割线 setbuttons TTBUTTON 有 分隔条 属性。 正解,就是这样,顶了。
感谢,感谢,非常的感谢,我已经把它做好了,会在周四的时候发一篇博客。谢谢,还是希望你们给我邮箱,到时候直接发你们邮箱,再来回贴就行了。呵呵。我是小问题不断,大问题解决不了。呵呵,正在努力看。这一方面的知识。
  • 打赏
  • 举报
回复
引用 9 楼 schlafenhamster 的回复:
你自己一点没做? 还花了我一分。 你要说明 哪里 有问题,要 靠 自己, 别人 只是 帮忙。
做了呀,怎么没有做,传的时候太着急了,不过已经解决了。不好意思。
shandongmn 2013-03-19
  • 打赏
  • 举报
回复
引用 24 楼 shandongmn 的回复:
引用 22 楼 schlafenhamster 的回复:看看你的 TBBUTTON tbButton[] = 这是可以 设置 0 为 分隔条的 如 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0}, 诡异了,这么个简单的问题,翻了多次 msdn也没有搞定. C/C++ code?12……
代码中多了个 “}” ,是发帖笔误,真实代码真是没有这个的。
shandongmn 2013-03-19
  • 打赏
  • 举报
回复
引用 22 楼 schlafenhamster 的回复:
看看你的 TBBUTTON tbButton[] = 这是可以 设置 0 为 分隔条的 如 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0},
诡异了,这么个简单的问题,翻了多次 msdn也没有搞定.



当不存在ttbutton的时候, 采用的是 setbuttonsytel的法子,

当不存在ttbutton的时候, 采用的是 setbuttonsytel的法子,

当不存在ttbutton的时候, 采用的是 setbuttonsytel的法子,

 参考:

http://msdn.microsoft.com/en-US/library/w13yte29(v=vs.80).aspx

A button's style determines how the button appears and how it responds to user input.
Before calling SetButtonStyle, call the GetButtonStyle member function to retrieve the button or separator style.

所以有代码:

BOOL CMainFrame::CreatePaletteBar()


{
	

if (!m_wndPaletteBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_SIZE_DYNAMIC |
		CBRS_TOP | CBRS_TOOLTIPS, ID_PALETTEBAR) ||
		!m_wndPaletteBar.LoadBitmap(IDB_PALETTE) ||
		!m_wndPaletteBar.SetButtons(palette,
		  sizeof(palette)/sizeof(UINT)))
	

{
		

TRACE0("Failed to create toolbar\n");
		

return FALSE;       // fail to create


}

	

m_wndPaletteBar.SetWindowText(_T("Palette"));
	

m_wndPaletteBar.EnableDocking(0);

	

// Create the Palette.  We are using hardcoded numbers for ease here
	

// normally the location would be read in from an ini file.
	

CPoint pt(GetSystemMetrics(SM_CXSCREEN) - 100,
	GetSystemMetrics(SM_CYSCREEN) / 3);

	

//m_wndPaletteBar.SetColumns(3);
	

FloatControlBar(&m_wndPaletteBar, pt);


	UINT dwStyle=m_wndPaletteBar.GetButtonStyle(2);

	dwStyle|=TBBS_SEPARATOR;

	m_wndPaletteBar.SetButtonStyle(2,dwStyle);

	return TRUE;
}



	UINT dwStyle=m_wndPaletteBar.GetButtonStyle(2);

	dwStyle|=TBBS_SEPARATOR;

	m_wndPaletteBar.SetButtonStyle(2,dwStyle);

}
palette  id数组的定义为:



static UINT BASED_CODE palette[] =
{
	

// same order as in the bitmap 'palette.bmp'
	

ID_PALETTEERASE,
	
ID_PALETTEPEN,
	
ID_SEPARATOR,		//已经改成第2个位置了
	
ID_PALETTESELECT,
	
ID_PALETTEBRUSH,
	
ID_PALETTESPRAY,
	
ID_PALETTEPAINT,
	
ID_PALETTELINE,
	
ID_PALETTEEYEDROP,
	
ID_PALETTEMAG,
	
ID_PALETTERECT,
	
ID_PALETTEROUND,
	
ID_PALETTEOVAL

};


把id数组的第2个设置值为:ID_SEPARATOR的原因:
参考:
http://msdn.microsoft.com/en-US/library/xeh4y0x1(v=vs.80).aspx

If an element of the array has the value ID_SEPARATOR, a separator is created in the corresponding position of the toolbar. This function also sets each button's style to TBBS_BUTTON and each separator's style to TBBS_SEPARATOR, and assigns an image index to each button. The image index specifies the position of the button's image within the bitmap.





源码在20楼
shandongmn 2013-03-19
  • 打赏
  • 举报
回复
引用 22 楼 schlafenhamster 的回复:
看看你的 TBBUTTON tbButton[] = 这是可以 设置 0 为 分隔条的 如 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0},
诡异了,这么个简单的问题,翻了多次
schlafenhamster 2013-03-19
  • 打赏
  • 举报
回复
看看你的 TBBUTTON tbButton[] = 这是可以 设置 0 为 分隔条的 如 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0, 0, 0},
melos 2013-03-19
  • 打赏
  • 举报
回复
引用 10 楼 shandongmn 的回复:
引用 9 楼 schlafenhamster 的回复:你自己一点没做? 还花了我一分。 你要说明 哪里 有问题,要 靠 自己, 别人 只是 帮忙。 引用 6 楼 sadasasdasd 的回复:引用 5 楼 zhoujielunzhimi 的回复:解决了吗?顶一个 好了,谢谢,老哥,多谢谢。 引用 5 楼 zhoujielunzhimi 的回复:解决了吗……
分割线不用位图去弄。。
shandongmn 2013-03-19
  • 打赏
  • 举报
回复
引用 19 楼 schlafenhamster 的回复:
不可能 把 分隔条 放 第一个 按钮 前 (最左边)!
也 就是 index=0 的 位置 ,不可能是 分隔条。



http://pan.baidu.com/share/link?shareid=304433&uk=1913319109

源码在这里,方便看看吗?

vc6的工程, 很简单, 有图片的

schlafenhamster 2013-03-19
  • 打赏
  • 举报
回复
不可能 把 分隔条 放 第一个 按钮 前 (最左边)! 也 就是 index=0 的 位置 ,不可能是 分隔条。
shandongmn 2013-03-18
  • 打赏
  • 举报
回复
引用 12 楼 yangyi_33855 的回复:
引用 11 楼 schlafenhamster 的回复:不需要在位图上绘制分割线 setbuttons TTBUTTON 有 分隔条 属性。 正解,就是这样,顶了。
引用 11 楼 schlafenhamster 的回复:
不需要在位图上绘制分割线 setbuttons TTBUTTON 有 分隔条 属性。
奇怪,我用的和你们的不一样啊, 我是在网上的一例子的基础上进行修改的, 可以帮忙斧正吗 BOOL CMainFrame::CreatePaletteBar() { if (!m_wndPaletteBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_SIZE_DYNAMIC | CBRS_TOP | CBRS_TOOLTIPS, ID_PALETTEBAR) || !m_wndPaletteBar.LoadBitmap(IDB_PALETTE) || !m_wndPaletteBar.SetButtons(palette, sizeof(palette)/sizeof(UINT))) { TRACE0("Failed to create toolbar\n"); return FALSE; // fail to create } m_wndPaletteBar.SetWindowText(_T("Palette")); m_wndPaletteBar.EnableDocking(0); // Create the Palette. We are using hardcoded numbers for ease here // normally the location would be read in from an ini file. CPoint pt(GetSystemMetrics(SM_CXSCREEN) - 100, GetSystemMetrics(SM_CYSCREEN) / 3); //m_wndPaletteBar.SetColumns(3); FloatControlBar(&m_wndPaletteBar, pt); m_wndPaletteBar.SetButtonStyle(1,TBBS_SEPARATOR); //设置这个风格,希望index的地方出现分割线,结果没有出现 return TRUE; } static UINT BASED_CODE palette[] = { // same order as in the bitmap 'palette.bmp' ID_PALETTEERASE, 0, //这个是我加的,希望这里出现一个分隔条,感觉不对 ID_PALETTEPEN, ID_PALETTESELECT, ID_PALETTEBRUSH, ID_PALETTESPRAY, ID_PALETTEPAINT, ID_PALETTELINE, ID_PALETTEEYEDROP, ID_PALETTEMAG, ID_PALETTERECT, ID_PALETTEROUND, ID_PALETTEOVAL }; 反正分割线是没有出来, 我是希望第1个位置出现分割线, 程序运行的效果是: 第1个位置为空白, 不知道怎么修改啊
yangyi_33855 2013-03-18
  • 打赏
  • 举报
回复
引用 11 楼 schlafenhamster 的回复:
不需要在位图上绘制分割线 setbuttons TTBUTTON 有 分隔条 属性。
正解,就是这样,顶了。
schlafenhamster 2013-03-18
  • 打赏
  • 举报
回复
不需要在位图上绘制分割线 setbuttons TTBUTTON 有 分隔条 属性。
shandongmn 2013-03-18
  • 打赏
  • 举报
回复
引用 9 楼 schlafenhamster 的回复:
你自己一点没做? 还花了我一分。 你要说明 哪里 有问题,要 靠 自己, 别人 只是 帮忙。
引用 6 楼 sadasasdasd 的回复:
引用 5 楼 zhoujielunzhimi 的回复:解决了吗?顶一个 好了,谢谢,老哥,多谢谢。
引用 5 楼 zhoujielunzhimi 的回复:
解决了吗?顶一个
楼主的问题让我想起另一个问题来,帮忙解答以下,多谢 关于分割线的问题, 需不需要在位图上绘制分割线。 我的意思是说:是否分割线 是系统帮忙产生的, 不需要像其他按钮一样,需要提供相应的位图. 我尝试了一下,是不行的 LoadBitmaps(不带分割线的位图)后, 再setbuttons(设置按钮的id) 结果没有出现“分割线”
schlafenhamster 2013-03-18
  • 打赏
  • 举报
回复
你自己一点没做? 还花了我一分。 你要说明 哪里 有问题,要 靠 自己, 别人 只是 帮忙。
  • 打赏
  • 举报
回复
引用 7 楼 schlafenhamster 的回复:
下班回家看看
谢谢。
schlafenhamster 2013-03-18
  • 打赏
  • 举报
回复
下班回家看看
  • 打赏
  • 举报
回复
引用 5 楼 zhoujielunzhimi 的回复:
解决了吗?顶一个
好了,谢谢,老哥,多谢谢。
加载更多回复(5)

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧