富文本框中的过去文本 不带格式的视觉C++

Past text in rich text box Visual C++ without formating

本文关键字:文本 格式 C++ 视觉 过去      更新时间:2023-10-16

我正在做我的项目,我正在为自己制作记事本。目前我处于最终状态(修复错误并添加一些最终内容)。我现在面临的问题是:当我粘贴格式化文本时,它会保持格式化,我希望它未格式化,默认字体,默认大小。我在Visual 2010 C++Microsoft工作。我用于粘贴的代码:

private: System::Void pasteToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
         richTextBox1->Paste();
     }

Paste 方法具有此重载,该重载采用指定粘贴数据格式的参数。指定所需的格式,如 DataFormats::TextDataFormats::UnicodeText 。例如:

  // Get the format for the object type.
  DataFormats::Format^ myFormat = DataFormats::GetFormat( DataFormats::Text );
  // After verifying that the data can be pasted, paste it. 
  if ( richTextBox1->CanPaste( myFormat ) )
  {
     richTextBox1->Paste( myFormat );
     return true;
  }
  else
  {
     MessageBox::Show( "The data format that you attempted to paste is not supported by this control." );
     return false;
  }