我有兩個Winform的應用程序,當我嘗試複製從ProcessCmdKey
作品粘貼文本正確,如果我做了一個檢查其不粘貼..如何禁用在C#中的WinForms
但是,當我嘗試粘貼複製粘貼選項我的文本在記事本中被粘貼...我只是想在相同的應用程序中實現文本的COPY和粘貼
如果我專注於其他Windows窗體文本沒有被粘貼...有什麼辦法..
private const Keys CopyKeys = Keys.Control | Keys.C;
private const Keys PasteKeys = Keys.Control | Keys.V;
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
bool bVal = false;
Process[] p2 = Process.GetProcesses();
foreach (Process pro in p2)
{
if (string.Compare(pro.ProcessName, "TestForm.vshost", true) == 0 && (keyData == CopyKeys) || (keyData == PasteKeys))
{
bVal = true; // Text will be pasted
return true;
}
else
return base.ProcessCmdKey(ref msg, keyData); // Text will not be pasted
}
return bVal;
}
這工作正常。當我嘗試實現相同記事本的同時寫字板。它被粘貼。