<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Форум компьютерной помощи &mdash; Средства обмена данными между приложениями]]></title>
		<link>https://itpmr.ru/viewtopic.php?id=752</link>
		<atom:link href="https://itpmr.ru/extern.php?action=feed&amp;tid=752&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Средства обмена данными между приложениями».]]></description>
		<lastBuildDate>Mon, 24 Dec 2012 11:48:48 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Средства обмена данными между приложениями]]></title>
			<link>https://itpmr.ru/viewtopic.php?pid=123795#p123795</link>
			<description><![CDATA[<p>Задание: написать приложение, выполняющее занесение текста и картинки в буфер обмена, а также получающее эти данные из буфера обмена.<br />Код программы:<br />using System;<br />using System.Collections.Generic;<br />using System.ComponentModel;<br />using System.Data;<br />using System.Drawing;<br />using System.Linq;<br />using System.Text;<br />using System.Windows.Forms;</p><p>namespace Laba5TVP<br />{<br />&nbsp; &nbsp; public partial class Form1 : Form<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; OpenFileDialog ofd = new OpenFileDialog();<br />&nbsp; &nbsp; &nbsp; &nbsp; public Form1()<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InitializeComponent();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CenterToScreen();<br />&nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; private void button2_Click(object sender, EventArgs e)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Clipboard.SetText(textBox1.Text); // заносим в буфер обмена введенный текст<br />&nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; private void button1_Click(object sender, EventArgs e)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ofd.Filter = &quot;Картинки (*.jpg)(*.png)|*.jpg&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ofd.ShowDialog();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (ofd.FileName != &quot;&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Bitmap image = new Bitmap(ofd.FileName);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pictureBox1.Image = image;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; private void button3_Click(object sender, EventArgs e)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IDataObject iData = Clipboard.GetDataObject();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (iData.GetDataPresent(DataFormats.Text))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; label2.Text = (String)iData.GetData(DataFormats.Text);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; catch (Exception ex) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.Show(ex.ToString()); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; private void button4_Click(object sender, EventArgs e)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Bitmap))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pictureBox2.Image = (Bitmap)Clipboard.GetDataObject().GetData(DataFormats.Bitmap);<br />&nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; private void button5_Click(object sender, EventArgs e)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Clipboard.SetDataObject(pictureBox1.Image, true); // заносим в буфер обмена выбранную картинку<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />}</p>]]></description>
			<author><![CDATA[null@example.com (admin)]]></author>
			<pubDate>Mon, 24 Dec 2012 11:48:48 +0000</pubDate>
			<guid>https://itpmr.ru/viewtopic.php?pid=123795#p123795</guid>
		</item>
	</channel>
</rss>
