RichEditCtrl.

Hi All,

How can i enable right click on RichEditCtrl

I want to pop up menu on the right click

Thanks



Answer this question

RichEditCtrl.

  • Richard L Brown

    If it's for a Windows forms application. It's done this way.

        System::Windows::Forms::ContextMenu^ cm;
     
        private: System::Void richTextBox1_MouseDown(System::Object^  sender,
                                    System::Windows::Forms::MouseEventArgs^  e) {
         if(e->Button == Windows::Forms::MouseButtons::Right) {
              cm = gcnew System::Windows::Forms::ContextMenu();
              MenuItem^ m1 = gcnew MenuItem( "&File" );
              MenuItem^ m2 = gcnew MenuItem( "&Open" ); 
              MenuItem^ m3 = gcnew MenuItem( "E&xit" );
              cm->MenuItems->Add( m1 );
              cm->MenuItems->Add( m2 );
              cm->MenuItems->Add( m3 ); 
              System::Drawing::Point^ p = gcnew System::Drawing::Point(10, 10);
              cm->Show(richTextBox1, *p );
            } 
         }

     This is just a quick and dirty example. If you want to do anything useful with the popup menu you will have to do some more, but this is the general direction.

    Cheers

     Sahir

     


  • Tor2k

    this is a way

    http://www.codeproject.com/richedit/popupdemo.asp

    better way: you can also do it with IRichEditOleCallback::GetContextMenu 


  • RichEditCtrl.