Python win32gui.MoveWindow() Examples

The following are code examples for showing how to use win32gui.MoveWindow(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: ironpython2   Author: IronLanguages   File: win32gui_dialog.py    Apache License 2.0 7 votes vote down vote up
def _DoSize(self, cx, cy, repaint = 1):
        # right-justify the textbox.
        ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SEARCHTEXT)
        l, t, r, b = win32gui.GetWindowRect(ctrl)
        l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
        r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
        win32gui.MoveWindow(ctrl, l, t, cx-l-5, b-t, repaint)
        # The button.
        ctrl = win32gui.GetDlgItem(self.hwnd, IDC_BUTTON_DISPLAY)
        l, t, r, b = win32gui.GetWindowRect(ctrl)
        l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
        r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
        list_y = b + 10
        w = r - l
        win32gui.MoveWindow(ctrl, cx - 5 - w, t, w, b-t, repaint)

        # The list control
        win32gui.MoveWindow(self.hwndList, 0, list_y, cx, cy-list_y, repaint)
        # The last column of the list control.
        new_width = cx - win32gui.SendMessage(self.hwndList, commctrl.LVM_GETCOLUMNWIDTH, 0)
        win32gui.SendMessage(self.hwndList, commctrl.LVM_SETCOLUMNWIDTH, 1, new_width) 
Example 2
Project: open-recipe   Author: dspray95   File: win32gui_dialog.py    The Unlicense 6 votes vote down vote up
def _DoSize(self, cx, cy, repaint = 1):
        # right-justify the textbox.
        ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SEARCHTEXT)
        l, t, r, b = win32gui.GetWindowRect(ctrl)
        l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
        r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
        win32gui.MoveWindow(ctrl, l, t, cx-l-5, b-t, repaint)
        # The button.
        ctrl = win32gui.GetDlgItem(self.hwnd, IDC_BUTTON_DISPLAY)
        l, t, r, b = win32gui.GetWindowRect(ctrl)
        l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
        r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
        list_y = b + 10
        w = r - l
        win32gui.MoveWindow(ctrl, cx - 5 - w, t, w, b-t, repaint)

        # The list control
        win32gui.MoveWindow(self.hwndList, 0, list_y, cx, cy-list_y, repaint)
        # The last column of the list control.
        new_width = cx - win32gui.SendMessage(self.hwndList, commctrl.LVM_GETCOLUMNWIDTH, 0)
        win32gui.SendMessage(self.hwndList, commctrl.LVM_SETCOLUMNWIDTH, 1, new_width) 
Example 3
Project: pyty   Author: howardjohn   File: window_api.py    GNU General Public License v3.0 6 votes vote down vote up
def move_window(hwnd, rect, gap=0, border=True):
    """
    Moves window.

    Args:
        hwnd (int): The window handler.
        rect: Rect(x, y, w, h) of new location.
    Kwargs:
        gap (int): Number of pixels between each window.
        border (bool): Should invisible border should be accounted for.
    """
    BORDER_WIDTH = 7 if border else 0  # Windows 10 has an invisible 8px border
    x = int(rect.x) - BORDER_WIDTH + gap // 2
    y = int(rect.y) + gap // 2
    w = int(rect.w) + 2 * BORDER_WIDTH - gap
    h = int(rect.h) + BORDER_WIDTH - gap  # No hidden border on top
    wg.MoveWindow(hwnd, x, y, w, h, True) 
Example 4
Project: arkScript   Author: akbchris   File: win32gui_dialog.py    MIT License 6 votes vote down vote up
def _DoSize(self, cx, cy, repaint = 1):
        # right-justify the textbox.
        ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SEARCHTEXT)
        l, t, r, b = win32gui.GetWindowRect(ctrl)
        l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
        r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
        win32gui.MoveWindow(ctrl, l, t, cx-l-5, b-t, repaint)
        # The button.
        ctrl = win32gui.GetDlgItem(self.hwnd, IDC_BUTTON_DISPLAY)
        l, t, r, b = win32gui.GetWindowRect(ctrl)
        l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
        r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
        list_y = b + 10
        w = r - l
        win32gui.MoveWindow(ctrl, cx - 5 - w, t, w, b-t, repaint)

        # The list control
        win32gui.MoveWindow(self.hwndList, 0, list_y, cx, cy-list_y, repaint)
        # The last column of the list control.
        new_width = cx - win32gui.SendMessage(self.hwndList, commctrl.LVM_GETCOLUMNWIDTH, 0)
        win32gui.SendMessage(self.hwndList, commctrl.LVM_SETCOLUMNWIDTH, 1, new_width) 
Example 5
Project: eavatar-me   Author: eavatar   File: console.py    Apache License 2.0 6 votes vote down vote up
def _DoSize(self, cx, cy, repaint=1):
        # right-justify the textbox.
        # ctrl = win32gui.GetDlgItem(self.hwnd, IDC_JOB_NAME)
        # win32gui.SetWindowText(ctrl, self.job_name)
        # l, t, r, b = win32gui.GetWindowRect(ctrl)
        # l, t = win32gui.ScreenToClient(self.hwnd, (l, t))
        # r, b = win32gui.ScreenToClient(self.hwnd, (r, b))
        # win32gui.MoveWindow(ctrl, l, t, cx-l-5, b-t, repaint)

        ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SCRIPT)
        win32gui.SetFocus(ctrl)

        # The button.
        ctrl = win32gui.GetDlgItem(self.hwnd, IDC_BUTTON_SUBMIT)
        l, t, r, b = win32gui.GetWindowRect(ctrl)
        l, t = win32gui.ScreenToClient(self.hwnd, (l, t))
        r, b = win32gui.ScreenToClient(self.hwnd, (r, b))
        w = r - l
        win32gui.MoveWindow(ctrl, cx - 5 - w, t, w, b - t, repaint) 
Example 6
Project: eavatar-me   Author: eavatar   File: notice_dlg.py    Apache License 2.0 6 votes vote down vote up
def _DoSize(self, cx, cy, repaint=1):
        # right-justify the textbox.
        # ctrl = win32gui.GetDlgItem(self.hwnd, IDC_JOB_NAME)
        # win32gui.SetWindowText(ctrl, self.job_name)
        # l, t, r, b = win32gui.GetWindowRect(ctrl)
        # l, t = win32gui.ScreenToClient(self.hwnd, (l, t))
        # r, b = win32gui.ScreenToClient(self.hwnd, (r, b))
        # win32gui.MoveWindow(ctrl, l, t, cx-l-5, b-t, repaint)

        ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SCRIPT)
        win32gui.SetFocus(ctrl)

        # The button.
        ctrl = win32gui.GetDlgItem(self.hwnd, IDC_BUTTON_SUBMIT)
        l, t, r, b = win32gui.GetWindowRect(ctrl)
        l, t = win32gui.ScreenToClient(self.hwnd, (l, t))
        r, b = win32gui.ScreenToClient(self.hwnd, (r, b))
        w = r - l
        win32gui.MoveWindow(ctrl, cx - 5 - w, t, w, b-t, repaint) 
Example 7
Project: NGU-scripts   Author: kujan   File: window.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def shake() -> None:
        """Shake that Window"""
        for x in range(1000):
            win32gui.MoveWindow(Window.id, x, 0, 1000, 800, False)
        for y in range(1000):
            win32gui.MoveWindow(Window.id, 1000, y, 1000, 800, False)
        for x in reversed(range(1000)):
            win32gui.MoveWindow(Window.id, x, 1000, 1000, 800, False)
        for y in reversed(range(1000)):
            win32gui.MoveWindow(Window.id, 0, y, 1000, 800, False) 
Example 8
Project: Advanced-Action-Scheduler   Author: swprojects   File: windowmanager.py    GNU General Public License v2.0 5 votes vote down vote up
def MoveWindow(handle, x1, y1, w, h):

    if w is None:  # size not defined
        tmpX1, tmpY1, tmpX2, tmpY2 = win32gui.GetWindowRect(handle)
        w = tmpX2 - tmpX1
        h = tmpY2 - tmpY1

    win32gui.MoveWindow(handle, x1, y1, w, h, True) 
Example 9
Project: Advanced-Action-Scheduler   Author: swprojects   File: windowmanager.py    GNU General Public License v2.0 5 votes vote down vote up
def SetWindowSize(handle, w, h):
    x1, y1, _, _ = win32gui.GetWindowRect(handle)
    win32gui.MoveWindow(handle, x1, y1, w, h, True) 
Example 10
Project: ironpython2   Author: IronLanguages   File: shell_view.py    Apache License 2.0 5 votes vote down vote up
def OnSize(self, hwnd, msg, wparam, lparam):
        #print "OnSize", self.hwnd_child, win32api.LOWORD(lparam), win32api.HIWORD(lparam)
        if self.hwnd_child is not None:
            x = win32api.LOWORD(lparam)
            y = win32api.HIWORD(lparam)
            win32gui.MoveWindow(self.hwnd_child, 0, 0, x, y, False)

# This uses scintilla to display a filename, and optionally jump to a line
# number. 
Example 11
Project: ironpython2   Author: IronLanguages   File: shell_view.py    Apache License 2.0 5 votes vote down vote up
def OnSize(self, hwnd, msg, wparam, lparam):
        x = win32api.LOWORD(lparam)
        y = win32api.HIWORD(lparam)
        win32gui.MoveWindow(self.hwnd, 0, 0, x, y, False) 
Example 12
Project: ironpython2   Author: IronLanguages   File: win32gui_dialog.py    Apache License 2.0 5 votes vote down vote up
def OnInitDialog(self, hwnd, msg, wparam, lparam):
        self.hwnd = hwnd
        # centre the dialog
        desktop = win32gui.GetDesktopWindow()
        l,t,r,b = win32gui.GetWindowRect(self.hwnd)
        dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
        centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)//2, (dt_b-dt_t)//2) )
        win32gui.MoveWindow(hwnd, centre_x-(r//2), centre_y-(b//2), r-l, b-t, 0)
        self._SetupList()
        l,t,r,b = win32gui.GetClientRect(self.hwnd)
        self._DoSize(r-l,b-t, 1) 
Example 13
Project: open-recipe   Author: dspray95   File: shell_view.py    The Unlicense 5 votes vote down vote up
def OnSize(self, hwnd, msg, wparam, lparam):
        #print "OnSize", self.hwnd_child, win32api.LOWORD(lparam), win32api.HIWORD(lparam)
        if self.hwnd_child is not None:
            x = win32api.LOWORD(lparam)
            y = win32api.HIWORD(lparam)
            win32gui.MoveWindow(self.hwnd_child, 0, 0, x, y, False)

# This uses scintilla to display a filename, and optionally jump to a line
# number. 
Example 14
Project: open-recipe   Author: dspray95   File: shell_view.py    The Unlicense 5 votes vote down vote up
def OnSize(self, hwnd, msg, wparam, lparam):
        x = win32api.LOWORD(lparam)
        y = win32api.HIWORD(lparam)
        win32gui.MoveWindow(self.hwnd, 0, 0, x, y, False) 
Example 15
Project: open-recipe   Author: dspray95   File: win32gui_dialog.py    The Unlicense 5 votes vote down vote up
def OnInitDialog(self, hwnd, msg, wparam, lparam):
        self.hwnd = hwnd
        # centre the dialog
        desktop = win32gui.GetDesktopWindow()
        l,t,r,b = win32gui.GetWindowRect(self.hwnd)
        dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
        centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)//2, (dt_b-dt_t)//2) )
        win32gui.MoveWindow(hwnd, centre_x-(r//2), centre_y-(b//2), r-l, b-t, 0)
        self._SetupList()
        l,t,r,b = win32gui.GetClientRect(self.hwnd)
        self._DoSize(r-l,b-t, 1) 
Example 16
Project: winmine_ai   Author: bnfour   File: winmine_util.py    MIT License 5 votes vote down vote up
def resize_window(handle):
    win32gui.MoveWindow(handle, 0, 0, 100, 100, True)


# brings window to top 
Example 17
Project: dex   Author: Innixma   File: open_hexagon_emulator.py    MIT License 5 votes vote down vote up
def get_application_focus(self):
        # hwnd = win32gui.FindWindow(None, self.application)
        # shell = win32com.client.Dispatch("WScript.Shell")
        self.shell.SendKeys('%')
        win32gui.SetForegroundWindow(self.game_window)
        win32gui.MoveWindow(self.game_window, self.window_offset[0], self.window_offset[1], self.window_size[0], self.window_size[1], True)

        if self.game_window == 0:
            print('ERROR: Can\'t find window')
            exit(1)

        return 
Example 18
Project: arkScript   Author: akbchris   File: shell_view.py    MIT License 5 votes vote down vote up
def OnSize(self, hwnd, msg, wparam, lparam):
        #print "OnSize", self.hwnd_child, win32api.LOWORD(lparam), win32api.HIWORD(lparam)
        if self.hwnd_child is not None:
            x = win32api.LOWORD(lparam)
            y = win32api.HIWORD(lparam)
            win32gui.MoveWindow(self.hwnd_child, 0, 0, x, y, False)

# This uses scintilla to display a filename, and optionally jump to a line
# number. 
Example 19
Project: arkScript   Author: akbchris   File: shell_view.py    MIT License 5 votes vote down vote up
def OnSize(self, hwnd, msg, wparam, lparam):
        x = win32api.LOWORD(lparam)
        y = win32api.HIWORD(lparam)
        win32gui.MoveWindow(self.hwnd, 0, 0, x, y, False) 
Example 20
Project: arkScript   Author: akbchris   File: win32gui_dialog.py    MIT License 5 votes vote down vote up
def OnInitDialog(self, hwnd, msg, wparam, lparam):
        self.hwnd = hwnd
        # centre the dialog
        desktop = win32gui.GetDesktopWindow()
        l,t,r,b = win32gui.GetWindowRect(self.hwnd)
        dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
        centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)//2, (dt_b-dt_t)//2) )
        win32gui.MoveWindow(hwnd, centre_x-(r//2), centre_y-(b//2), r-l, b-t, 0)
        self._SetupList()
        l,t,r,b = win32gui.GetClientRect(self.hwnd)
        self._DoSize(r-l,b-t, 1) 
Example 21
Project: Companions   Author: Jackeriss   File: shell_view.py    MIT License 5 votes vote down vote up
def OnSize(self, hwnd, msg, wparam, lparam):
        #print "OnSize", self.hwnd_child, win32api.LOWORD(lparam), win32api.HIWORD(lparam)
        if self.hwnd_child is not None:
            x = win32api.LOWORD(lparam)
            y = win32api.HIWORD(lparam)
            win32gui.MoveWindow(self.hwnd_child, 0, 0, x, y, False)

# This uses scintilla to display a filename, and optionally jump to a line
# number. 
Example 22
Project: Companions   Author: Jackeriss   File: shell_view.py    MIT License 5 votes vote down vote up
def OnSize(self, hwnd, msg, wparam, lparam):
        x = win32api.LOWORD(lparam)
        y = win32api.HIWORD(lparam)
        win32gui.MoveWindow(self.hwnd, 0, 0, x, y, False) 
Example 23
Project: eavatar-me   Author: eavatar   File: console.py    Apache License 2.0 5 votes vote down vote up
def OnInitDialog(self, hwnd, msg, wparam, lparam):
        self.hwnd = hwnd
        # centre the dialog
        desktop = win32gui.GetDesktopWindow()
        l, t, r, b = win32gui.GetWindowRect(self.hwnd)
        dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
        centre_x, centre_y = win32gui.ClientToScreen(desktop, (
            (dt_r - dt_l) // 2, (dt_b - dt_t) // 2))
        win32gui.MoveWindow(hwnd, centre_x - (r // 2), centre_y - (b // 2),
                            r - l, b - t, 0)
        # self._SetupList()
        l, t, r, b = win32gui.GetClientRect(self.hwnd)
        self._DoSize(r - l, b - t, 1) 
Example 24
Project: eavatar-me   Author: eavatar   File: notice_dlg.py    Apache License 2.0 5 votes vote down vote up
def OnInitDialog(self, hwnd, msg, wparam, lparam):
        self.hwnd = hwnd
        # centre the dialog
        desktop = win32gui.GetDesktopWindow()
        l, t, r, b = win32gui.GetWindowRect(self.hwnd)
        dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
        centre_x, centre_y = win32gui.ClientToScreen(desktop,
                                                     ((dt_r - dt_l)//2,
                                                      (dt_b - dt_t)//2))
        win32gui.MoveWindow(hwnd, centre_x-(r//2),
                            centre_y-(b//2), r-l, b-t, 0)
        # self._SetupList()
        l, t, r, b = win32gui.GetClientRect(self.hwnd)
        self._DoSize(r-l, b-t, 1) 
Example 25
Project: eavatar-me   Author: eavatar   File: simpledialog.py    Apache License 2.0 5 votes vote down vote up
def OnInitDialog(self, hwnd, msg, wparam, lparam):
        self.hwnd = hwnd
        # centre the dialog
        desktop = win32gui.GetDesktopWindow()
        l, t, r, b = win32gui.GetWindowRect(self.hwnd)
        dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
        centre_x, centre_y = win32gui.ClientToScreen(
            desktop,
            ((dt_r-dt_l)//2, (dt_b-dt_t)//2))
        win32gui.MoveWindow(hwnd, centre_x-(r//2),
                            centre_y-(b//2), r-l, b-t, 0)
        # self._SetupList()
        l, t, r, b = win32gui.GetClientRect(self.hwnd)
        self._DoSize(r-l, b-t, 1) 
Example 26
Project: ironpython2   Author: IronLanguages   File: shell_view.py    Apache License 2.0 4 votes vote down vote up
def _CreateChildWindow(self, prev):
        # Creates the list view window.
        assert self.hwnd_child is None, "already have a window"
        assert self.cur_foldersettings is not None, "no settings"
        style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_BORDER | \
                commctrl.LVS_SHAREIMAGELISTS | commctrl.LVS_EDITLABELS

        view_mode, view_flags = self.cur_foldersettings
        if view_mode==shellcon.FVM_ICON:
            style |= commctrl.LVS_ICON | commctrl.LVS_AUTOARRANGE
        elif view_mode==shellcon.FVM_SMALLICON:
            style |= commctrl.LVS_SMALLICON | commctrl.LVS_AUTOARRANGE
        elif view_mode==shellcon.FVM_LIST:
            style |= commctrl.LVS_LIST | commctrl.LVS_AUTOARRANGE
        elif view_mode==shellcon.FVM_DETAILS:
            style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE
        else:
            # XP 'thumbnails' etc
            view_mode = shellcon.FVM_DETAILS
            # Default to 'report'
            style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE

        for f_flag, l_flag in [
            (shellcon.FWF_SINGLESEL,        commctrl.LVS_SINGLESEL),
            (shellcon.FWF_ALIGNLEFT,        commctrl.LVS_ALIGNLEFT),
            (shellcon.FWF_SHOWSELALWAYS,    commctrl.LVS_SHOWSELALWAYS),
                              ]:
            if view_flags & f_flag:
                style |= l_flag

        self.hwnd_child = win32gui.CreateWindowEx(
                              win32con.WS_EX_CLIENTEDGE,
                              "SysListView32", None, style,
                              0, 0, 0, 0,
                              self.hwnd, 1000, 0, None)

        cr = win32gui.GetClientRect(self.hwnd)
        win32gui.MoveWindow(self.hwnd_child,
                            0, 0, cr[2]-cr[0], cr[3]-cr[1],
                            True)

        # Setup the columns for the view.
        lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_LEFT,
                                                   subItem=1,
                                                   text='Name',
                                                   cx=300)
        win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
                             0, lvc)

        lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_RIGHT,
                                                   subItem=1,
                                                   text='Exists',
                                                   cx=50)
        win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
                             1, lvc)
        # and fill it with the content
        self.Refresh() 
Example 27
Project: open-recipe   Author: dspray95   File: shell_view.py    The Unlicense 4 votes vote down vote up
def _CreateChildWindow(self, prev):
        # Creates the list view window.
        assert self.hwnd_child is None, "already have a window"
        assert self.cur_foldersettings is not None, "no settings"
        style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_BORDER | \
                commctrl.LVS_SHAREIMAGELISTS | commctrl.LVS_EDITLABELS

        view_mode, view_flags = self.cur_foldersettings
        if view_mode==shellcon.FVM_ICON:
            style |= commctrl.LVS_ICON | commctrl.LVS_AUTOARRANGE
        elif view_mode==shellcon.FVM_SMALLICON:
            style |= commctrl.LVS_SMALLICON | commctrl.LVS_AUTOARRANGE
        elif view_mode==shellcon.FVM_LIST:
            style |= commctrl.LVS_LIST | commctrl.LVS_AUTOARRANGE
        elif view_mode==shellcon.FVM_DETAILS:
            style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE
        else:
            # XP 'thumbnails' etc
            view_mode = shellcon.FVM_DETAILS
            # Default to 'report'
            style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE

        for f_flag, l_flag in [
            (shellcon.FWF_SINGLESEL,        commctrl.LVS_SINGLESEL),
            (shellcon.FWF_ALIGNLEFT,        commctrl.LVS_ALIGNLEFT),
            (shellcon.FWF_SHOWSELALWAYS,    commctrl.LVS_SHOWSELALWAYS),
                              ]:
            if view_flags & f_flag:
                style |= l_flag

        self.hwnd_child = win32gui.CreateWindowEx(
                              win32con.WS_EX_CLIENTEDGE,
                              "SysListView32", None, style,
                              0, 0, 0, 0,
                              self.hwnd, 1000, 0, None)

        cr = win32gui.GetClientRect(self.hwnd)
        win32gui.MoveWindow(self.hwnd_child,
                            0, 0, cr[2]-cr[0], cr[3]-cr[1],
                            True)

        # Setup the columns for the view.
        lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_LEFT,
                                                   subItem=1,
                                                   text='Name',
                                                   cx=300)
        win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
                             0, lvc)

        lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_RIGHT,
                                                   subItem=1,
                                                   text='Exists',
                                                   cx=50)
        win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
                             1, lvc)
        # and fill it with the content
        self.Refresh() 
Example 28
Project: arkScript   Author: akbchris   File: shell_view.py    MIT License 4 votes vote down vote up
def _CreateChildWindow(self, prev):
        # Creates the list view window.
        assert self.hwnd_child is None, "already have a window"
        assert self.cur_foldersettings is not None, "no settings"
        style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_BORDER | \
                commctrl.LVS_SHAREIMAGELISTS | commctrl.LVS_EDITLABELS

        view_mode, view_flags = self.cur_foldersettings
        if view_mode==shellcon.FVM_ICON:
            style |= commctrl.LVS_ICON | commctrl.LVS_AUTOARRANGE
        elif view_mode==shellcon.FVM_SMALLICON:
            style |= commctrl.LVS_SMALLICON | commctrl.LVS_AUTOARRANGE
        elif view_mode==shellcon.FVM_LIST:
            style |= commctrl.LVS_LIST | commctrl.LVS_AUTOARRANGE
        elif view_mode==shellcon.FVM_DETAILS:
            style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE
        else:
            # XP 'thumbnails' etc
            view_mode = shellcon.FVM_DETAILS
            # Default to 'report'
            style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE

        for f_flag, l_flag in [
            (shellcon.FWF_SINGLESEL,        commctrl.LVS_SINGLESEL),
            (shellcon.FWF_ALIGNLEFT,        commctrl.LVS_ALIGNLEFT),
            (shellcon.FWF_SHOWSELALWAYS,    commctrl.LVS_SHOWSELALWAYS),
                              ]:
            if view_flags & f_flag:
                style |= l_flag

        self.hwnd_child = win32gui.CreateWindowEx(
                              win32con.WS_EX_CLIENTEDGE,
                              "SysListView32", None, style,
                              0, 0, 0, 0,
                              self.hwnd, 1000, 0, None)

        cr = win32gui.GetClientRect(self.hwnd)
        win32gui.MoveWindow(self.hwnd_child,
                            0, 0, cr[2]-cr[0], cr[3]-cr[1],
                            True)

        # Setup the columns for the view.
        lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_LEFT,
                                                   subItem=1,
                                                   text='Name',
                                                   cx=300)
        win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
                             0, lvc)

        lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_RIGHT,
                                                   subItem=1,
                                                   text='Exists',
                                                   cx=50)
        win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
                             1, lvc)
        # and fill it with the content
        self.Refresh() 
Example 29
Project: Companions   Author: Jackeriss   File: shell_view.py    MIT License 4 votes vote down vote up
def _CreateChildWindow(self, prev):
        # Creates the list view window.
        assert self.hwnd_child is None, "already have a window"
        assert self.cur_foldersettings is not None, "no settings"
        style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_BORDER | \
                commctrl.LVS_SHAREIMAGELISTS | commctrl.LVS_EDITLABELS

        view_mode, view_flags = self.cur_foldersettings
        if view_mode==shellcon.FVM_ICON:
            style |= commctrl.LVS_ICON | commctrl.LVS_AUTOARRANGE
        elif view_mode==shellcon.FVM_SMALLICON:
            style |= commctrl.LVS_SMALLICON | commctrl.LVS_AUTOARRANGE
        elif view_mode==shellcon.FVM_LIST:
            style |= commctrl.LVS_LIST | commctrl.LVS_AUTOARRANGE
        elif view_mode==shellcon.FVM_DETAILS:
            style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE
        else:
            # XP 'thumbnails' etc
            view_mode = shellcon.FVM_DETAILS
            # Default to 'report'
            style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE

        for f_flag, l_flag in [
            (shellcon.FWF_SINGLESEL,        commctrl.LVS_SINGLESEL),
            (shellcon.FWF_ALIGNLEFT,        commctrl.LVS_ALIGNLEFT),
            (shellcon.FWF_SHOWSELALWAYS,    commctrl.LVS_SHOWSELALWAYS),
                              ]:
            if view_flags & f_flag:
                style |= l_flag

        self.hwnd_child = win32gui.CreateWindowEx(
                              win32con.WS_EX_CLIENTEDGE,
                              "SysListView32", None, style,
                              0, 0, 0, 0,
                              self.hwnd, 1000, 0, None)

        cr = win32gui.GetClientRect(self.hwnd)
        win32gui.MoveWindow(self.hwnd_child,
                            0, 0, cr[2]-cr[0], cr[3]-cr[1],
                            True)

        # Setup the columns for the view.
        lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_LEFT,
                                                   subItem=1,
                                                   text='Name',
                                                   cx=300)
        win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
                             0, lvc)

        lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_RIGHT,
                                                   subItem=1,
                                                   text='Exists',
                                                   cx=50)
        win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
                             1, lvc)
        # and fill it with the content
        self.Refresh()