[python-win32] PyCScrollView with no PyCDocument?

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Mar 10 06:49:26 CET 2009


Well, I think I've found a workaround. The following
hack seems to create something looking enough like
a PyCDocument to keep it happy while creating a
PyCView:

   dummy = win32ui.CreateRichEditView().GetDocument()

The result of this appears to be a PyCDocument that's
wrapping a null pointer. The fact that CreateView
accepts this suggests that there's really no need to
supply a document at creation time as far as the
C++ level is concerned. I can't find anything in the
MS docs to say there's any such need.

Looking at the source, you seem to be doing some
very strange things. In the PyCView constructor,
first you're hacking around protected members to
stuff the CDocument pointer into the m_pDocument
member. Then in CreateWindow you're taking it out
again and putting it in the CCreateContext.

I don't know why you can't just leave all this
alone at creation time, or at least make the document
argument optional, and expose the AddView method of
CDocument as a way of setting the document afterwards.

-- 
Greg


More information about the python-win32 mailing list