home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / Wintalk / VC / DataEdit.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  2.0 KB  |  74 lines

  1. /*+==========================================================================
  2.   File:      DataEdit.cpp
  3.  
  4.   Summary:   Extends the default functionality of the WFC Edit control
  5.              by providing two extra methods.
  6.  
  7.   Classes:   DataEdit
  8.  
  9.   Functions: Append, TruncateOneCharFromEnd
  10.              
  11. ----------------------------------------------------------------------------
  12.   This file is part of the Microsoft NGWS Samples.
  13.  
  14.   Copyright (C) 1998-1999 Microsoft Corporation.  All rights reserved.
  15. ==========================================================================+*/
  16.  
  17. #using <mscorlib.dll>
  18. #using <System.DLL>
  19. #using <System.Drawing.DLL>
  20. #using <System.Drawing.Design.DLL>
  21. #using <System.WinForms.DLL>
  22. #using <Microsoft.Win32.Interop.dll>
  23.  
  24. using namespace System;
  25. using namespace System::WinForms;
  26. using namespace System::WinForms::Design;
  27.  
  28. #include "DataEdit.h"
  29.  
  30. /*****************************************************************************
  31.  Function :    Append
  32.  
  33.  Abstract:     Appends a string to the end of the edit control
  34.             
  35.  Input Parameters: str(String)
  36.  
  37.  Returns: void
  38. ******************************************************************************/
  39.     void DataEdit::Append(String *str)
  40.     {
  41.         int len = Text->Length;
  42.         SelectionStart = len;
  43.         SelectionLength = len;
  44.         SelectedText = str;
  45.     }
  46.  
  47. /*****************************************************************************
  48.  Function:     TruncateOneCharFromEnd
  49.  
  50.  Abstract:     Truncates one character from the end of the text in the edit
  51.                control.
  52.             
  53.  Input Parameters: (none)
  54.  
  55.  Returns: void
  56. ******************************************************************************/
  57.     void DataEdit::TruncateOneCharFromEnd()
  58.     {
  59.         int len = Text->Length;
  60.         if (len == 1) {
  61.             Text = S"";
  62.         } else if (len > 1) {
  63.             SelectionStart = len-1;
  64.             SelectionLength = len;
  65.             String *s = SelectedText;
  66.             if (s->Equals(S"\n")) {
  67.                 SelectionStart = len-2;
  68.                 SelectionLength = len;
  69.             }
  70.             SelectedText = S"";
  71.         }
  72.     }
  73.         
  74.