DEV Community

海前 王
海前 王

Posted on

新的修改

void CMFCApplication3View::UpdateTextInBuffer()
{
// 锁定缓冲区以便直接访问
LPCTSTR pBuffer = LockBuffer();

  if (pBuffer != nullptr)
  {
      // 获取缓冲区的长度
      UINT nLength = GetBufferLength();

      // 创建一个可修改的缓冲区
      std::vector<TCHAR> tempBuffer(nLength + 1);  // +1 以容纳 null 终止符
      memcpy(tempBuffer.data(), pBuffer, nLength * sizeof(TCHAR));
      tempBuffer[nLength] = '\0';  // 确保字符串以 null 结尾

      // 解锁缓冲区
      UnlockBuffer();

      // 进行文本操作,例如将所有字符转换为大写
      for (UINT i = 0; i < nLength; ++i)
      {
          tempBuffer[i] = toupper(tempBuffer[i]);
      }

      // 获取 CEdit 控件的指针
      CEdit* pEdit = &GetEditCtrl(); // 视图中获取 CEdit 控件的指针

      if (pEdit != nullptr)
      {
          // 设置修改后的文本
          pEdit->SetWindowText(tempBuffer.data());
      }

      // 通知视图更新内容
      Invalidate(); // 强制视图重绘
  }
Enter fullscreen mode Exit fullscreen mode

}

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay