python - Python 中的 Windows 7 MARGINS 结构

标签 python windows-7 pywin32 aero margins

我正在尝试让一些更有趣的 Windows Aero 效果在 Python 中运行。

DwmExtendFrameIntoClientArea 函数可用于将 Aero 玻璃扩展到客户区。它需要一个窗口句柄和一个指向 MARGINS 结构的指针。我已经知道如何在 Python 中获取窗口句柄;但是,我不知道如何制作边距结构。

MARGINS structure, MSDN Docs

这是我目前所拥有的:

import Tkinter as tk
import string
import ctypes

root = tk.Tk()

handle = string.atoi(root.wm_frame(), 0)

dwm = ctypes.windll.dwmapi

# needs pointertomarginsstruct
dwm.DwmExtendFrameIntoClientArea(handel, pointertomarginsstruct)

root.mainloop()

最佳答案

我没有运行 Win7 来测试这个,但尝试用 ctypes 定义结构:

class MARGINS(ctypes.Structure):
  _fields_ = [("cxLeftWidth", c_int),
              ("cxRightWidth", c_int),
              ("cyTopHeight", c_int),
              ("cyBottomHeight", c_int)
             ]
margins = MARGINS(1, 2, 1, 1)

dwm.DwmExtendFrameIntoClientArea(handel, ctypes.byref(margins))

关于python - Python 中的 Windows 7 MARGINS 结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7197327/

相关文章:

video - Windows Media Foundation 使用 IMFTransform 将 mp4 电影帧解码为 2D 纹理

python - 将 win32lfn 扩展与 Mercurial 捆绑在一起

python - 错误 "ValueError: can' t 格式日期这么早"在一台 PC 上,在其他 PC 上工作

python - 如何创建一个自动生成所有字段的 factory_boy 工厂?

java - 如何检测我的程序是否在Windows 7下 "windows xp mode"下运行

python - 快速截图 Winapi 和 Opencv

ruby - JSON gem安装错误: unable to download data

python - 查找窗口失败

python - 通过用向量化替换 lambda x 来增强排序函数的性能

python - Google Cloud Functions 包含 Brew 依赖项