Black highlight bar with GDI

房东的猫 提交于 2019-12-04 04:58:18

问题


I got some nice splitter code for my GUI but I can't get the pen/brush/whatever it is I need to do proper highlighting. You know how in visual studio 10, the splitter bars can be dragged and there's a beautiful black transparent bar letting you know where the split will happen when you lift up your mouse button. Here's a picture: http://www.freeimgshost.com/fullsize/efmcxyyu1wbyb1r7mz0.png

How can I achieve that black highlight bar using solely GDI and c++?


回答1:


The Visual Studio UI is implemented in WPF, so I'd guess that the splitter bar is just a semi-transparent filled rectangle.

However, GDI has fairly poor support for transparency.

You could get the same effect using a semi-transparent, always-on-top, layered window. This is a simple solution because you don't have to worry about repainting anything. You just move the window about.

This answer to another question has some code that creates such a window (for a different purpose).




回答2:


This is probably one of the correct uses for LockWindowUpdate().

On Mousedown, lock the window, and start drawing the drag bar directly. As the mouse is still captured, the drag bar will still receive mouse notification. On mouseup, unlock the window, resize and let the drawing carry on as normal.



来源:https://stackoverflow.com/questions/11289896/black-highlight-bar-with-gdi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!