如何从MFC的EditBox中输入的文本中获取字符

问题描述:

如何从MFC的EditBox中输入的文本中分别获取字符.

例如,我用"Hello World"填充了editbox变量.现在我想按字符获取字符,例如,首先是"H",然后是"E",然后是"L",然后是"L",然后是"O"?

How to get the characters individually from a text entered in the EditBox in MFC.

For Example, I populated the editbox variable with "Hello World". Now I want to get the Character by character i.e First ''H'', then ''E'', then ''L'', then ''L'', then ''O'' like that?

我不相信有一种CEdit的方法可以明确地做到这一点,但是您可以自己编写一个方法.
I don''t believe there is a method of CEdit that will do this explicitly, but you could write a method yourself.
 char  CEdit::GetCharByIndex(int nIndex)
{
  CString  wndText;
  GetWindowText(wndText);

  ASSERT ( nIndex < wndText.GetLength() );

  return ( wndText.GetAt(nIndex) );
}

我的头顶. YMMV. :)

That''s all off the top of my head. YMMV. :)