Home > Software engineering >  VC write a typing software with CRICHEDIT always has a problem
VC write a typing software with CRICHEDIT always has a problem

Time:11-07

Interface the following ,
1. Above one is the normal text box IDC_EDIT1, the following is a CRICHEDIT (IDC_RICHEDIT2), the first text box the default content has been produced, but a text box onchange event is used to test the following words, to use blue show, wrong in red, but the result is always shown above problems, not according to the text content of right and wrong, the correct display color,
ONCHANGE code is as follows, please expert guidance (with _mbcs code) :
Void CWztestDlg: : OnChangeRichedit2 ()
{
//TODO: If this is a RICHEDIT control, the control will not
//send this notification unless you override the CDialog: : OnInitDialog ()
//function and call CRichEditCtrl (.) SetEventMask ()
//have the ENM_CHANGE flag ORed into the mask.

//TODO: Add your the control notification handler code here
WND CWnd * and * wndstatic;
Cstrings wznum txt1, txt2, temp1, temp2;//richedit length of the contents of a text box, the contents of the two text boxes (txt1 and txt2) and intercept the character at a time (temp1, temp2)
Int wzlength;
WND=GetDlgItem (IDC_RICHEDIT2);
Wzlength=WND - & gt; GetWindowTextLength ();
Wznum. The Format (" % d ", wzlength);
Wndstatic=GetDlgItem (IDC_STATIC);

CHARFORMAT cf;//set the font
This - & gt; M_richedit. GetDefaultCharFormat (cf);
Cf. DwMask=CFM_COLOR | CFM_OFFSET | CFM_SIZE | CFM_FACE;
Cf. DwEffects=CFE_BOLD | CFE_ITALIC;
Cf. YHeight=400;//set the height
Strcpy (cf. SzFaceName, _T (" official script "));
Cf. CbSize=20;
GetDlgItem (IDC_EDIT1) - & gt; GetWindowText (txt1);//get the first text box content
WND - & gt; GetWindowText (txt2);
If (txt2 GetLength () & gt; Txt1. GetLength ())
return;
for(int i=0; i{if (IsDBCSLeadByte (txt2 GetAt (I)))
{temp1=txt1. Mid (I, 2);
Temp2=txt2. Mid (I, 2);
}
The else
{temp1=txt1. Mid (I, 1);
Temp2=txt2. Mid (I, 1);
}
If (temp1==temp2)
{
//set the font
Cf. CrTextColor=RGB (0,0,255);//set colors


}
The else
{
Cf. CrTextColor=RGB (0, 255);//set colors
}
If (IsDBCSLeadByte (txt2 GetAt (I)))
{m_richedit. SetSel (I, 2);
i++;
}
The else
M_richedit. SetSel (I, 1);
M_richedit. SetSelectionCharFormat (cf);
M_richedit. SetSel (txt2. GetLength (), txt2. GetLength ());//the cursor to the text at the end of the

}
Wndstatic - & gt; SetWindowText (txt2);

}

CodePudding user response:

Put your project to switch to the Unicode encoding scheme

CodePudding user response:

reference 1/f, 7-eleven's response:
put your project to switch to the Unicode encoding scheme ~

Is the same,
  • Related