home *** CD-ROM | disk | FTP | other *** search
/ Windoware / WINDOWARE_1_6.iso / miscprog / actormdi / mdifilew.cls < prev    next >
Text File  |  1990-12-06  |  4KB  |  95 lines

  1. /* MDIFILEW.CLS - This class is a descendant of the
  2.   FileWindow class that can be used in an MDI
  3.   application. */!!
  4.  
  5. inherit(FileWindow, #MDIFileWindow, nil, 2, nil)!!
  6.  
  7. now(class(MDIFileWindow))!!
  8.  
  9. /* Return the default window style. */
  10. Def style(self)
  11. { ^WS_OVERLAPPEDWINDOW bitOr WS_VSCROLL bitOr WS_HSCROLL;
  12. }!!
  13.  
  14. now(MDIFileWindow)!!
  15.  
  16. /* This message is received whenever the focus changes to a new MDI child
  17.   window. The MDI client window is notified that that this window is
  18.   either being activated or deactivated.
  19.   NOTE: This message must be passed on to the default child procedure */
  20. Def WM_MDIACTIVATE(self, wP, lP)
  21. { if wP == 0
  22.   then deactivateMDIChild(parent, self);
  23.   else activateMDIChild(parent, self);
  24.   endif;
  25. }!!
  26.  
  27. /* Default for dialogs is to do nothing. Return 0
  28.   to let Windows do normal processing.
  29.   WARNING: Do not remove this method! May be redefined
  30.   in descendants if they register a private window
  31.   class with Windows for their dialogs. */
  32. Def defWndProc(self, msgNum, wP, lP)
  33. { ^Call DefMDIChildProc(getHWnd(self), msgNum, wP, lP);
  34. }!!
  35.  
  36. /* Destroy the MDI Child window by passing the WM_MDIDESTROY message
  37.   to the MDI Client window. */
  38. Def destroy(self)
  39. { Call SendMessage(getHWnd(parent), messageID(#WM_MDIDESTROY),
  40.     getHWnd(self), 0L);
  41. }!!
  42.  
  43. /* This message will be received whenever the window has been resized.
  44.   NOTE: This message must be passed on to the default child procedure */
  45. Def WM_SIZE(self, wP, lP)
  46. { WM_SIZE(self:ancestor, wP, lP);
  47.   execWindowProc(self, #WM_SIZE, wP, lP);
  48. }!!
  49.  
  50. /* Set up this windows default procedure so that it will execute the
  51.   DefMDIChildProc if the message is not handled by the Actor system.
  52.   For MDI child windows in Actor, WM_DESTROY and WM_NCDESTROY messages
  53.   are passed to the correct Def Proc this way, WM_SIZE and WM_COMMAND
  54.   are handled differently */
  55. Def execWindowProc(self, windMsg, wP, lP)
  56. { ^Call DefMDIChildProc(getHWnd(self), messageID(windMsg), wP, lP);
  57. }!!
  58.  
  59. /* Create an MDI child window according to certain specifications.  par is
  60.   the parent of this child.  It should be set to the Frame window
  61.   that controls the MDI application.  wName is the text that will appear
  62.   in the caption bar.  rect is a rectangle representing the are in which
  63.   the window should be displayed.  style defines what attributes the
  64.   window should have.  It should be noted that, once the WM_MDICREATE
  65.   message is sent to the MDIClient, a window will be created AND shown. */
  66. Def create(self, par, wName, rect, style | wndCls, childStruct, childRect)
  67. { parent := par;
  68.   wndCls := wndClass(class(self));
  69.   if Call GetClassInfo(HInstance, asciiz(wndCls), new(Struct, 26)) = 0
  70.   then register(class(self));
  71.   endif;
  72.   caption := wName;
  73.   wStyle := style;
  74.   setCurWindow(System, self);
  75.   childStruct := new(Struct, 26);
  76.   putLong(childStruct, asciiz(wndCls), 0);
  77.   putLong(childStruct, asciiz(caption), 4);
  78.   putWord(childStruct, HInstance, 8);
  79.   childRect := rect cor
  80.     rect(CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT);
  81.   putWord(childStruct, left(childRect), 10);
  82.   putWord(childStruct, top(childRect), 12);
  83.   putWord(childStruct, width(childRect), 14);
  84.   putWord(childStruct, height(childRect), 16);
  85.   putLong(childStruct, style, 18);
  86.   putLong(childStruct, 0L, 22);
  87.   hWnd := Call SendMessage(getHWnd(parent),
  88.     messageID(#WM_MDICREATE), 0, childStruct);
  89.   if hWnd = 0
  90.   then alert(System, self, #windCreateError);
  91.   endif;
  92.   add(Windows, self);
  93.   setFileDlg(self, new(FileDialog, "*.*"));
  94. }!!
  95.