加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

winapi – Win32:如何在窗外画画?

发布时间:2020-12-14 02:07:05 所属栏目:Windows 来源:网络整理
导读:查看 Windows工具提示类提示窗口,我看到它在提示窗口的实际矩形之外绘制了它的阴影. 使用SpyXX – 我可以获得工具提示的窗口rect和类样式: Rectangle: (440,229)-(544,249),104x20Restored Rect: (440,104x20Client Rect: (0,0)-(104,20),104x20 您会注意到
查看 Windows工具提示类提示窗口,我看到它在提示窗口的实际矩形之外绘制了它的阴影.

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

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

您会注意到,您看到的投影实际上位于正在绘制的窗口之外.当我在窗外时如何在窗户外面画一个阴影?

注意:The shadow is not drawn using the standard CS_DROPSHADOW class style.我已经通过实验证实了这一点,并且还可以在SpyXX中看到窗口的类样式;它不使用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的Redirecting GDI,DirectX,and WPF applications:

Drawing To and Reading From the Screen
— Baaaad!

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:

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)

解决方法

你不能以你描述的方式在窗外画画.

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

底线是,这是窗口管理器的产品,而不是您的程序.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读