Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnChar

Status
Not open for further replies.

mpsoutine

Programmer
Jan 6, 2003
87
US
Hi All,

Not sure if this is the correct function to do this in. I'm trying to take a character in an one edit box, convert in to uppercase, and print it in the original edit box and also a surname edit box. Get following error message:
The instruction at "0x5f42e11a"referenced memory at "0x00000020". the memofy could not be "read".

MPSoutine.
 
Hi,

I aggree. I thought I did the cut and paste correctly.

MPSoutine

void CInitials::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default

CEdit::OnChar(nChar, nRepCnt, nFlags);

CEdit* pEditInitials =(CEdit*)GetDlgItem(IDC_EDIT_INITIALS);
CEdit* pEditSurname = (CEdit*)GetDlgItem(IDC_EDIT_SURNAME);

CString strText;

//**Retrieve the text from the "Initial" edit box

pEditInitials->GetWindowText(strText);

//** Update the context of the surname edit box

pEditSurname->SetWindowText(strText);






if(isalpha(nChar))
{
if(islower(nChar))
nChar -=32;

//**Call the default window procedure as the value of nChar
//**may have been altered

DefWindowProc(WM_CHAR, nChar, MAKELONG(nRepCnt, nFlags));

//**Call the default window procedure again to add the p[eriod

nChar = '.';
DefWindowProc(WM_CHAR, nChar, MAKELONG(nRepCnt,nFlags));


}

//** If the backspace key is pressed call the
//** base class function twice to remove the period
//** and the letter

if(nChar == VK_BACK)
{
CEdit::OnChar(nChar, nRepCnt, nFlags);
CEdit::OnChar(nChar, nRepCnt, nFlags);
}

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top