-
Dfinir Ou Supprimer L'tat De Lecture Seule카테고리 없음 2020. 1. 25. 03:57
Freshness_thresh Dfinit la priode de rafrachissement du contenu du service. Old Cette directive dfinit le nom court de la commande chaque fois qu'un changement de l'tat de l'hte est dtect (c--d chaque fois qu'il est hors service ou qu'il se rtablit).
CEdit Class. 37 minutes to read. Contributors. In this article Provides the functionality of a Windows edit control.
Syntax class CEdit: public CWnd Members Public Constructors Name Description Constructs a CEdit control object. Public Methods Name Description Determines whether an edit-control operation can be undone. Retrieves the line and character indexes for the character closest to a specified position. Deletes (clears) the current selection (if any) in the edit control.
Copies the current selection (if any) in the edit control to the Clipboard in CFTEXT format. Creates the Windows edit control and attaches it to the CEdit object. Deletes (cuts) the current selection (if any) in the edit control and copies the deleted text to the Clipboard in CFTEXT format. Resets (clears) the undo flag of an edit control. Sets the inclusion of soft line-break characters on or off within a multiple-line edit control. Retrieves the text that is displayed as the text cue, or tip, in an edit control when the control is empty and does not have focus. Determines the topmost visible line in an edit control.
Retrieves a handle to the memory that is currently allocated for a multiple-line edit control. Gets the indexes of the starting and ending characters in a range of text that is highlighted in the current edit control. Gets the maximum amount of text this CEdit can contain. Retrieves a line of text from an edit control. Retrieves the number of lines in a multiple-line edit control. Gets the left and right margins for this CEdit. Determines whether the contents of an edit control have been modified.
Retrieves the password character displayed in an edit control when the user enters text. Gets the formatting rectangle of an edit control. Gets the first and last character positions of the current selection in an edit control.
Hides any balloon tip associated with the current edit control. Limits the length of the text that the user can enter into an edit control. Retrieves the line number of the line that contains the specified character index.
Retrieves the character index of a line within a multiple-line edit control. Retrieves the length of a line in an edit control. Scrolls the text of a multiple-line edit control. Inserts the data from the Clipboard into the edit control at the current cursor position. Data is inserted only if the Clipboard contains data in CFTEXT format. Retrieves the coordinates of the upper-left corner of a specified character index. Replaces the current selection in an edit control with the specified text.
Sets the text that is displayed as the text cue, or tip, in an edit control when the control is empty and does not have focus. Sets the handle to the local memory that will be used by a multiple-line edit control. Highlights a range of text that is displayed in the current edit control.
Sets the maximum amount of text this CEdit can contain. Sets the left and right margins for this CEdit. Sets or clears the modification flag for an edit control. Sets or removes a password character displayed in an edit control when the user enters text. Sets the read-only state of an edit control.
Sets the formatting rectangle of a multiple-line edit control and updates the control. Sets the formatting rectangle of a multiple-line edit control without redrawing the control window. Selects a range of characters in an edit control.
Sets the tab stops in a multiple-line edit control. Displays a balloon tip that is associated with the current edit control. Reverses the last edit-control operation. Remarks An edit control is a rectangular child window in which the user can enter text. You can create an edit control either from a dialog template or directly in your code.
In both cases, first call the constructor CEdit to construct the CEdit object, then call the member function to create the Windows edit control and attach it to the CEdit object. Construction can be a one-step process in a class derived from CEdit. Write a constructor for the derived class and call Create from within the constructor.
CEdit inherits significant functionality from CWnd. To set and retrieve text from a CEdit object, use the CWnd member functions and, which set or get the entire contents of an edit control, even if it is a multiline control. Text lines in a multiline control are separated by ' r n' character sequences. Also, if an edit control is multiline, get and set part of the control's text by calling the CEdit member functions,.
If you want to handle Windows notification messages sent by an edit control to its parent (usually a class derived from CDialog), add a message-map entry and message-handler member function to the parent class for each message. Each message-map entry takes the following form: ON NOTIFICATION ( id, memberFxn ) where id specifies the child window ID of the edit control sending the notification, and memberFxn is the name of the parent member function you have written to handle the notification. The parent's function prototype is as follows: afxmsg void memberFxn ( ); Following is a list of potential message-map entries and a description of the cases in which they would be sent to the parent:. ONENCHANGE The user has taken an action that may have altered text in an edit control. Unlike the ENUPDATE notification message, this notification message is sent after Windows updates the display. ONENERRSPACE The edit control cannot allocate enough memory to meet a specific request. ONENHSCROLL The user clicks an edit control's horizontal scroll bar.
The parent window is notified before the screen is updated. ONENKILLFOCUS The edit control loses the input focus. ONENMAXTEXT The current insertion has exceeded the specified number of characters for the edit control and has been truncated. Also sent when an edit control does not have the ESAUTOHSCROLL style and the number of characters to be inserted would exceed the width of the edit control. Also sent when an edit control does not have the ESAUTOVSCROLL style and the total number of lines resulting from a text insertion would exceed the height of the edit control.
ONENSETFOCUS Sent when an edit control receives the input focus. ONENUPDATE The edit control is about to display altered text. Sent after the control has formatted the text but before it screens the text so that the window size can be altered, if necessary. ONENVSCROLL The user clicks an edit control's vertical scroll bar. The parent window is notified before the screen is updated. If you create a CEdit object within a dialog box, the CEdit object is automatically destroyed when the user closes the dialog box.
If you create a CEdit object from a dialog resource using the dialog editor, the CEdit object is automatically destroyed when the user closes the dialog box. If you create a CEdit object within a window, you may also need to destroy it.
If you create the CEdit object on the stack, it is destroyed automatically. If you create the CEdit object on the heap by using the new function, you must call delete on the object to destroy it when the user terminates the Windows edit control. If you allocate any memory in the CEdit object, override the CEdit destructor to dispose of the allocations.
To modify certain styles in an edit control (such as ESREADONLY) you must send specific messages to the control instead of using. See in the Windows SDK.
For more information on CEdit, see. Inheritance Hierarchy CEdit Requirements Header: afxwin.h CEdit::CanUndo Call this function to determine if the last edit operation can be undone. BOOL CanUndo const; Return Value Nonzero if the last edit operation can be undone by a call to the Undo member function; 0 if it cannot be undone. Remarks For more information, see in the Windows SDK. Example See the example for. CEdit::CEdit Constructs a CEdit object.
CEdit; Remarks Use to construct the Windows edit control. Example // Declare a local CEdit object. CEdit myEdit; // Declare a dynamic CEdit object. CEdit.
pmyEdit = new CEdit; CEdit::CharFromPos Call this function to retrieve the zero-based line and character indices of the character nearest the specified point in this CEdit control int CharFromPos(CPoint pt) const; Parameters pt The coordinates of a point in the client area of this CEdit object. Return Value The character index in the low-order WORD, and the line index in the high-order WORD. Note GetHandle will not work with Windows 95/98. If you call GetHandle in Windows 95/98, it will return NULL. GetHandle will work as documented under Windows NT, versions 3.51 and later.
For more information, see in the Windows SDK. Example HLOCAL h = mmyEdit.GetHandle; LPCTSTR lpszText = (LPCTSTR)::LocalLock(h); // Dump the text of the edit control. AFXDUMP(lpszText);::LocalUnlock(h); CEdit::GetHighlight Gets the indexes of the first and last characters in a range of text that is highlighted in the current edit control. BOOL GetHighlight( int.
Definir Ou Supprimer L'etat De Lecture Seule
pichStart, int. pichEnd) const; Parameters Parameter Description pichStart out Zero-based index of the first character in the range of text that is highlighted. PichEnd out Zero-based index of the last character in the range of text that is highlighted. Return Value TRUE if this method is successful; otherwise, FALSE. Remarks This method sends the message, which is described in the Windows SDK.
Both SetHighlight and GetHighlight are currently enabled for UNICODE builds only. CEdit::GetLimitText Call this member function to get the text limit for this CEdit object. UINT GetLimitText const; Return Value The current text limit, in bytes, for this CEdit object. Remarks The text limit is the maximum amount of text, in bytes, that the edit control can accept.
Note This member function is available beginning with Windows 95 and Windows NT 4.0. For more information, see in the Windows SDK. Example See the example for. CEdit::GetModify Call this function to determine whether the contents of an edit control have been modified. BOOL GetModify const; Return Value Nonzero if the edit-control contents have been modified; 0 if they have remained unchanged. Remarks Windows maintains an internal flag indicating whether the contents of the edit control have been changed. This flag is cleared when the edit control is first created and may also be cleared by calling the member function.
For more information, see in the Windows SDK. Example // Reset the modified state only if my edit has been modified. If (mmyEdit.GetModify) mmyEdit.SetModify(FALSE); CEdit::GetPasswordChar Call this function to retrieve the password character that is displayed in an edit control when the user enters text.
TCHAR GetPasswordChar const; Return Value Specifies the character to be displayed instead of the character that the user typed. The return value is NULL if no password character exists. Remarks If you create the edit control with the ESPASSWORD style, the DLL that supports the control determines the default password character.
The manifest or the method determines which DLL supports the edit control. If user32.dll supports the edit control, the default password character is ASTERISK ('.' , U+002A).
If comctl32.dll version 6 supports the edit control, the default character is BLACK CIRCLE ('●', U+25CF). For more information about which DLL and version supports the common controls, see.
This method sends the message, which is described in the Windows SDK. Example // Turn on the password mode. MmyEdit.SetPasswordChar('.' ); ASSERT(mmyEdit.GetStyle & ESPASSWORD); ASSERT(mmyEdit.GetPasswordChar '.' ); CEdit::GetRect Call this function to get the formatting rectangle of an edit control.
Void GetRect(LPRECT lpRect) const; Parameters lpRect Points to the RECT structure that receives the formatting rectangle. Remarks The formatting rectangle is the limiting rectangle of the text, which is independent of the size of the edit-control window. The formatting rectangle of a multiple-line edit control can be modified by the and member functions. For more information, see in the Windows SDK. Example See the example for.
CEdit::GetSel Call this function to get the starting and ending character positions of the current selection (if any) in an edit control, using either the return value or the parameters. DWORD GetSel const; void GetSel( int& nStartChar, int& nEndChar) const; Parameters nStartChar Reference to an integer that will receive the position of the first character in the current selection. NEndChar Reference to an integer that will receive the position of the first nonselected character past the end of the current selection. Return Value The version that returns a DWORD returns a value that contains the starting position in the low-order word and the position of the first nonselected character after the end of the selection in the high-order word. Remarks For more information, see in the Windows SDK. Example // Set the selection to be all characters after the current selection.
DWORD dwSel = mmyEdit.GetSel; mmyEdit.SetSel(HIWORD(dwSel), -1); CEdit::HideBalloonTip Hides any balloon tip associated with the current edit control. BOOL HideBalloonTip; Return Value TRUE if this method is successful; otherwise, FALSE. Remarks This function sends the message, which is described in the Windows SDK. CEdit::LimitText Call this function to limit the length of the text that the user may enter into an edit control. Void LimitText(int nChars = 0); Parameters nChars Specifies the length (in bytes) of the text that the user can enter. If this parameter is 0, the text length is set to UINTMAX bytes. This is the default behavior.
Remarks Changing the text limit restricts only the text the user can enter. It has no effect on any text already in the edit control, nor does it affect the length of the text copied to the edit control by the member function in CWnd. If an application uses the SetWindowText function to place more text into an edit control than is specified in the call to LimitText, the user can delete any of the text within the edit control.
However, the text limit will prevent the user from replacing the existing text with new text, unless deleting the current selection causes the text to fall below the text limit. Note This member function is available beginning with Windows 95 and Windows NT 4.0.
For more information, see in the Windows SDK. Example See the example for. CEdit::ReplaceSel Call this function to replace the current selection in an edit control with the text specified by lpszNewText. Void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE); Parameters lpszNewText Points to a null-terminated string containing the replacement text.
BCanUndo To specify that this function can be undone, set the value of this parameter to TRUE. The default value is FALSE. Remarks Replaces only a portion of the text in an edit control. If you want to replace all of the text, use the member function. If there is no current selection, the replacement text is inserted at the current cursor location.
For more information, see in the Windows SDK. Example See the example for. CEdit::SetCueBanner Sets the text that is displayed as the text cue, or tip, in an edit control when the control is empty. BOOL SetCueBanner(LPCWSTR lpszText); BOOL SetCueBanner( LPCWSTR lpszText, BOOL fDrawWhenFocused = FALSE); Parameters lpszText in Pointer to a string that contains the cue to display in the edit control. FDrawWhenFocused in If FALSE, the cue banner is not drawn when the user clicks in the edit control and gives the control the focus. If TRUE, the cue banner is drawn even when the control has focus. The cue banner disappears when the user starts to type in the control.
The default value is FALSE. Return Value TRUE if the method is successful; otherwise FALSE. Remarks This method sends the message, which is described in the Windows SDK. For more information, see the macro. Example The following example demonstrates the method. Mcedit.SetCueBanner(T('First, enter text here.'
), TRUE); CEdit::SetHandle Call this function to set the handle to the local memory that will be used by a multiple-line edit control. Void SetHandle(HLOCAL hBuffer); Parameters hBuffer Contains a handle to the local memory. This handle must have been created by a previous call to the Windows function using the LMEMMOVEABLE flag. The memory is assumed to contain a null-terminated string. If this is not the case, the first byte of the allocated memory should be set to 0. Remarks The edit control will then use this buffer to store the currently displayed text instead of allocating its own buffer. This member function is processed only by multiple-line edit controls.
Before an application sets a new memory handle, it should use the member function to get the handle to the current memory buffer and free that memory using the LocalFree Windows function. SetHandle clears the undo buffer (the member function then returns 0) and the internal modification flag (the member function then returns 0). The edit-control window is redrawn. You can use this member function in a multiple-line edit control in a dialog box only if you have created the dialog box with the DSLOCALEDIT style flag set. Note GetHandle will not work with Windows 95/98.
If you call GetHandle in Windows 95/98, it will return NULL. GetHandle will work as documented under Windows NT, versions 3.51 and later.
For more information, see, and in the Windows SDK. Example // The string to set in the edit control.
CString strString(T('George Frideric')); // Initialize the new local handle. Sizet cbSize = (strString.GetLength + 1). sizeof(TCHAR); HLOCAL h =::LocalAlloc(LHND, cbSize); LPTSTR lpszText = (LPTSTR)::LocalLock(h); tcsncpys(lpszText, cbSize / sizeof(TCHAR), strString, TRUNCATE);::LocalUnlock(h); // Free the current text handle of the edit control.::LocalFree(mmyEdit.GetHandle); // Set the new text handle. MmyEdit.SetHandle(h); CEdit::SetHighlight Highlights a range of text that is displayed in the current edit control. Void SetHighlight( int ichStart, int ichEnd); Parameters Parameter Description ichStart in Zero-based index of the first character in the range of text to highlight.
IchEnd in Zero-based index of the last character in the range of text to highlight. Remarks This method sends the message, which is described in the Windows SDK. This method sends the message, which is described in the Windows SDK. Both SetHighlight and GetHighlight are enabled for UNICODE builds only.
CEdit::SetLimitText Call this member function to set the text limit for this CEdit object. Void SetLimitText(UINT nMax); Parameters nMax The new text limit, in characters. Remarks The text limit is the maximum amount of text, in characters, that the edit control can accept. Changing the text limit restricts only the text the user can enter. It has no effect on any text already in the edit control, nor does it affect the length of the text copied to the edit control by the member function in CWnd. If an application uses the SetWindowText function to place more text into an edit control than is specified in the call to LimitText, the user can delete any of the text within the edit control.
However, the text limit will prevent the user from replacing the existing text with new text, unless deleting the current selection causes the text to fall below the text limit. This function replaces in Win32. For more information, see in the Windows SDK. Example See the example for. CEdit::SetMargins Call this method to set the left and right margins of this edit control.
Void SetMargins( UINT nLeft, UINT nRight); Parameters nLeft The width of the new left margin, in pixels. NRight The width of the new right margin, in pixels.