如何绘制一个禁用的图标 [英] how to draw a disabled icon

查看:94
本文介绍了如何绘制一个禁用的图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我终于可以在下拉菜单中添加图标了

I'm finally getting around to adding icons to our pull down menus:


在此图像中,您可以看到除高亮显示的行以外的所有内容都还可以.除了图标是彩色的而不是灰色的以外,突出显示的行还不错.


In this image, you can see that everything but the highlighted line is okay. The highlighted line is fine except for the icon, which is drawn in color, instead of grayed.

我基于极简方法编写代码:
http://www.codeproject.com/Articles/16529/Simple-Menus-That-Display-Icons-Minimalistic-Appro?msg=4166441#xx4166441xx

I'm basing my code off of a minimalist approach:
http://www.codeproject.com/Articles/16529/Simple-Menus-That-Display-Icons-Minimalistic-Appro?msg=4166441#xx4166441xx

基本上,这仅需要我绘制图标,而不必使用自定义代码来管理菜单项的所有方面.很漂亮.

Basically, this only requires that I draw the icon, and I don't have to manage all aspects of a menu item using custom code. Pretty nifty.

它适用于我们的目的,但选择禁用(灰色)菜单项时除外.
但是,当菜单项变为灰色并被选中时,绘制的图标就会显示出来,就像启用该图标一样.错误的. :(

It works for our purposes except when selecting a disabled (grayed) menu item.
But when the menu item is grayed and selected, then the drawn icon appears as it would if it were enabled. Wrong. :(

但是,突出显示/选择背景时,完全相同的绘图代码也可以使用.

Yet the exact same drawing code works when the background is highlighted/selected.

这使我相信HDC中包含一些必须完全控制图标显示方式的声明-因为以下代码在所有条件下(但处于选中状态)都可以工作:

::DrawIconEx(lpdis->hDC, lpdis->rcItem.left+0, lpdis->rcItem.top, pIcon->GetHandle(), pIcon->GetSize().cx, pIcon->GetSize().cy, 0, NULL, DI_NORMAL);

有人知道HDC封装了什么状态来控制DrawIconEx的功能吗?如果我可以在选定图形期间复制未选中图形时发现的HDC状态,那么我应该能够生成灰色图标,而无需采用手动对内存中的图标进行灰度缩放的30-50行实现.

Does anyone know what state is encapsulated in the HDC that would control how DrawIconEx functions? If I can replicate the HDC state during selected drawing as found when not-selected-drawing, I should be able to generate the grayed icons without resorting the 30-50 line implementations that manually gray-scale the icon in memory.

推荐答案

您可以使用:

DrawState(...)

带有DSS_DISABLED标志的API函数,但是我不确定输出的质量.

API function, with DSS_DISABLED flag, but I am not sure about the quality of the output.

这篇关于如何绘制一个禁用的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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