本文整理汇总了C#中DataObject.GetDataPresent方法的典型用法代码示例。如果您正苦于以下问题:C# DataObject.GetDataPresent方法的具体用法?C# DataObject.GetDataPresent怎么用?C# DataObject.GetDataPresent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObject
的用法示例。
在下文中一共展示了DataObject.GetDataPresent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisplayClipboardData
void DisplayClipboardData()
{
try
{
IDataObject iData = new DataObject();
iData = Clipboard.GetDataObject();
if (iData.GetDataPresent(DataFormats.Text))
{
if (mstring != (string)iData.GetData(DataFormats.Text))
{
mstring = (string)iData.GetData(DataFormats.Text);
ListViewItem tLVI = listView1.FindItemWithText(mstring);
if (tLVI == null || tLVI.Text != mstring)
{
// Default delimiter \r\n
if ((bool)CPQueue.Properties.Settings.Default["splitCopy"])
{
string[] substrings;
if (!(bool)CPQueue.Properties.Settings.Default["space"])
{
substrings = Regex.Split(mstring, "\r\n");
}
else
{
substrings = mstring.Split(' ');
}
foreach (string line in substrings)
{
if (line.Length > 0)
{
ListViewItem lvi = new ListViewItem(line);
lvi.SubItems.Add(DateTime.Now.ToString("HH:mm:ss tt"));
listView1.Items.Add(lvi);
}
}
}
else
{
ListViewItem lvi = new ListViewItem(mstring);
lvi.SubItems.Add(DateTime.Now.ToString("HH:mm:ss tt"));
listView1.Items.Add(lvi);
}
listView1.Items[selectedItem].Selected = false;
listView1.Items[selectedItem].Focused = false;
if (!(bool)CPQueue.Properties.Settings.Default["stack"])
{
selectedItem = 0;
loadItem();
}
else
{
selectedItem = listView1.Items.Count - 1;
loadItem();
}
}
}
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
示例2: QueryAcceptData
public int QueryAcceptData(Runtime.InteropServices.ComTypes.IDataObject lpdataobj, IntPtr lpcfFormat, int reco, int fReally, IntPtr hMetaPict)
{
if (reco != 0)
{
return -2147467263;
}
DataObject obj2 = new DataObject(lpdataobj);
if ((obj2 == null) || (!obj2.GetDataPresent(DataFormats.Text) && !obj2.GetDataPresent(DataFormats.UnicodeText)))
{
return -2147467259;
}
return 0;
}