window.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # The MFCish window classes.
  2. from . import object
  3. import win32ui
  4. import win32con
  5. class Wnd(object.CmdTarget):
  6. def __init__(self, initobj=None):
  7. object.CmdTarget.__init__(self, initobj)
  8. if self._obj_: self._obj_.HookMessage(self.OnDestroy, win32con.WM_DESTROY)
  9. def OnDestroy(self, msg):
  10. pass
  11. # NOTE NOTE - This facility is currently disabled in Pythonwin!!!!!
  12. # Note - to process all messages for your window, add the following method
  13. # to a derived class. This code provides default message handling (ie, is
  14. # identical, except presumably in speed, as if the method did not exist at
  15. # all, so presumably will be modified to test for specific messages to be
  16. # useful!
  17. # def WindowProc(self, msg, wParam, lParam):
  18. # rc, lResult = self._obj_.OnWndMsg(msg, wParam, lParam)
  19. # if not rc: lResult = self._obj_.DefWindowProc(msg, wParam, lParam)
  20. # return lResult
  21. class FrameWnd(Wnd):
  22. def __init__(self, wnd):
  23. Wnd.__init__(self, wnd)
  24. class MDIChildWnd(FrameWnd):
  25. def __init__(self, wnd = None):
  26. if wnd is None:
  27. wnd=win32ui.CreateMDIChild()
  28. FrameWnd.__init__(self, wnd)
  29. def OnCreateClient(self, cp, context):
  30. if context is not None and context.template is not None:
  31. context.template.CreateView(self, context)
  32. class MDIFrameWnd(FrameWnd):
  33. def __init__(self, wnd = None):
  34. if wnd is None:
  35. wnd=win32ui.CreateMDIFrame()
  36. FrameWnd.__init__(self, wnd)