Win32:如何在窗口外绘制? [英] Win32: How to draw outside my window?

查看:276
本文介绍了Win32:如何在窗口外绘制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看着Windows tooltips类提示窗口,我看到它在提示窗口的实际矩形外部外部绘制了阴影.

Looking at a Windows tooltips class hint window, i see that it draws its drop-shadow outside the hint window's actual rectangle.

使用 SpyXX -我可以获得工具提示的窗口矩形和类样式:

Using SpyXX - i can get the tooltip's window rect, and class styles:

Rectangle:     (440, 229)-(544, 249), 104x20
Restored Rect: (440, 229)-(544, 249), 104x20
Client Rect:   (0, 0)-(104, 20), 104x20

您会注意到,所看到的阴影实际上在绘制的窗口的外部之外.我如何在外部在我的窗口之外,在窗口周围绘制阴影?

You'll notice that the drop shadow you see is physically outside the window that's being drawn. How can i draw a shadow outside around my window, while being outside my window?

注意:

Note: The shadow is not drawn using the standard CS_DROPSHADOW class style. i've confirmed this experimentally, and can also see the class style's for the window in SpyXX; it does not use CS_DROPSHADOW:

Windows Styles:     94000001

    WS_POPUP        80000000
    WS_VISIBLE      10000000
    WS_CLIPSIBLINGS  4000000
    TTS_ALWAYSTIP          1

Extended Styles:    00080088

    WS_EX_LAYERED      80000
    WS_EX_TOOLWIN         80
    WS_EX_TOPMOST          8

那我怎么画在窗外?

注意:尝试在桌面DC上绘图.摘自Greg Schechter的重定向GDI,DirectX和WPF应用程序:

Note: Trying to draw on the desktop DC is out. From Greg Schechter's Redirecting GDI, DirectX, and WPF applications:

在屏幕上绘图和读取 -巴阿德!

Drawing To and Reading From the Screen -- Baaaad!

最后,因为我们正在重定向 一个特别危险的话题 练习是写在屏幕上, 通过使用GetDC(NULL) 并为此写信,或尝试 做XOR橡皮筋线等. 这是写给的两个主要原因 屏幕坏了:

Lastly, since we're on the redirection topic, one particularly dangerous practice is writing to the screen, either through the use of GetDC(NULL) and writing to that, or attempting to do XOR rubber-band lines, etc. There are two big reasons that writing to the screen is bad:

这很昂贵...写信给 屏幕本身并不昂贵,但是它 几乎总是伴随着 从屏幕上阅读,因为 通常会读-修改-写 写入时进行XOR之类的操作 屏幕.从视频中阅读 内存表面非常昂贵, 需要与DWM同步, 并拖延了整个GPU管道, 以及DWM应用程序管道.
这是不可预测的...如果您以某种方式 设法达到实际的主要水平 并写它,不可能有 可预测性,您需要持续多长时间 写给小学的将继续 屏幕.由于UCE不知道 关于它,它可能会在 下一帧刷新,否则可能会持续 在很长一段时间内,取决于 还有什么需要更新的 屏幕. (我们真的不允许直接 无论如何写给主要的 那个原因...如果您尝试 访问DirectDraw主 实例,DWM将关闭,直到 正在访问的应用程序退出)

It's expensive... writing to the screen itself isn't expensive, but it is almost always accompanied by reading from the screen because one typically does read-modify-write operations like XOR when writing to the screen. Reading from the video memory surface is very expensive, requires synchronization with the DWM, and stalls the entire GPU pipe, as well as the DWM application pipe.
It's unpredictable... if you somehow manage to get to the actual primary and write to it, there can be no predictability as to how long what you wrote to the primary will remain on screen. Since the UCE doesn't know about it, it may get cleared in the next frame refresh, or it may persist for a very long time, depending on what else needs to be updated on the screen. (We really don't allow direct writing to the primary anyhow, for that very reason... if you try to access the DirectDraw primary, for instance, the DWM will turn off until the accessing application exits)

推荐答案

您不能以您描述的方式在窗口外部绘制.

You can't draw outside your window in the manner you describe.

如果右键单击桌面,然后转到属性/外观/效果",然后取消选中在菜单下显示阴影" ...您将不再有阴影.

If you right click your desktop then go to properties/appearance/effects and uncheck 'Show shadows under menus' ... you will no longer have the shadow.

最重要的是,这是窗口管理器的产品,而不是您的程序.

Bottom line is that this is a product of the window manager not your program.

这篇关于Win32:如何在窗口外绘制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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