wxWidget capture !!!

Hi,

Why don’t work the following code for (wxGrid, wxSpinCtrl).

Please help me.

TIA.

#Boa:Frame:frmDesign

from wxPython.wx import *
from wxPython.grid import *
from win32api import SendMessage
import win32ui
import win32gui

WM_PAINT = 0xf
WM_PRINT = 0x317
PRF_CLIENT = 0x4
PRF_CHILDREN = 0x10
PRF_OWNED = 0x20

def create(parent):
return frmDesign(parent)

[wxID_FRMDESIGN, wxID_FRMDESIGNBTN, wxID_FRMDESIGNGRD, wxID_FRMDESIGNPIC,
wxID_FRMDESIGNSP, wxID_FRMDESIGNT12, wxID_FRMDESIGNTXT,
] = map(lambda _init_ctrls: wxNewId(), range(7))

class frmDesign(wxFrame):
def _init_ctrls(self, prnt):
# generated method, don’t edit
wxFrame.init(self, id=wxID_FRMDESIGN, name=u’frmDesign’,
parent=prnt, pos=wxPoint(351, 255), size=wxSize(634, 357),
style=wxDEFAULT_FRAME_STYLE, title=‘wxFrame1’)
self.SetClientSize(wxSize(626, 330))

    self.t12 = wxButton(id=wxID_FRMDESIGNT12, label='button1', name=u't12',
          parent=self, pos=wxPoint(8, 304), size=wxSize(96, 23), style=0)
    EVT_BUTTON(self.t12, wxID_FRMDESIGNT12, self.OnT12Button)

    self.pic = wxStaticBitmap(bitmap=wxNullBitmap, id=wxID_FRMDESIGNPIC,
          name=u'pic', parent=self, pos=wxPoint(16, 16), size=wxSize(168,
          144), style=0)

    self.grd = wxGrid(id=wxID_FRMDESIGNGRD, name=u'grd', parent=self,
          pos=wxPoint(416, 224), size=wxSize(200, 100), style=0)

    self.txt = wxTextCtrl(id=wxID_FRMDESIGNTXT, name=u'txt', parent=self,
          pos=wxPoint(440, 120), size=wxSize(160, 21), style=0,
          value='textCtrl1')

    self.btn = wxButton(id=wxID_FRMDESIGNBTN, label='button1', name=u'btn',
          parent=self, pos=wxPoint(440, 48), size=wxSize(75, 23), style=0)

    self.sp = wxSpinCtrl(id=wxID_FRMDESIGNSP, initial=0, max=100, min=0,
          name=u'sp', parent=self, pos=wxPoint(336, 80), size=wxSize(117,
          21), style=wxSP_ARROW_KEYS)

def __init__(self, parent):
    self._init_ctrls(parent)
    self.grd.CreateGrid(2,10)

def OnT12Button(self, event):       
    dc = wxClientDC(self.pic)
    SendMessage(self.btn.GetHandle(), WM_PAINT, 1, 0)
    SendMessage(self.btn.GetHandle(), WM_PRINT, dc.GetHDC(), 2+4+8+16+32)
    event.Skip()
···

Also, the function OnT12Button can be the next:

def OnT12Button(self, event):
dc = wxClientDC(self.pic)
SendMessage(self.sp.GetHandle(), WM_PAINT, dc.GetHDC(), 0)
SendMessage(self.sp.GetHandle(), WM_PRINT, dc.GetHDC(), PRF_CHILDREN|PRF_CLIENT|PRF_OWNED)

This program work only with the simple controls. Is there any way to enumerate the subcontrols who compose the main control?

···

----- Original Message -----

From:
Catalin Lungu

To: wxPython-users@lists.wxwidgets.org

Sent: Friday, January 07, 2005 2:05 PM

Subject: [wxPython-users] wxWidget capture !!!

Hi,

Why don’t work the following code for (wxGrid, wxSpinCtrl).

Please help me.

TIA.

#Boa:Frame:frmDesign

from wxPython.wx import *
from wxPython.grid import *
from win32api import SendMessage
import win32ui
import win32gui

WM_PAINT = 0xf
WM_PRINT = 0x317
PRF_CLIENT = 0x4
PRF_CHILDREN = 0x10
PRF_OWNED = 0x20

def create(parent):
return frmDesign(parent)

[wxID_FRMDESIGN, wxID_FRMDESIGNBTN, wxID_FRMDESIGNGRD, wxID_FRMDESIGNPIC,
wxID_FRMDESIGNSP, wxID_FRMDESIGNT12, wxID_FRMDESIGNTXT,
] = map(lambda _init_ctrls: wxNewId(), range(7))

class frmDesign(wxFrame):
def _init_ctrls(self, prnt):
# generated method, don’t edit
wxFrame.init(self, id=wxID_FRMDESIGN, name=u’frmDesign’,
parent=prnt, pos=wxPoint(351, 255), size=wxSize(634, 357),
style=wxDEFAULT_FRAME_STYLE, title=‘wxFrame1’)
self.SetClientSize(wxSize(626, 330))

      self.t12 = wxButton(id=wxID_FRMDESIGNT12, label='button1', name=u't12',
            parent=self, pos=wxPoint(8, 304), size=wxSize(96, 23), style=0)
      EVT_BUTTON(self.t12, wxID_FRMDESIGNT12, self.OnT12Button)
      self.pic = wxStaticBitmap(bitmap=wxNullBitmap, id=wxID_FRMDESIGNPIC,
            name=u'pic', parent=self, pos=wxPoint(16, 16), size=wxSize(168,
            144), style=0)
      self.grd = wxGrid(id=wxID_FRMDESIGNGRD, name=u'grd', parent=self,
            pos=wxPoint(416, 224), size=wxSize(200, 100), style=0)
      self.txt = wxTextCtrl(id=wxID_FRMDESIGNTXT, name=u'txt', parent=self,
            pos=wxPoint(440, 120), size=wxSize(160, 21), style=0,
            value='textCtrl1')
      self.btn = wxButton(id=wxID_FRMDESIGNBTN, label='button1', name=u'btn',
            parent=self, pos=wxPoint(440, 48), size=wxSize(75, 23), style=0)
      self.sp = wxSpinCtrl(id=wxID_FRMDESIGNSP, initial=0, max=100, min=0,
            name=u'sp', parent=self, pos=wxPoint(336, 80), size=wxSize(117,
            21), style=wxSP_ARROW_KEYS)
  def __init__(self, parent):
      self._init_ctrls(parent)
      self.grd.CreateGrid(2,10)
  def OnT12Button(self, event):       
      dc = wxClientDC(self.pic)
      SendMessage(self.btn.GetHandle(), WM_PAINT, 1, 0)
      SendMessage(self.btn.GetHandle(), WM_PRINT, dc.GetHDC(), 2+4+8+16+32)
      event.Skip()

Catalin Lungu wrote:

Also, the function OnT12Button can be the next:
def OnT12Button(self, event): dc = wxClientDC(self.pic)
        SendMessage(self.sp.GetHandle(), WM_PAINT, dc.GetHDC(), 0)
        SendMessage(self.sp.GetHandle(), WM_PRINT, dc.GetHDC(), PRF_CHILDREN|PRF_CLIENT|PRF_OWNED)

First of all, drawing to the client DC of the static bitmap is probably not what you want to do as it will just get overwritten by the control's own paint event. You probably want to select a bitmap into a memory DC and then after the bitmap has been filled use it to set the staticbitmap's bitmap.

Secondly, we just discussed WM_PRINT and etc. a few days ago, see the "Getting bitmap of a window" thread.

BTW, I realized yesterday that there have been some changes to wxMSW in the last few weeks that might make WM_PRINT work better than it did before, so I need to dust off my old exerimental code and try again. However even if it works I am still a bit reluctant to add it to wxWidgets unless it can also be made to work on the other platforms as well...

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!