Public Member Functions

ICustEdit Class Reference

This reference page is linked to from the following overview topics: Methods and Classes of Custom Controls.


Search for all occurrences

Detailed Description

See also:
Class ICustomControl, Custom Controls.

Description:
This control is a simple text input control. The user may type any string into the field and the plug-in is notified when the user presses the ENTER key. There are also methods to parse and return integer and floating point values entered in the control.

cc1.gif
To initialize the pointer to the control call:
ICustEdit *GetICustEdit(HWND hCtrl);

To release the control call:
ReleaseICustEdit(ICustEdit *ice);
The value to use in the Class field of the Custom Control Properties dialog is: CustEdit
The following messages may be sent by the edit control:
This message is sent when the control gets focus or when the user presses the ENTER key while using the control.
WM_CUSTEDIT_ENTER
wParam contains the custom edit control resource ID.
lParam contains the HWND of custom edit control.

#include <custcont.h>

Inheritance diagram for ICustEdit:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void  GetText (MCHAR *text, int ct)=0
virtual void  GetText (MSTR &text) const =0
virtual int  GetTextLength () const =0
virtual void  SetText (const MCHAR *text)=0
virtual void  SetText (int i)=0
virtual void  SetText (float f, int precision=3)=0
virtual int  GetInt (BOOL *valid=NULL)=0
virtual float  GetFloat (BOOL *valid=NULL)=0
virtual void  SetLeading (int lead)=0
virtual void  WantReturn (BOOL yesNo)=0
virtual BOOL  GotReturn ()=0
virtual void  GiveFocus ()=0
virtual BOOL  HasFocus ()=0
virtual void  WantDlgNextCtl (BOOL yesNo)=0
virtual void  SetNotifyOnKillFocus (BOOL onOff)=0
virtual void  SetBold (BOOL onOff)=0
virtual void  SetParamBlock (ReferenceTarget *pb, int subNum)=0

Member Function Documentation

virtual void GetText ( MCHAR *  text,
int  ct 
) [pure virtual]
Remarks:
This retrieves the text entered into the control.
Parameters:
text Storage for the text to retrieve.
ct Specifies the maximum length of the string returned.
virtual void GetText ( MSTR text ) const [pure virtual]
Remarks:
This retrieves the text entered into the control.
Parameters:
text Storage for the text to retrieve.
virtual int GetTextLength ( ) const [pure virtual]
Remarks:
This retrieves the length of the text entered into the control. It returns the length of the text in characters (so without the terminating NULL). Note that this value may be higher than the actual length of the text when it contains multi-byte characters.
virtual void SetText ( const MCHAR *  text ) [pure virtual]
Remarks:
This method places the text into the control for editing.
Parameters:
text The text to place in the control.
virtual void SetText ( int  i ) [pure virtual]
Remarks:
This method allows you to pass in an integer value to the control. The integer is converted to a string and displayed in the control.
Parameters:
i This value is converted to a string and displayed in the control.
virtual void SetText ( float  f,
int  precision = 3 
) [pure virtual]
Remarks:
This method allows you to pass in a floating point value to the control. The float is converted to a string and displayed in the control.
Parameters:
f This value is converted to a string and displayed in the control.
precision The precision argument is simply the number of decimal places that get represented in the string that appears in the edit field. So if the arguments were (1.0f/3.0f, 3) then the string "0.333" would appear in the edit field.
virtual int GetInt ( BOOL *  valid = NULL ) [pure virtual]
Remarks:
This method parses and returns an integer value from the control.
Parameters:
valid This pointer, if passed, is set to TRUE if the input is 'valid'; otherwise FALSE. FALSE indicates that something caused the parsing of the input to terminate improperly. An example is a non-numeric character. So for example, if the user entered "123jkfksdf" into the field the valid pointer would be set to FALSE.
virtual float GetFloat ( BOOL *  valid = NULL ) [pure virtual]
Remarks:
This method parses and returns a floating point value from the control.
Parameters:
valid This pointer, if passed, is set to TRUE if the input is 'valid'; otherwise FALSE. FALSE indicates that something caused the parsing of the input to terminate improperly. An example is a non-numeric character. So for example, if the user entered "123jkfksdf" into the field this pointer would be set to FALSE.
virtual void SetLeading ( int  lead ) [pure virtual]
Remarks:
A developer doesn't normally need to call this method. This offsets the text vertically in the edit control.
Parameters:
lead This parameter specifies the number of pixels to offset.
virtual void WantReturn ( BOOL  yesNo ) [pure virtual]
Remarks:
This method allows custom handling of the RETURN key. If you pass TRUE to this method an EN_CHANGE message will be sent to the control when the RETURN key is pressed. The EN_CHANGE message is sent when the user has taken any action that may have altered text in an edit control so developer need to also call GotReturn() (documented below) to see if it was indeed a RETURN key press.
Parameters:
yesNo If TRUE, then when the user presses the RETURN key in that control, the edit field will send an EN_CHANGE message to the owner, and calling GotReturn() will return TRUE.
Sample Code:
Below is the way this is handled by the Hit By Name dialog. In that dialog, when the user enters a wild card pattern into the name match field and presses RETURN, the dialog is exited with the items matching the pattern selected. The way this is accomplished is by pass TRUE to WantReturn() and then processing the EN_CHANGE message on the control. If GotReturn() is TRUE the Win32 function PostMessage() is used to send the IDOK message to exit the dialog. If this wasn't done, pressing RETURN in the edit control would only enter the text -- the user would have to move the mouse over the OK button and press it.

        case IDC_HBN_PATTERN:
            if (HIWORD(wParam)==EN_CHANGE)
            {
                iName = GetICustEdit(GetDlgItem(hDlg,IDC_HBN_PATTERN) );
                iName->GetText(buf,256);
                ct = _tcslen(buf);
                if(ct && buf[ct-1] != _M('*'))
                    _tcscat(buf, _M("*"));
                SendMessage(sbn->hList, LB_RESETCONTENT, 0, 0);
                sbn->SetPattern(GetDlgItem(hDlg, IDC_HBN_PATTERN), buf);
                sbn->BuildHitList(ct);
                if(iName->GotReturn())
                    PostMessage(hDlg,WM_COMMAND,IDOK,0);
                ReleaseICustEdit(iName);
            }
            break;
virtual BOOL GotReturn ( ) [pure virtual]
Remarks:
This method should be called on receipt of an EN_CHANGE message. It return TRUE if pressing the RETURN key generated the message; otherwise FALSE.
virtual void GiveFocus ( ) [pure virtual]
Remarks:
Calling this method gives the control the focus to receive input.
virtual BOOL HasFocus ( ) [pure virtual]
Remarks:
Returns TRUE if the control has the focus to receive input; otherwise FALSE.
virtual void WantDlgNextCtl ( BOOL  yesNo ) [pure virtual]
Remarks:
Determines whether the TAB key may be used to jump to the next control in the tab sequence.
Parameters:
yesNo TRUE to enable the TAB key to move to the next control; FALSE to disable the TAB key from moving the focus.
virtual void SetNotifyOnKillFocus ( BOOL  onOff ) [pure virtual]
Remarks:
Normally when a user exits an edit filed the notification WM_CUSTEDIT_ENTER is sent. Many plug-ins key off this message to finalize the input of values. For instance, if the user is entering a value into an edit field and they hit the TAB key to leave the field the value should be entered. Normally this is the desired behavior. However, as a special case condition, if a developer does not want to update the value, this method may be called so the WM_CUSTEDIT_ENTER notification won't be sent when the edit control loses focus.
Parameters:
onOff TRUE to turn on; FALSE to turn off.
virtual void SetBold ( BOOL  onOff ) [pure virtual]
Remarks:
Sets the text font in the edit control to display in a bold format or normal.
Parameters:
onOff TRUE to turn bolding on; FALSE to turn off.
virtual void SetParamBlock ( ReferenceTarget pb,
int  subNum 
) [pure virtual]

ICustEdit ICustEdit ICustEdit ICustEdit ICustEdit ICustEdit ICustEdit ICustEdit ICustEdit ICustEdit
ICustEdit ICustEdit ICustEdit ICustEdit ICustEdit ICustEdit ICustEdit ICustEdit ICustEdit ICustEdit