Python中的windows7页边距结构

2024-05-19 03:37:51 发布

您现在位置:Python中文网/ 问答频道 /正文

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

dwmextendenframeintoclientarea功能可用于将Aero glass扩展到客户区。它需要一个窗口句柄和一个指向页边距结构的指针。我已经知道如何用Python获得窗口的句柄;但是,我不知道如何创建margins结构。在

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()

Tags: import功能stringwindowsrootctypes句柄结构
1条回答
网友
1楼 · 发布于 2024-05-19 03:37:51

我没有运行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))

相关问题 更多 >

    热门问题