• Keine Ergebnisse gefunden

TEdit class

Im Dokument Reference Guide (Seite 186-195)

TEdgeOrSizeConstraint struct

inline void Absolute (TEdge edge, int value)

Used to determine edge constraints only, Absolute sets the edge of your window to a fixed value.

See also: TEdgeConstraint::Absolute

inline void PercentOf (TWindow *otherWin, int percent,

TWidthHeight otherWidthHeight = widthOrHeight) Although a window's width or height defaults to being a percentage of the sibling or parent window's corresponding dimension, it can also be a percentage of the sibling or parent's opposite dimension. For example, one window's width can be 50% of the parent window's height.

See also: TEdgeOrSizeConstraint::Absolute

inline void PercentOf (TWindow *otherWin, TEdge edge, int percent) Used to determine edge constraints only, Percent Of specifies that the edge of one window indicated in edge should be a percentage of the

corresponding edge of another window or other Win.

See also: TEdgeConstraint::PercentOf inline void SameAs (TWindow *otherWin,

TWidthHeight otherWidthHeight

=

widthOrHeight, int value

=

0)

Although a window's width or height defaults to being the same as the sibling or parent window's corresponding dimension, it can be the same of the sibling's or parent's opposite dimension. For example, one window's width can be the same as the parent window's height.

See also: TEdgeOrSizeConstraint::PercentOf inline void SameAs (TWindow *otherWin, TEdge edge)

Used to determine edge constraints only, SameAs sets the edge of one window the same as the corresponding edge of the other window specified in otherWin.

See also: TEdgeConstraint::SameAs

edit.h

A TEdit is an interface object that represents an edit control interface element in Windows. A TEdit object must be used to create an edit control in a parent TWindow. A TEdit can be used to facilitate communication

TEdit class

Constructor

Constructor

Can Undo

174

between your application and the edit controls of a TDialog. This class is streamable.

There are two styles of edit control objects: single line and multiline.

Multiline edit controls allow editing of multiple lines of text.

The position of the first character in an edit control is zero. For a multiline edit control, the 'position numbers continue sequentially from line to line;

line breaks count as two characters.

Most of TEdit's member functions manage the edit control's text. TEdit also includes some automatic member response functions that respond to selec-tions from the edit control's parent window menu, including cut, copy, and paste. Two important member functions inherited from TEdit's base class (TStatic) are GetText and SetText.

Public constructors

TEdit(TWindow* parent, int Id, const char far *text, int x, int y, int w, int h, DINT textLen, BOOL multiline

=

FALSE, TModule* module

=

0);

Constructs an edit control object with a parent window (parent). Sets the creation attributes of the edit control and fills its Attr data members with the specified control ID (Id), position (x, y) relative to the origin of the parent window's client area, width (w), and height (h).

If text buffer length (textLen) is

a

or I, there is no explicit limit to the num-ber of characters that can be entered. Otherwise textLen - 1 characters can be entered. By default, initial text (text) in the edit control is left-justified and the edit control has a border. Multiline edit controls have horizontal and vertical scroll bars.

TEdit(TWindow* parent, int resourceID, DINT textLen, TModule* module = 0);

Constructs a TEdit object to be associated with an edit control of a TDialog.

Invokes the TStatic constructor with identical parameters. The resourceID parameter must correspond to an edit resource that you define. Enables the data transfer mechanism by calling EnableTransfer.

See also: TStatic::TStatic

Public member functions

BOOL CanDndo();

Returns TRUE if it is possible to undo the last edit.

ObjecfWindows 2.0 Reference Guide

ClearModify

Copy

Cut

DeleteLine

DeleteSelection

DeleteSubText

TEdit class

See also: TEdit::Undo void ClearModify() i

Resets the change flag of the edit control causing IsModified to return FALSE. The flag is set when text is modified.

See also: TEdit::IsModified void Copy ( ) i

Copies the currently selected text into the Clipboard.

void Cut() i

Deletes the currently selected text and copies it into the Clipboard.

BOOL DeleteLine(int lineNurnber) i

Deletes the text in the line specified by lineNumber in a multiline edit control. If -1 passed, deletes the current line. DeleteLine does not delete the line break and affects no other lines. Returns TRUE if successful. Returns FALSE if lineNumber is not -1 and is out of range or if an error occurs.

BOOL DeleteSelection() i

Deletes the currently selected text, and returns FALSE if no text is selected.

BOOL DeleteSubText(UINT startPos, UINT endPos) i

Deletes the text between the starting and ending positions specified by startPos and endPos, respectively. DeleteSubText returns TRUE if successful.

EmptyUndoBuffer void EmptyUndoBuffer () ;

FormatLines

If an operation inside the edit control can be undone, the edit control undo flag is set. EmptyUndoBuffer resets or clears this flag.

inline void ForrnatLines(BOOL addEOL)i

Indicates if the end-of-line characters (carriage return, linefeed) are to be added or removed from text lines that are wordwrapped in a multiline edit control. Returns TRUE if these characters are placed at the end of

wordwrapped lines or FALSE if they are removed.

GetFirstVisibleLine inline int GetFirstVisibleLine () const i

GetHandle

Indicates the topmost visible line in an edit control. For single-line edit controls, the return value is O. For multiline edit controls, the return value is the index of the topmost visible line.

inline HANDLE GetHandle() const;

TEdit class

GetLine

GetLineFromPos

GetLinelndex

GetLineLength

GetNumLines

Returns the data handle of the buffer that holds the contents of the control window.

See also: :TEdit::SetHandle

BOOL GetLine(char far* str, int strSize, int lineNumber) i

Retrieves a line of text (whose line number is supplied) from the edit control and returns it in str (NULL-terminated). strSize indicates how many characters to retrieve. GetLine returns FALSE if it is unable to retrieve the text or if the supplied buffer is too small.

See also: TStatic::GetText, TEdit::GetNumLines, TEdit::GetLineLength inline int GetLineFromPos(DINT charPos)i

From a multiline edit control, returns the line number on which the char-acter position specified by charPos occurs. If charPos is greater than the position of the last character, the number of the last line is returned. If charPos is-I, the number of the line that contains the first selected character is returned. If there is no selection, the line containing the caret is returned.

See also: ::EM_LINEFROMCHAR inline DINT GetLineIndex(int lineNumber) i

In a multiline edit control, GetLinelndex returns the number of characters that appear before the line number specified by lineNumber. If lineNumber is -I, GetLinelndex returns the number of the line that contains the caret is returned.

See also: ::EM_LINEINDEX int GetLineLength(int lineNumber) i

From a multiline edit control, GetLineLength returns the number of characters in the line specified by lineNumber. If it is -I, the following applies: if no text is selected, GetLineLength returns the length of the line where the caret is positioned; if text is selected on the line, GetLineLength returns the line length minus the number of selected characters; if selected text spans more than one line, GetLineLength returns the length of the lines minus the number of selected characters.

inline int GetNumLines() i

Returns the number of lines that have been entered in a multiline edit control: 1 if the edit control has no text (if it has one line with no text in it), or

a

if there is no text or if an error occurs.

See also: ::EM_GETNUMLINES GetPasswordChar inline DINT GetPasswordChar () const i

176 ObjecfWindows 2.0 Reference Guide

GetRect

GetSelection

GetSubText

TEdit class

Returns the character to be displayed in place of a user-typed character.

When the edit control is created with the ES_PASSWORD style specified, the default display character is an asterisk (*).

See also: TEdit::SetPasswordChar, ::EM_GETPASSWORDCHAR, ::ES_PASSWORD

inline void GetRect(TRect& frmtRect) const;

Gets the formatting rectangle of a multiline edit control.

See also: TEdit::SetRect, TEdit::SetRectNP, ::EM_GETRECT inline void GetSelection(UINT& startPos, UINT& endPos);

Returns the starting (startPos) and ending (endPos) positions of the currently selected text. By using GetSelection in conjunction with GetSubText, you can get the currently selected text.

See also: TEdit::GetSubText

void GetSubText(char far* str, UINT startPos, UINT endPos);

Retrieves the text in an edit control from indices startPos to endPos and returns it in str.

See also: TEdit::GetSelection

GetWordBreakProc inline EDITWORDBREAKPROC GetWordBreakProc () const;

Insert

IsModified

LockBuffer

Retrieves the current wordwrap function. Returns the address of the wordwrap function defined by the application or

a

if none exists.

See also: TEdit::SetWordBreakProc, ::EM_GETWORDBREAKPROC inline void Insert (const char far* str);

Inserts the text supplied in str into the edit control at the current text insertion point (cursor position), and replaces any currently selected text.

Insert is similar to Paste, but does not affect the Clipboard.

See also: TEdit::Paste BOOL IsModified();

Returns TRUE if the user has changed the text in the edit control.

See also: TEdit::ClearModify

char far* LockBuffer(UINT newsize=O);

Locks the edit control's buffer and returns a pointer to the buffer. Passing newsize greater than

a

causes the buffer to be resized to newsize. You must call Unlock when you are finished.

TEd it class

Paste

Scroll

Search

SetHandle

See also: TEdit::UnLockBuffer void Paste() i

Inserts text from the Clipboard into the edit control at the current text insertion point (cursor position).

See also: TEdit::CMEditPaste

inline void Scroll (int horizontalUnit, int verticalUnit)i

Scrolls a multiline edit control horizontally and vertically using the numbers of characters specified in horizontalUnit and verticalUnit. Positive values result in scrolling to the right or down in the edit control, and negative values result in scrolling to the left or up.

int Search(UINT startPos, const char far* text, BOOL caseSensitive=FALSE, BOOL wholeWord=FALSE, BOOL up=FALSE)i

Performs either a case-sensitive or case-insensitive search for the supplied text. If the text is found, the matching text is selected, and Search returns the position of the beginning of the matched text. If the text is not found in the edit control's text, Search returns -1. If -1 is passed as startPos, then the search starts from either the end or the beginning of the currently selected text, depending on the search direction.

inline void SetHandle(HLOCAL localMem) i

Sets a handle to the text buffer used to hold the contents of a multiline edit control.

See also: :TEdit::GetHandle SetPasswordChar void SetPasswordChar (DINT ch) i

SetReadOnly

SetRect

SetRectNP

178

SetPasswordChar sets the character to be displayed in place of a user-typed character. When the ES_P ASSWORD style is specified, the default display character is an asterisk (*).

See also: TEdit::GetPasswordChar, ::ES_PASSWORD inline void SetReadOnly(BOOL readOnlY)i

Sets the edit control to be read-only or read-write.

inline void SetRect(const TRect& frmtRect)i

Sets the formatting rectangle for a multiline edit control.

See also: TEdit::GetRect, TEdit::SetRectNP inline void SetRectNP(const TRect& frmtRect) i

ObjectWindows 2.0 Reference Guide

SetSelection

SetTabStops

TEdit class

Sets the formatting rectangle for a multiline edit control. Unlike SetRect, SetRectNP does not repaint the edit control.

See also: TEdit::GetRect, TEdit::SetRect

inline BOOL SetSelection(UINT startPos, UINT endPos);

Forces the selection of the text between the positions specified by startPos and endPos, but not including the character at endPos.

void inline SetTabStops(int numTabs, const int far* tabs);

Sets the tab stop positions in a multiline edit control.

SetVVordBreakProc inline void SetWordBreakProc(EDITWORDBREAKPROC proc);

Undo

UnlockBuffer

Validator

CanClose

In a multiline edit control, Set WordBreakProc indicates that an application-supplied word-break function has replaced the default word-break function. The application-supplied word-break function· might break the words in the text buffer at a character other than the default blank character.

See also: TEdit::GetWordBreakProc void Undo();

Undoes the last edit.

See also: TEdit::CanUndo, TEdit::CMEditUndo

void UnlockBuffer(const char far* buffer, BOOL updateHandle=FALSE);

Unlocks a locked edit control buffer. If the contents were changed, updateHandle should be TRUE.

See also: TEdit::LockBuffer

Protected data members

TValidator* Validator;

Points to the valida tor object constructed in your derived class to validate input text. If no valida tor exists, Validator is zero.

Protected member functions

BOOL CanClose();

Checks to see if all child windows can be closed before closing the current window. If any child window returns FALSE, CanClose returns FALSE and

TEdit class

CmEditClear

CmEditCopy

CmEditCut

CmEditDelete

CmEditPaste

CmEditUndo

ENErrSpace

EvChar

180

terminates the process. If all child windows can be closed, CanClose returns TRUE.

void CrnEditClear()i

Automatically responds to a menu selection with a menu ID of CM_EDITCLEAR by calling Clear.

See also: TStatic::Clear void CrnEditCopY()i

Automatically responds to a menu selection with a menu ID of CM_EDITCOPY by calling Copy.

See also: TEdit::Copy void CrnEditCut()i

Automatically responds to a menu selection with a menu ID of CM_EDITCUT by calling Cut.

See also: TEdit::Cut void CrnEditDelete()i

Automatically responds to a menu selection with a menu ID of CM_EDITDELETE by calling DeleteSelection.

See also: TEdit::DeleteSelection void CrnEditPaste()i

Automatically responds to a menu selection with a menu ID of CM_EDITP ASTE by calling Paste.

See also: TEdit::Paste void CrnEditUndo() i

Automatically responds to a menu selection with a menu ID of CM_EDITUNDO by calling Undo.

See also: TEdit::Undo void ENErrSpace()i

Sounds a beep in response to an error notification message that is sent when the edit control unsuccessfully attempts to allocate more memory.

void EvChar(UINT key, UINT repeatCount, UINT flags) i

Validates the text entered into the edit control. If the input is incorrect, the original text is restored. Otherwise, the validated and modified text is placed back into the edit control, so the results of the auto-fill (if any) can be

ObjectWindows 2.0 Reference Guide

EvGetDlgCode

EvKeyDown

EvKiIIFocus

GetClassName

SetupWindow

I calt class

viewed. When Is ValidInput is called, the SupressFill parameter defaults to False, so that the string can be modified.

DINT EvGetDlgCode();

Responds to the GetDlgCode query according to the current state of the control. If the edit control contains valid input, then Tabs are allowed for changing focus.

void EvKeyDown(DINT key, DINT repeat Count , DINT flags);

EvKeyDown translates the virtual key code into a movement. key indicates the virtual key code of the pressed key, repeatCount holds the number of times the same key is pressed, flags contains one of the messages that translates to a virtual key (VK) code for the mode indicators. If the Tab key is sent to the Edit Control, EvKeyDown checks the validity before allowihg the focus to change.

void EvKillFocus(HWND hWndGetFocus);

In response to a WM_KILLFOCUS message sent to a window that is losing the keyboard, EvKillFocus hides and then destroys the caret. EvKillFocus validates text whenever the focus is about to be lost and holds onto the focus if the text is not valid. Doesn't kill the focus if another application, a Cancel button, or an OK button (in which case CanClose is called to validate text) has the focus.

char far* GetClassName();

Returns the name of TEdit's Windows registratibn class, "EDIT."

See also: TWindow::GetClassName void SetupWindow();

If the textLen data member is nonzero, Setup Window limits the number of characters that can be entered into the edit control to textLen -1.

See also: TStatic::TextLen, TWindow::SetupWindow

Response table entries

Response table entry

EV _COMMAND (CM_EDITCLEAR, CmEditClear) EV_COMMAND (CM~EDITCOPY, CmEditCopy) EV _COMMAND (CM_EDITCUT, CmEditCut) EV-.:COMMAND (CrvtEDITDELETE, CmEditDelete) EV_COMMAND (CM_EDITPASTE, CmEditPaste)

Member function CmEditClear CmEditCopy CmEditCut CmEditClear CmEditPaste

I calI class

EV _COMMAND (CM_EDITUNDO, CmEditUndo)

EV --,COMMAND_ENABLE(CM_EDITCLEAR, CmCharsEnable) EV _COMMAND_ENABLE(CM_EDITCOPY, CmSelectEnable) EV _COMMAND _ENABLE(CM_EDlrCUT, CmSelectEnable) EV _COMMAND_ENABLE(CM_EDITDELETE, CmSelectEnable) EV _COMMAND _ENABLE(CM_EDITPASTE, CmPasteEnable) EV _COMMAND_ENABLE(CM_EDITUNDO, CmModEnable) EV _NOTIFY _AT_CHILD (EN_ERRSPACE, ENErrSpace) EV_WM_CHAR

TEditFile is a file-editing window. TEditFile'sdata members and member functions manage the file dialog box and automatic responses for file commands such as Open, Read, Write, Save, and SaveAs. TEditFile is

streamable. .

Public data members

TOpenSaveDialog: :TData FileData;

Contains information about the user's file open or save selection.

See also: TOpenSaveDialog::TData char far* FileName;

Contains the name of the file being edited.

Public constructors and destructor

TEditFile(TWindow* parent = O,int Id = 0, const char far* text = 0, const char far* fileName

=

0, TModule*'module

=

0);

Constructs a TEditFile window given the parent window, resource ID (fd), text, file name, and module ID. Sets Filename to fileName.

Im Dokument Reference Guide (Seite 186-195)