如何更改突出显示菜单项的标记的颜色? [英] How to change the color of the marker that highlights menu items ?
问题描述
首先,我要感谢所有花时间查看此主题并尝试提供帮助的人。
我有一个所有者绘制的弹出菜单,子菜单,也是所有者绘制的。
当我运行代码时会发生以下效果:
当我将鼠标悬停在子菜单上时项目,他的背景变成白色,箭头(表示子菜单有项目的箭头)变成白色箭头。
我的问题是:
如何更改该标记的颜色(例如让它变成红色)?
一些代码示例/伪代码/说明/教程/链接......欢迎。
更新#4:
***** ************************************************** ****************************************
通过使用
ExtTextOut()
并使用样式
ETO_OPAQUE $ p修复了文本背后出现白色背景的问题$ p>。
箭头仍然是白色。
我可以使用以下代码正确突出显示项目WM_DRAWITEM:
if (lpdis-> itemAction& ODA_SELECT) // 如果选择了项目
{
if (lpdis-> itemState& ODS_SELECTED)
{
// < span class =code-comment>设置高亮标记的颜色
SetBkColor(lpdis-> hDC,RGB( 117 , 210 , 255 ));
// 绘制所需文本
ExtTextOut (lpdis-> hDC,lpdis-> rcItem.left,
lpdis-> rcItem.top,ETO_OPAQUE,& lpdis-> rcItem,
(LPCWSTR)lpdis-> itemData,
wcslen((LPCWSTR)lpdis-> itemData),NULL);
// 绘制标记的边缘
DrawEdge(lpdis-> hDC,& lpdis-> rcItem,EDGE_RAISED,
BF_FLAT);
// 在菜单项周围绘制框架并为其着色以匹配标记颜色
FrameRect(lpdis-> hDC,& lpdis-> rcItem,
CreateSolidBrush(RGB( 117 , 210 , 255 )));
}
}
***************** ************************************************** ****************************
我在Windows XP上的MS Visual Studio Express 2008中工作C ++,使用纯 WIN32 API。
如果需要任何其他信息(源代码或类似的东西),请索取,我非常乐意提供它。
解决方案
解决方案是所有者绘制菜单。这样做的工作如下:
所有者绘制的菜单,带有图标,标题和阴影 [ ^ ]
I would like to start by saying thanks to everyone who takes some time to view this thread and try to help.
I have a owner drawn popup menu, with submenu, which is also owner drawn.
When I run the code the following effect happens:
When I hover with mouse over submenu''s item, his background becomes white , and the arrow ( the one that indicates that submenu has items ) turns into white arrow.
My question is:
How do I change the color of that marker ( let it be red for example ) ?
Some code example/ pseudo-code / instructions / tutorials / links ... would be welcome.
UPDATE #4:
***********************************************************************************************
Fixed the problem of white background appearing behind text by using
ExtTextOut()
with style
ETO_OPAQUE
.
Arrow is still white.
I can highlight item properly with following code in WM_DRAWITEM:
if( lpdis->itemAction & ODA_SELECT ) // if item is selected
{
if(lpdis->itemState & ODS_SELECTED)
{
// set the color of the highlight marker
SetBkColor( lpdis->hDC, RGB(117, 210, 255) );
// draw desired text
ExtTextOut( lpdis->hDC, lpdis->rcItem.left,
lpdis->rcItem.top, ETO_OPAQUE, &lpdis->rcItem,
(LPCWSTR)lpdis->itemData,
wcslen((LPCWSTR)lpdis->itemData), NULL);
// draw edges of the marker
DrawEdge( lpdis->hDC, &lpdis->rcItem, EDGE_RAISED,
BF_FLAT );
// draw frame around menu item and color it so it matches the markers color
FrameRect( lpdis->hDC, &lpdis->rcItem,
CreateSolidBrush( RGB(117, 210, 255) ) );
}
}
***********************************************************************************************
I work in MS Visual Studio Express 2008, on Windows XP, in C++, using pure WIN32 API.
If any other information is required ( source code or something similar ), please ask for it, I will more than gladly supply it.
解决方案 The solution is owner draw the menu. It is some work like this to:
Owner Drawn Menu with Icons, Titles and Shading[^]
这篇关于如何更改突出显示菜单项的标记的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!