funcs_winVista.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:petronia 作者: groboclown 项目源码 文件源码
def create_window__create_borderless_window(func_map):
    # Use an inner window, so that we can use the func_map for accessing other functions
    # that are OS specific.

    # Call out to the answer:
    # http://stackoverflow.com/questions/39731497/create-window-without-titlebar-with-resizable-border-and-without-bogus-6px-whit/39735058

    # However, the WM_CREATE just doesn't work right - it causes windows to
    # be automatically closed, even when 0 is explicitly returned.

    def window__create_borderless_window(class_name, title, message_handler, callback_map,
                                         show_on_taskbar=True, always_on_top=False):
        margins = MARGINS()
        margins.cxLeftWidth = 0
        margins.cxRightWidth = 0
        margins.cyTopHeight = 0
        margins.cyBottomHeight = 0

        style_flags = {
            'popup', 'visible',
            # 'layered',   This causes the windows to not show up.
            'transparent'
        }
        if always_on_top:
            style_flags.add('topmost')
        if not show_on_taskbar:
            style_flags.add('tool-window')

        def hit_test(hwnd, msg, wparam, lparam):
            # We don't have a border, so don't worry about
            # border cursor checks.
            # pt = wintypes.POINT()

            # x in low word, y in the high word
            # pt.x = wintypes.DWORD(lparam & 0xffff)
            # pt.y = wintypes.DWORD((lparam >> 16) & 0xffff)
            # windll.user32.ScreenToClient(hwnd, byref(pt))

            # rc = wintypes.RECT()
            # windll.user32.GetClientRect(hwnd, byref(rc))
            return HTCLIENT

        callback_map[WM_NCACTIVATE] = lambda hwnd, msg, wparam, lparam: 0
        callback_map[WM_NCCALCSIZE] = lambda hwnd, msg, wparam, lparam: lparam == 0 and 0 or False
        callback_map[WM_NCHITTEST] = hit_test

        hwnd = func_map['window__create_display_window'](class_name, title, message_handler, style_flags)
        # windll.dwmapi.DwmExtendFrameIntoClientArea(hwnd, byref(margins))

        return hwnd

    return window__create_borderless_window
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号