home *** CD-ROM | disk | FTP | other *** search
- /*+==========================================================================
- File: DataEdit.cpp
-
- Summary: Extends the default functionality of the WFC Edit control
- by providing two extra methods.
-
- Classes: DataEdit
-
- Functions: Append, TruncateOneCharFromEnd
-
- ----------------------------------------------------------------------------
- This file is part of the Microsoft NGWS Samples.
-
- Copyright (C) 1998-1999 Microsoft Corporation. All rights reserved.
- ==========================================================================+*/
-
- #using <mscorlib.dll>
- #using <System.DLL>
- #using <System.Drawing.DLL>
- #using <System.Drawing.Design.DLL>
- #using <System.WinForms.DLL>
- #using <Microsoft.Win32.Interop.dll>
-
- using namespace System;
- using namespace System::WinForms;
- using namespace System::WinForms::Design;
-
- #include "DataEdit.h"
-
- /*****************************************************************************
- Function : Append
-
- Abstract: Appends a string to the end of the edit control
-
- Input Parameters: str(String)
-
- Returns: void
- ******************************************************************************/
- void DataEdit::Append(String *str)
- {
- int len = Text->Length;
- SelectionStart = len;
- SelectionLength = len;
- SelectedText = str;
- }
-
- /*****************************************************************************
- Function: TruncateOneCharFromEnd
-
- Abstract: Truncates one character from the end of the text in the edit
- control.
-
- Input Parameters: (none)
-
- Returns: void
- ******************************************************************************/
- void DataEdit::TruncateOneCharFromEnd()
- {
- int len = Text->Length;
- if (len == 1) {
- Text = S"";
- } else if (len > 1) {
- SelectionStart = len-1;
- SelectionLength = len;
- String *s = SelectedText;
- if (s->Equals(S"\n")) {
- SelectionStart = len-2;
- SelectionLength = len;
- }
- SelectedText = S"";
- }
- }
-
-