Python win32gui.SetWindowLong() Examples

The following are 9 code examples of win32gui.SetWindowLong(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module win32gui , or try the search function .
Example #1
Source File: win32gui_demo.py    From ironpython2 with 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 #2
Source File: win32gui_demo.py    From ironpython2 with 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 #3
Source File: recipe-334779.py    From code with MIT License 6 votes vote down vote up
def __init__(self, gtk_window):

        self._window = gtk_window
        self._hwnd = gtk_window.window.handle

        self._message_map = {}

        # Windows transparency is only supported windows2000 and above.
        if sys.getwindowsversion()[0] <= 4:
            self.alpha = None
        else:
            self.alpha = 100
            self._transparency = False

        self.notify_icon = None            

        # Sublass the window and inject a WNDPROC to process messages.
        self._oldwndproc = win32gui.SetWindowLong(self._hwnd, GWL_WNDPROC,
                                                  self._wndproc)

        gtk_window.connect('unrealize', self.remove) 
Example #4
Source File: recipe-334779.py    From code with MIT License 6 votes vote down vote up
def set_alpha(self, alpha=100, colorkey=0, mask=False):
        """ Sets the transparency of the window. """
        if self.alpha != None:
            if not self._transparency:
                style = win32gui.GetWindowLong(self._hwnd, GWL_EXSTYLE)
                if (style & WS_EX_LAYERED) != WS_EX_LAYERED:
                    style = style | WS_EX_LAYERED
                    win32gui.SetWindowLong(self._hwnd, GWL_EXSTYLE, style)
                self._transparency = True

            if mask and colorkey:
                flags = LWA_COLORKEY
            else:
                flags = LWA_ALPHA
                if colorkey:
                    flags = flags | LWA_COLORKEY

            win_alpha = int(float(alpha)/100*255)
            winxpgui.SetLayeredWindowAttributes(self._hwnd, colorkey,
                                                win_alpha, flags)
            self.alpha = int(alpha) 
Example #5
Source File: NativeEvent.py    From PyQt with 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 #6
Source File: shell_view.py    From ironpython2 with 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 #7
Source File: main.py    From MouseTracks with GNU General Public License v3.0 5 votes vote down vote up
def hide(self, new=True):
        """Hide a window from the task bar.
        Kept the old way just to be on the safe side.
        """
        if new:
            win32gui.ShowWindow(self.hwnd, False)
        else:
            self.minimise()
            win32gui.ShowWindow(self.hwnd, win32con.SW_HIDE)
            win32gui.SetWindowLong(self.hwnd, win32con.GWL_EXSTYLE,
                                   win32gui.GetWindowLong(self.hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_TOOLWINDOW)
            win32gui.ShowWindow(self.hwnd, win32con.SW_SHOW) 
Example #8
Source File: EmbedWindow.py    From PyQt with 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 #9
Source File: shell_view.py    From Email_My_PC with 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