Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 将IDC_编辑文本转换为十六进制单词_C++_Winapi - Fatal编程技术网

C++ 将IDC_编辑文本转换为十六进制单词

C++ 将IDC_编辑文本转换为十六进制单词,c++,winapi,C++,Winapi,我有一个IDC_编辑文本框集,它将接受十六进制空格分隔的值,我想转换成一个单词。我希望控件模拟数组,但我真的不确定如何完成转换 基本上,如果我输入: "12 AB" 我需要得到的单词等于: 0x12AB 作为一个很少涉足C++的人,更不用说WiAPI了,我真的很难受如何去做。我目前的代码是: HWND hTextInput = GetDlgItem(hWnd, IDC_EDIT); DWORD dwInputLength = Edit_GetTextLength(hTextInput);

我有一个IDC_编辑文本框集,它将接受十六进制空格分隔的值,我想转换成一个单词。我希望控件模拟数组,但我真的不确定如何完成转换

基本上,如果我输入:

"12 AB"
我需要得到的单词等于:

0x12AB

作为一个很少涉足C++的人,更不用说WiAPI了,我真的很难受如何去做。我目前的代码是:

HWND hTextInput = GetDlgItem(hWnd, IDC_EDIT);
DWORD dwInputLength = Edit_GetTextLength(hTextInput);

char* resultString = new char[dwInputLength+1];
memset(hTextInput , 0, dwInputLength+1);

WORD result = (resultString[0] << 8) | resultString[1];
HWND htdemiput=GetDlgItem(HWND,IDC_编辑);
DWORD dwInputLength=Edit_GetTextLength(htput);
char*resultString=new char[dwInputLength+1];
memset(htdeput,0,dwInputLength+1);
WORD结果=(结果字符串[0]请尝试以下操作:

WORD Readhex(const char *p)
{
  char c ;
  WORD result = 0 ;

  while (c = *p++)
  {
    if (c >= '0' && c <= '9')
      c -= '0' ;
    else if (c >= 'A' && c <= 'F')
      c -= 'A' - 10 ;
    else if (c >= 'a' && c <= 'f')
      c -= 'a' - 10 ;
    else
      continue ;

    result = (result << 4) + c ;
  }

  return result ;
}

...
HWND hTextInput = GetDlgItem(hWnd, IDC_EDIT);
DWORD dwInputLength = Edit_GetTextLength(hTextInput);

char* resultString = new char[dwInputLength+1];
GetWindowText(hTextInput, resultString, dwInputLength+1) ;

WORD result = ReadHex(resultString) ;
WORD Readhex(const char*p)
{
字符c;
单词结果=0;
而(c=*p++)
{
如果(c>='0'&&c='A'&&c='A'&&c='A'&&c)签出。