如何从MFC的EditBox中输入的文本中获取字符 [英] How to get the characters from a text entered in the EditBox in MFC

查看:371
本文介绍了如何从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. :)


这篇关于如何从MFC的EditBox中输入的文本中获取字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆