Python win32gui.SetWindowLong() Examples

The following are code examples for showing how to use win32gui.SetWindowLong(). 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: flight-lab   Author: google   File: windows.py    Apache License 2.0 6 votes vote down vote up
def set_style(self, add=None, remove=None):
    """Changes window style.

    Args:
      add: styles to add.
      remove: styles to remove.
    Returns:
      Self.
    """
    hwnd = self.get_hwnd()
    styles = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
    if add:
      styles |= add
    if remove:
      styles &= ~remove
    win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, styles)
    return self 
Example 2
Project: ironpython2   Author: IronLanguages   File: win32gui_demo.py    Apache License 2.0 6 votes vote down vote up
def OnPaint_1(hwnd, msg, wp, lp):
    dc, ps=win32gui.BeginPaint(hwnd)
    win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED)
    br=win32gui.CreateSolidBrush(win32api.RGB(255,0,0))
    win32gui.SelectObject(dc, br)
    angle=win32gui.GetWindowLong(hwnd, win32con.GWL_USERDATA)
    win32gui.SetWindowLong(hwnd, win32con.GWL_USERDATA, angle+2)
    r_angle=angle*(math.pi/180)
    win32gui.SetWorldTransform(dc,
        {'M11':math.cos(r_angle), 'M12':math.sin(r_angle), 'M21':math.sin(r_angle)*-1, 'M22':math.cos(r_angle),'Dx':250,'Dy':250})
    win32gui.MoveToEx(dc,250,250)
    win32gui.BeginPath(dc)
    win32gui.Pie(dc, 10, 70, 200, 200, 350, 350, 75, 10)
    win32gui.Chord(dc, 200, 200, 850, 0, 350, 350, 75, 10)
    win32gui.LineTo(dc, 300,300)
    win32gui.LineTo(dc, 100, 20)
    win32gui.LineTo(dc, 20, 100)
    win32gui.LineTo(dc, 400, 0)
    win32gui.LineTo(dc, 0, 400)
    win32gui.EndPath(dc)
    win32gui.StrokeAndFillPath(dc)
    win32gui.EndPaint(hwnd, ps)
    return 0 
Example 3
Project: ironpython2   Author: IronLanguages   File: win32gui_demo.py    Apache License 2.0 6 votes vote down vote up
def TestGradientFill():
    wc = win32gui.WNDCLASS()
    wc.lpszClassName = 'test_win32gui_2'
    wc.style =  win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.hbrBackground = win32con.COLOR_WINDOW+1
    wc.lpfnWndProc=wndproc_2
    class_atom=win32gui.RegisterClass(wc)       
    hwnd = win32gui.CreateWindowEx(0, class_atom,'Kaleidoscope',
        win32con.WS_CAPTION|win32con.WS_VISIBLE|win32con.WS_THICKFRAME|win32con.WS_SYSMENU,
        100,100,900,900, 0, 0, 0, None)
    s=win32gui.GetWindowLong(hwnd,win32con.GWL_EXSTYLE)
    win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, s|win32con.WS_EX_LAYERED)
    win32gui.SetLayeredWindowAttributes(hwnd, 0, 175, win32con.LWA_ALPHA)
    for x in xrange(30):
        win32gui.InvalidateRect(hwnd,None,True)
        win32gui.PumpWaitingMessages()
        time.sleep(0.3)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(class_atom,None) 
Example 4
Project: open-recipe   Author: dspray95   File: win32gui_demo.py    The Unlicense 6 votes vote down vote up
def OnPaint_1(hwnd, msg, wp, lp):
    dc, ps=win32gui.BeginPaint(hwnd)
    win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED)
    br=win32gui.CreateSolidBrush(win32api.RGB(255,0,0))
    win32gui.SelectObject(dc, br)
    angle=win32gui.GetWindowLong(hwnd, win32con.GWL_USERDATA)
    win32gui.SetWindowLong(hwnd, win32con.GWL_USERDATA, angle+2)
    r_angle=angle*(math.pi/180)
    win32gui.SetWorldTransform(dc,
        {'M11':math.cos(r_angle), 'M12':math.sin(r_angle), 'M21':math.sin(r_angle)*-1, 'M22':math.cos(r_angle),'Dx':250,'Dy':250})
    win32gui.MoveToEx(dc,250,250)
    win32gui.BeginPath(dc)
    win32gui.Pie(dc, 10, 70, 200, 200, 350, 350, 75, 10)
    win32gui.Chord(dc, 200, 200, 850, 0, 350, 350, 75, 10)
    win32gui.LineTo(dc, 300,300)
    win32gui.LineTo(dc, 100, 20)
    win32gui.LineTo(dc, 20, 100)
    win32gui.LineTo(dc, 400, 0)
    win32gui.LineTo(dc, 0, 400)
    win32gui.EndPath(dc)
    win32gui.StrokeAndFillPath(dc)
    win32gui.EndPaint(hwnd, ps)
    return 0 
Example 5
Project: open-recipe   Author: dspray95   File: win32gui_demo.py    The Unlicense 6 votes vote down vote up
def TestGradientFill():
    wc = win32gui.WNDCLASS()
    wc.lpszClassName = 'test_win32gui_2'
    wc.style =  win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.hbrBackground = win32con.COLOR_WINDOW+1
    wc.lpfnWndProc=wndproc_2
    class_atom=win32gui.RegisterClass(wc)       
    hwnd = win32gui.CreateWindowEx(0, class_atom,'Kaleidoscope',
        win32con.WS_CAPTION|win32con.WS_VISIBLE|win32con.WS_THICKFRAME|win32con.WS_SYSMENU,
        100,100,900,900, 0, 0, 0, None)
    s=win32gui.GetWindowLong(hwnd,win32con.GWL_EXSTYLE)
    win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, s|win32con.WS_EX_LAYERED)
    win32gui.SetLayeredWindowAttributes(hwnd, 0, 175, win32con.LWA_ALPHA)
    for x in range(30):
        win32gui.InvalidateRect(hwnd,None,True)
        win32gui.PumpWaitingMessages()
        time.sleep(0.3)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(class_atom,None) 
Example 6
Project: poe-timeless-jewel-multitool   Author: johanahlqvist   File: drawer.py    Apache License 2.0 6 votes vote down vote up
def _draw_worker(draw_list):
    print('nd')
    pygame.init()
    screen = pygame.display.set_mode((2560, 1440), pygame.NOFRAME)
    fuchsia = (255, 0, 128)  # Transparency color
    # Set window transparency color
    hwnd = pygame.display.get_wm_info()["window"]
    win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE,
                           win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_LAYERED)
    win32gui.SetLayeredWindowAttributes(hwnd, win32api.RGB(*fuchsia), 0, win32con.LWA_COLORKEY)
    done = False
    while not done:
        print('nd')
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                done = True
        for rect_key in draw_list.keys():
            rect = draw_list[rect_key]
            screen.fill(fuchsia)  # Transparent background
            pygame.draw.rect(screen, rect.color, pygame.Rect(rect.x, rect.y, rect.side_length, rect.thickness))
            pygame.draw.rect(screen, rect.color, pygame.Rect(rect.x, rect.y, rect.thickness, rect.side_length))
            pygame.draw.rect(screen, rect.color, pygame.Rect(rect.x + rect.side_length, rect.y, rect.thickness, rect.side_length))
            pygame.draw.rect(screen, rect.color, pygame.Rect(rect.x, rect.y + rect.side_length, rect.side_length + rect.thickness, rect.thickness))
        pygame.display.update()
# 
Example 7
Project: arkScript   Author: akbchris   File: win32gui_demo.py    MIT License 6 votes vote down vote up
def OnPaint_1(hwnd, msg, wp, lp):
    dc, ps=win32gui.BeginPaint(hwnd)
    win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED)
    br=win32gui.CreateSolidBrush(win32api.RGB(255,0,0))
    win32gui.SelectObject(dc, br)
    angle=win32gui.GetWindowLong(hwnd, win32con.GWL_USERDATA)
    win32gui.SetWindowLong(hwnd, win32con.GWL_USERDATA, angle+2)
    r_angle=angle*(math.pi/180)
    win32gui.SetWorldTransform(dc,
        {'M11':math.cos(r_angle), 'M12':math.sin(r_angle), 'M21':math.sin(r_angle)*-1, 'M22':math.cos(r_angle),'Dx':250,'Dy':250})
    win32gui.MoveToEx(dc,250,250)
    win32gui.BeginPath(dc)
    win32gui.Pie(dc, 10, 70, 200, 200, 350, 350, 75, 10)
    win32gui.Chord(dc, 200, 200, 850, 0, 350, 350, 75, 10)
    win32gui.LineTo(dc, 300,300)
    win32gui.LineTo(dc, 100, 20)
    win32gui.LineTo(dc, 20, 100)
    win32gui.LineTo(dc, 400, 0)
    win32gui.LineTo(dc, 0, 400)
    win32gui.EndPath(dc)
    win32gui.StrokeAndFillPath(dc)
    win32gui.EndPaint(hwnd, ps)
    return 0 
Example 8
Project: arkScript   Author: akbchris   File: win32gui_demo.py    MIT License 6 votes vote down vote up
def TestGradientFill():
    wc = win32gui.WNDCLASS()
    wc.lpszClassName = 'test_win32gui_2'
    wc.style =  win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.hbrBackground = win32con.COLOR_WINDOW+1
    wc.lpfnWndProc=wndproc_2
    class_atom=win32gui.RegisterClass(wc)       
    hwnd = win32gui.CreateWindowEx(0, class_atom,'Kaleidoscope',
        win32con.WS_CAPTION|win32con.WS_VISIBLE|win32con.WS_THICKFRAME|win32con.WS_SYSMENU,
        100,100,900,900, 0, 0, 0, None)
    s=win32gui.GetWindowLong(hwnd,win32con.GWL_EXSTYLE)
    win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, s|win32con.WS_EX_LAYERED)
    win32gui.SetLayeredWindowAttributes(hwnd, 0, 175, win32con.LWA_ALPHA)
    for x in range(30):
        win32gui.InvalidateRect(hwnd,None,True)
        win32gui.PumpWaitingMessages()
        time.sleep(0.3)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(class_atom,None) 
Example 9
Project: PyQt   Author: PyQt5   File: NativeEvent.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)
        # 主屏幕的可用大小(去掉任务栏)
        self._rect = QApplication.instance().desktop().availableGeometry(self)
        self.resize(800, 600)
        self.setWindowFlags(Qt.Window
                            | Qt.FramelessWindowHint
                            | Qt.WindowSystemMenuHint
                            | Qt.WindowMinimizeButtonHint
                            | Qt.WindowMaximizeButtonHint
                            | Qt.WindowCloseButtonHint)
        # 增加薄边框
        style = win32gui.GetWindowLong(int(self.winId()), win32con.GWL_STYLE)
        win32gui.SetWindowLong(
            int(self.winId()), win32con.GWL_STYLE, style | win32con.WS_THICKFRAME)

        if QtWin.isCompositionEnabled():
            # 加上 Aero 边框阴影
            QtWin.extendFrameIntoClientArea(self, -1, -1, -1, -1)
        else:
            QtWin.resetExtendedFrame(self) 
Example 10
Project: ironpython2   Author: IronLanguages   File: shell_view.py    Apache License 2.0 5 votes vote down vote up
def CreateViewWindow(self, prev, settings, browser, rect):
        print "ScintillaShellView.CreateViewWindow", prev, settings, browser, rect
        # Make sure scintilla.dll is loaded.  If not, find it on sys.path
        # (which it generally is for Pythonwin)
        try:
            win32api.GetModuleHandle("Scintilla.dll")
        except win32api.error:
            for p in sys.path:
                fname = os.path.join(p, "Scintilla.dll")
                if not os.path.isfile(fname):
                    fname = os.path.join(p, "Build", "Scintilla.dll")
                if os.path.isfile(fname):
                    win32api.LoadLibrary(fname)
                    break
            else:
                raise RuntimeError("Can't find scintilla!")

        style = win32con.WS_CHILD | win32con.WS_VSCROLL | \
                win32con.WS_HSCROLL | win32con.WS_CLIPCHILDREN | \
                win32con.WS_VISIBLE
        self.hwnd = win32gui.CreateWindow("Scintilla", "Scintilla", style,
                              rect[0], rect[1], rect[2]-rect[0], rect[3]-rect[1], 
                              self.hwnd_parent, 1000, 0, None)

        message_map = {
                win32con.WM_SIZE: self.OnSize,
        }
#        win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map)

        file_data = file(self.filename, "U").read()

        self._SetupLexer()
        self._SendSci(scintillacon.SCI_ADDTEXT, len(file_data), file_data)
        if self.lineno != None:
            self._SendSci(scintillacon.SCI_GOTOLINE, self.lineno)
        print "Scintilla's hwnd is", self.hwnd 
Example 11
Project: open-recipe   Author: dspray95   File: shell_view.py    The Unlicense 5 votes vote down vote up
def _CreateMainWindow(self, prev, settings, browser, rect):
        # Creates a parent window that hosts the view window.  This window
        # gets the control notifications etc sent from the child.
        style = win32con.WS_CHILD | win32con.WS_VISIBLE #
        wclass_name = "ShellViewDemo_DefView"
        # Register the Window class.
        wc = win32gui.WNDCLASS()
        wc.hInstance = win32gui.dllhandle
        wc.lpszClassName = wclass_name
        wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW
        try:
            win32gui.RegisterClass(wc)
        except win32gui.error as details:
            # Should only happen when this module is reloaded
            if details[0] != winerror.ERROR_CLASS_ALREADY_EXISTS:
                raise

        message_map = {
                win32con.WM_DESTROY: self.OnDestroy,
                win32con.WM_COMMAND: self.OnCommand,
                win32con.WM_NOTIFY:  self.OnNotify,
                win32con.WM_CONTEXTMENU: self.OnContextMenu,
                win32con.WM_SIZE: self.OnSize,
        }

        self.hwnd = win32gui.CreateWindow( wclass_name, "", style, \
                rect[0], rect[1], rect[2]-rect[0], rect[3]-rect[1],
                self.hwnd_parent, 0, win32gui.dllhandle, None)
        win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map)
        print("View 's hwnd is", self.hwnd)
        return self.hwnd 
Example 12
Project: open-recipe   Author: dspray95   File: shell_view.py    The Unlicense 5 votes vote down vote up
def CreateViewWindow(self, prev, settings, browser, rect):
        print("ScintillaShellView.CreateViewWindow", prev, settings, browser, rect)
        # Make sure scintilla.dll is loaded.  If not, find it on sys.path
        # (which it generally is for Pythonwin)
        try:
            win32api.GetModuleHandle("Scintilla.dll")
        except win32api.error:
            for p in sys.path:
                fname = os.path.join(p, "Scintilla.dll")
                if not os.path.isfile(fname):
                    fname = os.path.join(p, "Build", "Scintilla.dll")
                if os.path.isfile(fname):
                    win32api.LoadLibrary(fname)
                    break
            else:
                raise RuntimeError("Can't find scintilla!")

        style = win32con.WS_CHILD | win32con.WS_VSCROLL | \
                win32con.WS_HSCROLL | win32con.WS_CLIPCHILDREN | \
                win32con.WS_VISIBLE
        self.hwnd = win32gui.CreateWindow("Scintilla", "Scintilla", style,
                              rect[0], rect[1], rect[2]-rect[0], rect[3]-rect[1], 
                              self.hwnd_parent, 1000, 0, None)

        message_map = {
                win32con.WM_SIZE: self.OnSize,
        }
#        win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map)

        file_data = file(self.filename, "U").read()

        self._SetupLexer()
        self._SendSci(scintillacon.SCI_ADDTEXT, len(file_data), file_data)
        if self.lineno != None:
            self._SendSci(scintillacon.SCI_GOTOLINE, self.lineno)
        print("Scintilla's hwnd is", self.hwnd) 
Example 13
Project: system_tray   Author: timeyyy   File: taskbar.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def add_to_taskbar(hw):
    try:
        #~ win32gui.ShowWindow(hw, SW_HIDE)
        win32gui.SetWindowLong(hw, GWL_EXSTYLE,WS_EX_APPWINDOW)
        #~ win32gui.SetWindowLong(hw, GWL_EXSTYLE,win32gui.GetWindowLong(hw, GWL_EXSTYLE)| WS_EX_TOOLWINDOW);
        #~ win32gui.ShowWindow(hw, SW_SHOW);
    except win32gui.error:
        print("Error while hiding the window")
        return None	

#~ @staticmethod 
Example 14
Project: system_tray   Author: timeyyy   File: taskbar.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def hide_from_taskbar(hw):
    try:
        win32gui.ShowWindow(hw, SW_HIDE)
        #~ win32gui.SetWindowLong(hw, GWL_EXSTYLE,win32gui.GetWindowLong(hw, GWL_EXSTYLE)| WS_EX_TOOLWINDOW)
        win32gui.SetWindowLong(hw, GWL_EXSTYLE, WS_EX_TOOLWINDOW)
        #~ win32gui.ShowWindow(hw, SW_SHOW)
    except win32gui.error:
        print("Error while hiding the window")
        return None

#~ @staticmethod 
Example 15
Project: system_tray   Author: timeyyy   File: taskbar.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def do2(root):
		hwnd=int(root.wm_frame(),0)
		style=win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)	#remove style from bar
		style &=  ~win32con.WS_EX_APPWINDOW
		print(style)
		win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, style)
		style = win32gui.GetWindowLong(hwnd,  win32con.GWL_EXSTYLE)	#add correct style
		style |= win32con.WS_EX_TOOLWINDOW
		win32gui.SetWindowLong(hwnd,win32con.GWL_EXSTYLE, style) 
Example 16
Project: system_tray   Author: timeyyy   File: win_taskbar.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def add_to_taskbar(hw):
    try:
        #~ win32gui.ShowWindow(hw, SW_HIDE)
        win32gui.SetWindowLong(hw, GWL_EXSTYLE,WS_EX_APPWINDOW)
        #~ win32gui.SetWindowLong(hw, GWL_EXSTYLE,win32gui.GetWindowLong(hw, GWL_EXSTYLE)| WS_EX_TOOLWINDOW);
        #~ win32gui.ShowWindow(hw, SW_SHOW);
    except win32gui.error:
        print("Error while hiding the window")
        return None	

#~ @staticmethod 
Example 17
Project: system_tray   Author: timeyyy   File: win_taskbar.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def hide_from_taskbar(hw):
    try:
        win32gui.ShowWindow(hw, SW_HIDE)
        #~ win32gui.SetWindowLong(hw, GWL_EXSTYLE,win32gui.GetWindowLong(hw, GWL_EXSTYLE)| WS_EX_TOOLWINDOW)
        win32gui.SetWindowLong(hw, GWL_EXSTYLE, WS_EX_TOOLWINDOW)
        #~ win32gui.ShowWindow(hw, SW_SHOW)
    except win32gui.error:
        print("Error while hiding the window")
        return None

#~ @staticmethod 
Example 18
Project: pyty   Author: howardjohn   File: window_api.py    GNU General Public License v3.0 5 votes vote down vote up
def add_titlebar(hwnd):
    """
    Sets the window style to include a titlebar if it doesn't have one.

    Args:
        hwnd (int): The window handler.
    """
    style = wg.GetWindowLong(hwnd, wc.GWL_STYLE)
    style |= wc.WS_CAPTION
    wg.SetWindowLong(hwnd, wc.GWL_STYLE, style)
    maximize(hwnd)
    restore(hwnd) 
Example 19
Project: pyty   Author: howardjohn   File: window_api.py    GNU General Public License v3.0 5 votes vote down vote up
def remove_titlebar(hwnd):
    """
    Sets window style to caption (no titlebar).

    Args:
        hwnd (int): The window handler.
    """
    style = wg.GetWindowLong(hwnd, wc.GWL_STYLE)
    style &= ~wc.WS_CAPTION
    wg.SetWindowLong(hwnd, wc.GWL_STYLE, style)
    maximize(hwnd)
    restore(hwnd) 
Example 20
Project: arkScript   Author: akbchris   File: shell_view.py    MIT License 5 votes vote down vote up
def _CreateMainWindow(self, prev, settings, browser, rect):
        # Creates a parent window that hosts the view window.  This window
        # gets the control notifications etc sent from the child.
        style = win32con.WS_CHILD | win32con.WS_VISIBLE #
        wclass_name = "ShellViewDemo_DefView"
        # Register the Window class.
        wc = win32gui.WNDCLASS()
        wc.hInstance = win32gui.dllhandle
        wc.lpszClassName = wclass_name
        wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW
        try:
            win32gui.RegisterClass(wc)
        except win32gui.error as details:
            # Should only happen when this module is reloaded
            if details[0] != winerror.ERROR_CLASS_ALREADY_EXISTS:
                raise

        message_map = {
                win32con.WM_DESTROY: self.OnDestroy,
                win32con.WM_COMMAND: self.OnCommand,
                win32con.WM_NOTIFY:  self.OnNotify,
                win32con.WM_CONTEXTMENU: self.OnContextMenu,
                win32con.WM_SIZE: self.OnSize,
        }

        self.hwnd = win32gui.CreateWindow( wclass_name, "", style, \
                rect[0], rect[1], rect[2]-rect[0], rect[3]-rect[1],
                self.hwnd_parent, 0, win32gui.dllhandle, None)
        win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map)
        print("View 's hwnd is", self.hwnd)
        return self.hwnd 
Example 21
Project: arkScript   Author: akbchris   File: shell_view.py    MIT License 5 votes vote down vote up
def CreateViewWindow(self, prev, settings, browser, rect):
        print("ScintillaShellView.CreateViewWindow", prev, settings, browser, rect)
        # Make sure scintilla.dll is loaded.  If not, find it on sys.path
        # (which it generally is for Pythonwin)
        try:
            win32api.GetModuleHandle("Scintilla.dll")
        except win32api.error:
            for p in sys.path:
                fname = os.path.join(p, "Scintilla.dll")
                if not os.path.isfile(fname):
                    fname = os.path.join(p, "Build", "Scintilla.dll")
                if os.path.isfile(fname):
                    win32api.LoadLibrary(fname)
                    break
            else:
                raise RuntimeError("Can't find scintilla!")

        style = win32con.WS_CHILD | win32con.WS_VSCROLL | \
                win32con.WS_HSCROLL | win32con.WS_CLIPCHILDREN | \
                win32con.WS_VISIBLE
        self.hwnd = win32gui.CreateWindow("Scintilla", "Scintilla", style,
                              rect[0], rect[1], rect[2]-rect[0], rect[3]-rect[1], 
                              self.hwnd_parent, 1000, 0, None)

        message_map = {
                win32con.WM_SIZE: self.OnSize,
        }
#        win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map)

        file_data = file(self.filename, "U").read()

        self._SetupLexer()
        self._SendSci(scintillacon.SCI_ADDTEXT, len(file_data), file_data)
        if self.lineno != None:
            self._SendSci(scintillacon.SCI_GOTOLINE, self.lineno)
        print("Scintilla's hwnd is", self.hwnd) 
Example 22
Project: Companions   Author: Jackeriss   File: shell_view.py    MIT License 5 votes vote down vote up
def CreateViewWindow(self, prev, settings, browser, rect):
        print "ScintillaShellView.CreateViewWindow", prev, settings, browser, rect
        # Make sure scintilla.dll is loaded.  If not, find it on sys.path
        # (which it generally is for Pythonwin)
        try:
            win32api.GetModuleHandle("Scintilla.dll")
        except win32api.error:
            for p in sys.path:
                fname = os.path.join(p, "Scintilla.dll")
                if not os.path.isfile(fname):
                    fname = os.path.join(p, "Build", "Scintilla.dll")
                if os.path.isfile(fname):
                    win32api.LoadLibrary(fname)
                    break
            else:
                raise RuntimeError("Can't find scintilla!")

        style = win32con.WS_CHILD | win32con.WS_VSCROLL | \
                win32con.WS_HSCROLL | win32con.WS_CLIPCHILDREN | \
                win32con.WS_VISIBLE
        self.hwnd = win32gui.CreateWindow("Scintilla", "Scintilla", style,
                              rect[0], rect[1], rect[2]-rect[0], rect[3]-rect[1], 
                              self.hwnd_parent, 1000, 0, None)

        message_map = {
                win32con.WM_SIZE: self.OnSize,
        }
#        win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map)

        file_data = file(self.filename, "U").read()

        self._SetupLexer()
        self._SendSci(scintillacon.SCI_ADDTEXT, len(file_data), file_data)
        if self.lineno != None:
            self._SendSci(scintillacon.SCI_GOTOLINE, self.lineno)
        print "Scintilla's hwnd is", self.hwnd 
Example 23
Project: PyQt   Author: PyQt5   File: EmbedWindow.py    GNU General Public License v3.0 5 votes vote down vote up
def restore(self):
        """归还窗口"""
        # 有bug,归还后窗口没有了WS_VISIBLE样式,不可见
        widget = self.layout().itemAt(3).widget()
        print('restore', widget.hwnd, widget.style, widget.exstyle)
        win32gui.SetParent(widget.hwnd, widget.phwnd)  # 让它返回它的父窗口
        win32gui.SetWindowLong(
            widget.hwnd, win32con.GWL_STYLE, widget.style | win32con.WS_VISIBLE)  # 恢复样式
        win32gui.SetWindowLong(
            widget.hwnd, win32con.GWL_EXSTYLE, widget.exstyle)  # 恢复样式
        win32gui.ShowWindow(
            widget.hwnd, win32con.SW_SHOW)  # 显示窗口
        widget.close()
        self.layout().removeWidget(widget)  # 从布局中移出
        widget.deleteLater() 
Example 24
Project: pywmtouchhook   Author: alisdt   File: touchhook.py    The Unlicense 5 votes vote down vote up
def __init__(self, hwnd):
        # Set the WndProc to our function
        self.oldWndProc = win32gui.SetWindowLong(hwnd, win32con.GWL_WNDPROC, self.wndProc)

        # TWF_FINETOUCH and TWF_WANTPALM: see
        # https://msdn.microsoft.com/en-us/library/windows/desktop/dd317326%28v=vs.85%29.aspx
        rtn = RegisterTouchWindow(hwnd, 0x00000001 | 0x00000002)
        assert rtn, "Couldn't register for touch messages"