|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionI have often found that user input edit boxes on a dialog require much more than the capabilities provided by the basic Another issue that arises is the need to alternately display a status or prompt type string in an edit box under conditions where no user input has yet been specified. And then finally under the conditions where there is some type of error associated with a user entered value it is desireable to display an alert type error message in the edit box as opposed to using the proverbial I have implemented an editing control to address these needs. The picture above shows this Application In Your ProjectTo be able to utilize this string edit control in your application requires four very easy steps:
#include "StringEdit.h" And then you locate the member variable declarations in this same header file in the part that is filled in by the ClassWizard. Locate the line for the CEdit control and change the type to From this : // Dialog Data //{{AFX_DATA(CStringEditDemoDlg) enum { IDD = IDD_STRINGEDITDEMO_DIALOG }; CEdit m_MyInputEdit; To this : // Dialog Data //{{AFX_DATA(CStringEditDemoDlg) enum { IDD = IDD_STRINGEDITDEMO_DIALOG }; CStringEdit m_MyInputEdit; Usage NotesThe default constructor will configure the Some style attributes of the edit control can be set in the dialog design tool. Feel free to utilize any of the text alignment and framing options. The InterfaceThe interface to the class is provided through the use of the following member functions: void SetFixedLen(BOOL bFixedLen) // set fixed length flag BOOL GetFixedLen(void) // read back the fixed length flag Fixed length mode for the control simply causes the string returned by the void SetMode(BOOL bMode) // sets edit/status mode BOOL GetMode(void) // reads back the mode flag The control mode is primarily controlled to be in Edit Mode when the mode flag is set void SetAlertActive(UINT nSeconds) // start active alert mode void SetAlertInactive(void) // End the alert mode The alert display mode, with the control in the red color is initiaited with the void SetMaxLength(int nMax) // method to set the maximum string length int GetMaxLength(void) // method to read back //the maximum string length The void SetLegal(LPCSTR lpszLegal) // sets the string of legal characters void GetLegal(CString& strLegal) // gets back the legal string The legal string is a set of characters in a string that specify the valid entry characters for the edit control. If this string is empty then any characters are accepted as input (subject to those specified in the Illegal string). void SetIllegal(LPCSTR lpszIllegal) // sets the string of illegal characters void GetIllegal(CString& strIllegal) // gets back the illlegal string The illegal string specifies those characters which are specifically disallowed in the edited string input. If this string is emppty then there are no illegal characters to look for. void SetStatus(LPCSTR lpszStatus) // set status string void GetStatus(CString& strStatus) // gets back the status string These load and retreive the text string that is displayed in the status mode. void SetAlert(LPCSTR lpszAlert) // set alert string void GetAlert(CString& strAlert) // gets back the alert string These load and retreive the text string that is displayed in the alert mode. void SetText(LPCSTR lpszText) // plug text into control void GetText(CString& strText) // take text out of control These are used to place edit mode text into and get it back from the control.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||