Hi,

I currently try to add a matplotlib backend based on the Gecko engine 
(XPCOM, plugin), PIL and pywin.


I don't use a child window and draw directly in the plugin window.

My flicker problem of the plugin area is resolved.
But when I resize the window (when the dimensions are increased) the 
buttons of the parent window flicker (the window which embeds the plugin).

I think, there is something to do with the WM_NCPAINT event (fired when 
the window is enlarged) but I don't see what.

Can anybody help me ?

thanks a lot.

Cyril.


The wndproc procedure is :

  def wndProc(self, hwnd, message, wParam, lParam):
    if message == win32con.WM_PAINT:
      print "Hello PAINT"
      fig = self.canvas.figure
      dpival = fig.dpi.get()
      winch = self.width/dpival
      hinch = self.height/dpival
      fig.set_figsize_inches(winch, hinch)
      hdc, paintStruct = win32gui.BeginPaint(hwnd)
      self.canvas.draw()
      image = Image.frombuffer('RGBA', self.canvas.get_width_height(), 
self.canvas.buffer_rgba(0,0))
      image = image.transpose(Image.FLIP_TOP_BOTTOM)
      dib = ImageWin.Dib(image)
      z = ImageWin.HWND(hwnd)
      dib.expose(z)

      win32gui.EndPaint(hwnd, paintStruct)
      return 0

    elif message == win32con.WM_MOUSEACTIVATE:
      print "Hello MOUSEACTIVATE"
      return 1

    elif message == win32con.WM_NCPAINT:
      print "Hello NCPAINT"
      return win32gui.DefWindowProc(hwnd, message, wParam, lParam)

    elif message == win32con.WM_ERASEBKGND:
      print "Hello ERASEBKGND"
      return 1

    elif message == win32con.WM_SIZE:
      print "Hello SIZE"
      return 0

    elif message == win32con.WM_LBUTTONDOWN:
      print "Hello LBUTTONDOWN "
      self.start = win32gui.ScreenToClient(hwnd, win32gui.GetCursorPos())
      return 1

    elif message == win32con.WM_MOUSEMOVE:
      print "Hello MOVE "
      win = win32ui.CreateWindowFromHandle(hwnd)
      win32gui.UpdateWindow(hwnd)

      if self.start:
        image = Image.frombuffer('RGBA', self.canvas.get_width_height(), 
self.canvas.buffer_rgba(0,0))
        image = image.transpose(Image.FLIP_TOP_BOTTOM)
        dib = ImageWin.Dib(image)
        z = ImageWin.HWND(hwnd)
        dib.expose(z)
        self.current = win32gui.ScreenToClient(hwnd, 
win32gui.GetCursorPos())
        dc = win.GetDC()
        dc.MoveTo(self.start[0], self.start[1])
        dc.LineTo(self.current[0], self.start[1])
        dc.LineTo(self.current[0], self.current[1])
        dc.LineTo(self.start[0], self.current[1])
        dc.LineTo(self.start[0], self.start[1])
      return 1

    elif message == win32con.WM_LBUTTONUP:
      print "Hello LBUTTONDOWN "
      self.start = None
      self.current = None
      image = Image.frombuffer('RGBA', self.canvas.get_width_height(), 
self.canvas.buffer_rgba(0,0))
      image = image.transpose(Image.FLIP_TOP_BOTTOM)
      dib = ImageWin.Dib(image)
      z = ImageWin.HWND(hwnd)
      dib.expose(z)
      return 1

    else:
      print "Hello ELSE"
      return win32gui.DefWindowProc(hwnd, message, wParam, lParam)


_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to