home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / OWL1.PAK / MDICLIEN.CPP < prev    next >
Text File  |  1995-08-29  |  2KB  |  75 lines

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. /* --------------------------------------------------------
  4.   MDICLIEN.CPP
  5.   Defines type TMDIClient.  This defines the basic behavior
  6.   of all MDI client windows.
  7.   -------------------------------------------------------- */
  8.  
  9. #include <alloc.h>
  10. #include "mdi.h"
  11.  
  12. /* Constructor for a TMDIClient.  Initializes its data fields using
  13.    passed parameter and default values. If this is not done, the default
  14.    size of the window would be zero.  Allocates space for the
  15.    CLIENTCREATESTRUCT on the heap and sets ClientAttr to point to this
  16.    space. */
  17. TMDIClient::TMDIClient(TMDIFrame *AParent, PTModule AModule)
  18.            : TWindow(AParent, NULL, AModule)
  19. {
  20.   Attr.Id = ID_MDICLIENT;
  21.   Attr.Style = WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP | WS_CLIPCHILDREN;
  22.   Attr.X = CW_USEDEFAULT;    Attr.Y = 0;
  23.   Attr.W = CW_USEDEFAULT;    Attr.H = 0;
  24.  
  25.   ClientAttr = (LPCLIENTCREATESTRUCT)farmalloc(sizeof(CLIENTCREATESTRUCT));
  26.   ClientAttr->hWindowMenu = (HMENU)0;
  27.   ClientAttr->idFirstChild = ID_FIRSTMDICHILD;
  28.   Attr.Param = (LPSTR)ClientAttr;
  29.   SetFlags(WB_MDICHILD, FALSE);
  30. }
  31.  
  32. /* Constructor for a TMDIClient which is being used in a DLL as an alias
  33.    for a non-OWL window */
  34. TMDIClient::TMDIClient(PTMDIFrame AParent, HWND AnHWindow, PTModule AModule)
  35.            : TWindow(AnHWindow, AModule)
  36. {
  37.   Parent = AParent;
  38.   SetFlags(WB_MDICHILD, FALSE);
  39. }
  40.  
  41. /* Frees the memory associated with ClientAttr. */
  42. TMDIClient::~TMDIClient()
  43. {
  44.     if (ClientAttr)
  45.         farfree(ClientAttr);
  46. }
  47.  
  48. /* Reads an instance of TMDIClient from the passed ipstream. */
  49. void *TMDIClient::read(ipstream& is)
  50. {
  51.   TWindow::read(is);
  52.   ClientAttr = (LPCLIENTCREATESTRUCT)farmalloc(sizeof(CLIENTCREATESTRUCT));
  53.  
  54.   WORD idFirstChild = ClientAttr->idFirstChild; // prevent compiler warning
  55.   is >> idFirstChild;
  56.   ClientAttr->hWindowMenu = (HMENU)0;
  57.   Attr.Param = (LPSTR)ClientAttr;
  58.   return this;
  59. }
  60.  
  61. /* Writes the TMDIClient to the passed opstream. */
  62. void TMDIClient::write(opstream& os)
  63. {
  64.   TWindow::write(os);
  65.   os << ClientAttr->idFirstChild;
  66. }
  67.  
  68. TStreamable *TMDIClient::build()
  69. {
  70.   return new TMDIClient(streamableInit);
  71. }
  72.  
  73. TStreamableClass RegMDIClient("TMDIClient", TMDIClient::build,
  74.                       __DELTA(TMDIClient));
  75.