Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to make an edit control box in which user can enter some value. so i drag an edit control to my dialog. add a variable "value of type CString to this edit control. then i add an event handler of message type EN_CHANGE to this edit control. what should i do next?
Posted
Comments
Sweety Khan 2-Jul-10 16:07pm    
i m heartLy thankful to all who help me in my project :) SpeCial thanks and Best wiShes for Sauro Viti, Niklas Lindquist, SnowHow,emilio_grv,Sandeep Mewara,Richard MacCutchan,Jayant Dash,John Simmons, CPallini, Moak. Sorry if i forget someone's name.

Try compiling the application.
 
Share this answer
 
You don't need an event handler for EN_CHANGE unless you plan on doing something while the user types, like updating a preview or making selections in another control.

Look at your implementation of the virtual DoDataExchange()[^] function and you will see how your CEdit is interchanging data with the CString object. Also, read about the UpdateData()[^] function on msdn.

...and of course, don't forget John Simmons suggestion. It is a good one! ;)
 
Share this answer
 
Comments
Sweety Khan 1-Jul-10 14:00pm    
hmm u both making fun of me :) obviously i compiled it many times
Sweety Khan 1-Jul-10 14:10pm    
yes i have to do something with what the user types
Sweety Khan 2-Jul-10 2:07am    
i got this code and understand it from this site http://www.codersource.net/mfc/mfc-tutorials/cedit.aspx but that does not work as i want.
Sweety Khan 2-Jul-10 2:08am    
UpdateData();CString strStoreValue; strStoreValue=value; UpdateData(FALSE);
Sweety Khan 2-Jul-10 2:13am    
what i m doing wrong?
UpdateData() only affects the variables you have hooked up to your control in DoDataExchange().
*.h
CString m_strEditValue;

*.cpp
DoDataExchange(CDataExchange* pDX)
{
    DDX_Text(pDX, IDC_EDIT, m_strEditValue);
}
SomewhereElse()
{
    UpdateData(TRUE); // Get value from control to variable
      // m_strEditValue now contains the value entered in the edit control

    UpdateDate(FALSE); // Send variable data to control
      // The edit control now contains the value of m_strEditValue
}


UpdateData() will eventually call your DoDataExchange() method. Step into it with a debugger and see how it works to get a better understanding.
 
Share this answer
 
Comments
Sweety Khan 2-Jul-10 9:50am    
somewhereelse can be any button where i want to use m_strEditValue? right?
Sweety Khan 2-Jul-10 15:38pm    
its done thanx:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900