简体   繁体   English

C ++ MFC如何绘制选择矩形?

[英]C++ MFC How to draw selection rectangle?

I have a list control. 我有一个列表控件。 I want to draw selection rectangle on my own. 我想自己绘制选择矩形。 For example: when i clicked on an item it will draw an selection ractangle on that item and the item is next to it (or can be somewhere else). 例如:当我单击一个项目时,它将在该项目上绘制一个选择三角形,并且该项目在它旁边(或可以在其他位置)。

Can anybody tell me how to do that ? 有人可以告诉我该怎么做吗?

Thank you! 谢谢!

To draw a focus rectangle, call the DrawFocusRect function . 要绘制焦点矩形,请调用DrawFocusRect函数 To enable Visual Styles, call the DrawThemeBackground function ( Parts and States : LBCP_ITEM and LBPSI_SELECTED ). 要启用视觉样式,请调用DrawThemeBackground函数部件和状态LBCP_ITEMLBPSI_SELECTED )。

Either way, you will have to create an owner-drawn List Box to be able to adjust rendering. 无论哪种方式,您都必须创建一个所有者绘制的列表框才能调整渲染。 For an MFC CListBox control you have to override at least CListBox::DrawItem (and usually also CListBox::MeasureItem ). 对于MFC CListBox控件,您必须至少重写CListBox :: DrawItem (通常还重写CListBox :: MeasureItem )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM