1
Reply

copying an object from clipboard

Andrzej

Andrzej

Mar 7 2009 2:12 PM
4.1k
This (below) piece of code is intended to copy selected picture from richTexBox into clipboard and then from clipboard into pictureBox, but it doesn't work. Nothing happens. Could me someone explain why?

private: System::Void butSkalujRyc_Click(System::Object^  sender, System::EventArgs^  e) {
             if (panel1->Visible == false)
             {
             this->richTextBox1->Copy();
             pictureBox1->SizeMode = PictureBoxSizeMode::StretchImage;
            
             if(Clipboard::GetDataObject()->GetDataPresent(DataFormats::Bitmap))
                 this->pictureBox1->Image = cli::safe_cast<Bitmap^>( Clipboard::GetDataObject()->GetData(DataFormats::Bitmap));

             panel1->Show();
            Clipboard::Clear();
             }
             else panel1->Hide();
         }

Answers (1)