在桌面窗口上绘制和擦除线条 [英] Draw and Erase lines on Desktop Window

查看:72
本文介绍了在桌面窗口上绘制和擦除线条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在VC ++ 6.0中有一个要求,即在窗口之间的桌面窗口上绘制线条,并在不需要时删除它们.线是从一个窗口穿过桌面窗口绘制到另一窗口的.作为要求的一部分,必须用不同的颜色显示线条.我可以将SetROP2与R2_XORPEN一起使用,它非常适合使用桌面Widnow绘制和擦除线条.但是,桌面上的线条是通过线条颜色和桌面窗口颜色的组合而反转的.我尝试使用二进制栅格操作来抑制此问题,但是没有一种组合可以解决该问题.您能帮忙什么解决方案吗?

问候
shanpalaniram

Hi,

I have a requirement in VC++6.0 where draw lines at desktop window between windows and erase them when is not needed. The lines are drawn from one window to another window passing through the desktop window. As part of the requirement the lines must be shown with different colors. I can use SetROP2 with R2_XORPEN which works perfectly for drawing and erasing lines using desktop widnow. But the line is on desktop is inverted with the combination of line color and desktop window color. I tried using Binary raster operations for suppressing this issue but none of the combination is resolved the issue. Could you help what is the solution for this?

regards
shanpalaniram

推荐答案

如果希望以纯色绘制线条,则不应将SetROP2 R2_XORPEN 一起使用.只需使用普通模式绘制线条即可.

要擦除"该行,只需使用Invalidate函数之一使相应区域无效.例如:

If you want your line to be drawn in plain color, then you shouldn''t use SetROP2 with R2_XORPEN. Just use the normal mode to draw your line.

To "erase" the line, just invalidate the corresponding area with one of the Invalidate functions. For example:

HWND hDesktopWnd = GetDesktopWindow();
//redraw the rectangle area which contains the line
InvalidateRect(hDesktopWnd, &rect, TRUE);
//or with a region
InvalidateRgn(hDesktopWnd, rgn, TRUE);


我从来没有做过我将要描述的事情,因此我无法告诉它是否可以正常工作,但是您可以尝试将所有窗口托管在一个主窗口中,并使该主窗口透明.

然后,您将在主窗口内绘制线条为非透明线,并且可以轻松使主窗口无效.

检查此链接以了解如何制作透明窗口:
http://msdn.microsoft.com/en-us/library/ms997507.aspx [ ^ ]

希望对您有所帮助.
I have never done what I will describe and therefore I can''t tell wether it will work ot not, but you can try to host all your windows in a main window and make this main window transparent.

You would then draw the lines inside your main window as non-transparent, and can invalidate the main window easily.

Check this link to know how to make transparent windows:
http://msdn.microsoft.com/en-us/library/ms997507.aspx[^]

I hope this will help.


这篇关于在桌面窗口上绘制和擦除线条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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