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

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. /* --------------------------------------------------------
  4.   INPUTDIA.CPP
  5.   Defines type TInputDialog.  This defines the basic
  6.   behavior of all input dialogs.
  7.   -------------------------------------------------------- */
  8.  
  9. #include "inputdia.h"
  10. #include <string.h>
  11.  
  12. TInputDialog::TInputDialog(PTWindowsObject AParent, LPSTR ATitle,
  13.                            LPSTR APrompt, LPSTR ABuffer, WORD ABufferSize,
  14.                            PTModule AModule)
  15.              : TDialog(AParent, SD_INPUTDIALOG, AModule)
  16. {
  17.   SetCaption(ATitle);
  18.   Prompt = _fstrdup(APrompt ? APrompt : "");
  19.   Buffer = ABuffer;
  20.   BufferSize = ABufferSize;
  21. }
  22.  
  23. /* Sets and gets the values of the items (controls) of the input
  24.    dialog. */
  25. void TInputDialog::TransferData(WORD Direction)
  26. {
  27.   if ( Direction == TF_SETDATA )
  28.   {
  29.     SetDlgItemText(HWindow, ID_PROMPT, Prompt);
  30.     SetDlgItemText(HWindow, ID_INPUT, Buffer);
  31.   }
  32.   else
  33.     if ( Direction == TF_GETDATA )
  34.       GetDlgItemText(HWindow, ID_INPUT, Buffer, BufferSize);
  35. }
  36.  
  37. /* Sets the values of the items (controls) of the input dialog. */
  38. void TInputDialog::SetupWindow()
  39. {
  40.   TDialog::SetupWindow();
  41.   SendDlgItemMessage(HWindow, ID_INPUT, EM_LIMITTEXT,
  42.                        BufferSize - 1, 0);
  43. }
  44.  
  45. /* Reads an instance of TInputDialog from the passed ipstream. */
  46. void *TInputDialog::read(ipstream& is)
  47. {
  48.   TDialog::read(is);
  49.  
  50.   Prompt = is.freadString();
  51.   return this;
  52. }
  53.  
  54. /* Writes the TInputDialog to the passed opstream. */
  55. void TInputDialog::write(opstream& os)
  56. {
  57.   TDialog::write(os);
  58.  
  59.   os.fwriteString(Prompt);
  60. }
  61.  
  62. TStreamable *TInputDialog::build()
  63. {
  64.   return new TInputDialog(streamableInit);
  65. }
  66.  
  67. TStreamableClass RegInputDialog("TInputDialog", TInputDialog::build,
  68.                           __DELTA(TInputDialog));
  69.