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

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. /* --------------------------------------------------------
  4.   GROUPBOX.CPP
  5.   Defines type TGroupBox.  This defines the basic behavior
  6.   for all group boxes.
  7.   -------------------------------------------------------- */
  8.  
  9. #include "groupbox.h"
  10.  
  11. /* Constructor for a TGroupBox object.  Initializes its data fields
  12.    using supplied parameters and default values.  By default, the
  13.    parent window is notified when the state of the group box's selection
  14.    boxes has changed.  */
  15. TGroupBox::TGroupBox(PTWindowsObject AParent, int AnId, LPSTR AText,
  16.                      int X, int Y, int W, int H, PTModule AModule)
  17.             : TControl(AParent, AnId, AText, X, Y, W, H, AModule)
  18. {
  19.   NotifyParent = TRUE;
  20.   Attr.Style = (Attr.Style | BS_GROUPBOX) & ~WS_TABSTOP;
  21. }
  22.  
  23. /* Constructor for a TGroupBox to be associated with a MS-Windows interface
  24.    element created by MS-Windows from a resource definition. Initializes
  25.    its data fields using supplied parameters.  By default, the
  26.    parent window is notified when the state of the group box's selection
  27.    boxes has changed.Disables transfer of state data for the TGroupBox. */
  28. TGroupBox::TGroupBox(PTWindowsObject AParent, int ResourceId, PTModule AModule)
  29.                      : TControl(AParent, ResourceId, AModule)
  30. {
  31.   NotifyParent = TRUE;
  32.   DisableTransfer();
  33. }
  34.  
  35. /* Notifies parent that the selection in the associated groupbox has
  36.   changed.  This method is called by TCheckBoxes grouped in the groupbox
  37.   when their state changes. */
  38. void TGroupBox::SelectionChanged(int ControlId)
  39. {
  40.   if ( NotifyParent )
  41.     SendMessage(Parent->HWindow, WM_COMMAND, Attr.Id,
  42.       MAKELONG(HWindow, ControlId));
  43. }
  44.  
  45. /* Reads an instance of TGroupBox from the passed ipstream. */
  46. void *TGroupBox::read(ipstream& is)
  47. {
  48.   TWindow::read(is);
  49.   is >> NotifyParent;
  50.   return this;
  51. }
  52.  
  53. /* Writes the TGroupBox to the passed opstream. */
  54. void TGroupBox::write(opstream& os)
  55. {
  56.   TWindow::write(os);
  57.   os << NotifyParent;
  58.   }
  59.  
  60. TStreamable *TGroupBox::build()
  61. {
  62.   return new TGroupBox(streamableInit);
  63. }
  64.  
  65. TStreamableClass RegGroupBox("TGroupBox", TGroupBox::build,
  66.                  __DELTA(TGroupBox));
  67.