home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dho.zip / DHO / SRC / SOURCE.ZIP / edittext.cc < prev    next >
C/C++ Source or Header  |  1995-08-27  |  3KB  |  138 lines

  1. /****************************************/
  2. /*    Developer Helper Object Set       */
  3. /*  (C) 1994-95 Thomas E. Bednarz, Jr.  */
  4. /*     All rights reserved              */
  5. /***************************************/
  6.  
  7. /* $Id: edittext.cc 1.5 1995/08/13 03:21:12 teb Exp $ */
  8.  
  9.  
  10. #include"edittext.h"
  11. #include"window.h"
  12.  
  13. //-------------------------------------------------------------------
  14. //   TEditText
  15. TEditText::TEditText (TWinBase *parent, ULONG resource): TControl( parent, resource)
  16. {
  17.    hwndEntryField = NULL;
  18. }
  19.  
  20.  
  21. //-------------------------------------------------------------------
  22. //   TEditText
  23. TEditText::TEditText(TWinBase *parent, EditTxtAttr *etr, LONG xPos, LONG yPos,
  24.                   LONG xWidth, LONG yHeight): TControl(parent)
  25. {
  26.    ENTRYFDATA efd;
  27.    ULONG efStyle;
  28.  
  29.    efStyle = WS_VISIBLE;
  30.  
  31. //   if (etr->anyChar)
  32. //      efStyle |= ES_ANY;
  33.    if (etr->autoScroll)
  34.       efStyle |= ES_AUTOSCROLL;
  35.    if (etr->autoTab)
  36.       efStyle |= ES_AUTOTAB;
  37.    if (etr->lcr==left)
  38.       efStyle |= ES_LEFT;
  39.    else if (etr->lcr == center)
  40.       efStyle |= ES_CENTER;
  41.    else if (etr->lcr == right)
  42.       efStyle |= ES_RIGHT;
  43.    if (etr->margin)
  44.       efStyle |= ES_MARGIN;
  45.    if (etr->readOnly)
  46.       efStyle |= ES_READONLY;
  47.    if (etr->unreadable)
  48.       efStyle |= ES_UNREADABLE;
  49.  
  50.  
  51.    efd.cb = sizeof(ENTRYFDATA);
  52.    efd.cchEditLimit=etr->charLimit;
  53.    efd.ichMinSel = etr->minSel;
  54.    efd.ichMaxSel = etr->maxSel;
  55.  
  56.    hwndEntryField = WinCreateWindow(
  57.       parent->getHWND(),
  58.       WC_ENTRYFIELD,
  59.       etr->initialText,
  60.       efStyle,
  61.       xPos, yPos,
  62.       xWidth, yHeight,
  63.       parent->getHWND(),
  64.       HWND_TOP,
  65.       0,
  66.       &efd,
  67.       NULL);
  68. }
  69.  
  70. //-------------------------------------------------------------------
  71. //   ~TEditText
  72. TEditText::~TEditText()
  73. {
  74.  
  75.  
  76. }
  77.  
  78.  
  79. //-------------------------------------------------------------------
  80. //   TEditText
  81. const char *TEditText::getClassName()
  82. {
  83.    return "TEditText";
  84. }
  85.  
  86.  
  87. //-------------------------------------------------------------------
  88. //   getControlText
  89. void TEditText::getControlText(PCH buff, ULONG buf_len)
  90. {
  91.    if (hwndEntryField==(HWND)NULL)
  92.      WinQueryWindowText( WinWindowFromID( fParent->getHWND() , fResource) ,  buf_len, buff);
  93.    else
  94.       WinQueryWindowText(hwndEntryField, buf_len, buff);
  95.  
  96. }
  97.  
  98.  
  99. //-------------------------------------------------------------------
  100. //   setControlText
  101. void TEditText::setControlText(PCH text)
  102. {
  103.    if (hwndEntryField==(HWND)NULL)
  104.    {
  105.       HWND tmp;
  106.       tmp = WinWindowFromID( fParent->getHWND() , fResource);
  107.       WinSetWindowText(tmp, text);
  108.    }
  109.    else
  110.       WinSetWindowText(hwndEntryField, text);
  111.  
  112. }
  113.  
  114. //-------------------------------------------------------------------
  115. //   getTextLength
  116. LONG TEditText::getTextLength()
  117. {
  118.    long ret_val = 0;
  119.    if (hwndEntryField==(HWND)NULL)
  120.       ret_val =  WinQueryWindowTextLength(WinWindowFromID( fParent->getHWND() , fResource) );
  121.    else
  122.       ret_val =  WinQueryWindowTextLength(hwndEntryField);
  123.    return ret_val;
  124. }
  125.  
  126.  
  127. //-------------------------------------------------------------------
  128. //   showControl
  129. void TEditText::showControl()
  130. {
  131.    WinShowWindow(hwndEntryField, TRUE);
  132. }
  133.  
  134.  
  135.  
  136.  
  137.  
  138.