添加颜色选择器工具栏,例如mspaint的 [英] Adding a color-picker toolbar like mspaint's

查看:103
本文介绍了添加颜色选择器工具栏,例如mspaint的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在偏好设置"对话框中添加一个类似于mspaint的颜色选择器.

I want to add a color picker in my preferences dialog that is like mspaint's.

这可能与MFC有关吗?我之所以使用VC6,是因为该项目是很久以前启动的,现在无法移植,因此不能使用新的MFC类.

Is this possible to do with MFC? I'm using VC6 because the project was started on it a long time ago and now it can't be ported, so I can't use new MFC classes.

推荐答案

此难题有两部分.首先是类似多行工具栏的功能.第二个是单击编辑颜色"时调用的颜色选择器.

There are a couple of pieces to this puzzle. First is the multi-row toolbar-like functionality. The second is the color picker that gets invoked when you click "Edit Colors".

第一个 可以使用多行工具栏(在一定程度上)进行模仿.我似乎想起了VC6的CToolBar在多行工具栏上存在一些问题,但是我不确定该问题是否已在Service Pack中修复(看起来好像已经修复了,但我不确定)

The first can be imitated (to a degree) with a multi-row tool bar. I seem to recall VC6's CToolBar having some issues with multi-row toolbars, but I'm not sure whether that may have been fixed in an service pack (it kind of seems like it might have, but I don't remember for sure).

如果您不喜欢这样(它看起来与原始版本不一样),那么您将很难创建自己的控件并将其放入CToolBar中.只要您只想照原样模仿控件,就不会很困难-您基本上会向控件传递一个颜色数字数组,并且在单击时会发送一条通知消息带有选定的颜色编号(如果需要,还可以包含颜色编号的索引).只要坚持使用固定的布局,数学就很容易了,但是如果您希望支持更改布局,那么匆忙就会变得困难得多.

If you don't like that (it won't look much like the original), you'd be pretty much stuck with creating your own control and putting it into a CToolBar. As long as you only want to imitate the control exactly as-is, that won't be terribly difficult -- you'll basically pass the control an array of color numbers, and when there's a click, it'll send a notification message with the chosen color number (or the index of the color number, if you prefer). The math for that is pretty easy as long as you stick with a fixed layout, but if you want to support changing the layout, it can get a lot more difficult in a hurry.

第二部分,一个很好的起点可能是汉斯·迪特里希(Hans Deitrich)的 XColorSpectrumCtrl .

For the second part, one good starting point would probably be Hans Deitrich's XColorSpectrumCtrl.

这篇关于添加颜色选择器工具栏,例如mspaint的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆