EDN Admin
Well-known member
<div style="background-color:white; color:black
<pre> <br/>Hello I faced a problem when I tried to watchout any Clipboard activity It gives me (The path is not of a legal form) when the program try to assign the FilePath string collection to the Clipboard file drop list. This is my code:- [/code]
<pre><span style="color:blue using System;
<span style="color:blue using System.Collections.Generic;
<span style="color:blue using System.ComponentModel;
<span style="color:blue using System.Data;
<span style="color:blue using System.Drawing;
<span style="color:blue using System.Linq;
<span style="color:blue using System.Text;
<span style="color:blue using System.Windows.Forms;
<span style="color:blue using System.Runtime.InteropServices;
<span style="color:blue using System.Collections.Specialized;
<span style="color:blue using System.IO;
<span style="color:blue namespace ClipBoardMultiDistantCopy
{
<span style="color:blue public <span style="color:blue partial <span style="color:blue class frmCBMDC : Form
{
[DllImport(<span style="color:#a31515 "User32.dll")]
<span style="color:blue protected <span style="color:blue static <span style="color:blue extern <span style="color:blue int SetClipboardViewer(<span style="color:blue int hWndNewViewer);
[DllImport(<span style="color:#a31515 "User32.dll", CharSet = CharSet.Auto)]
<span style="color:blue public <span style="color:blue static <span style="color:blue extern <span style="color:blue bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext);
[DllImport(<span style="color:#a31515 "user32.dll", CharSet = CharSet.Auto)]
<span style="color:blue public <span style="color:blue static <span style="color:blue extern <span style="color:blue int SendMessage(IntPtr hwnd, <span style="color:blue int wMsg, IntPtr wParam, IntPtr lParam);
IntPtr nextClipboardViewer;
StringCollection FilePath = <span style="color:blue new StringCollection();
<span style="color:blue public frmCBMDC()
{
InitializeComponent();
nextClipboardViewer = (IntPtr)SetClipboardViewer((<span style="color:blue int)<span style="color:blue this.Handle);
}
<span style="color:blue private <span style="color:blue void Exit_Click(<span style="color:blue object sender, EventArgs e)
{
<span style="color:blue this.niMultiCopy.Visible = <span style="color:blue false;
Application.Exit();
}
<span style="color:blue protected <span style="color:blue override <span style="color:blue void WndProc(<span style="color:blue ref System.Windows.Forms.Message m)
{
<span style="color:blue const <span style="color:blue int WM_DRAWCLIPBOARD = 0x308;
<span style="color:blue const <span style="color:blue int WM_CHANGECBCHAIN = 0x030D;
<span style="color:blue switch (m.Msg)
{
<span style="color:blue case WM_DRAWCLIPBOARD:
{
<span style="color:blue string[] str;
StringCollection FilePath = <span style="color:blue new StringCollection();
str = GetClipboardData().Split(<span style="color:#a31515 ?);
<span style="color:blue foreach (<span style="color:blue string Str <span style="color:blue in str)
{
FilePath.Add(Str.ToString().Replace(<span style="color:#a31515 "\", "\\"));
}
Clipboard.SetFileDropList(FilePath);
SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);
}
<span style="color:blue break;
<span style="color:blue case WM_CHANGECBCHAIN:
<span style="color:blue if (m.WParam == nextClipboardViewer)
nextClipboardViewer = m.LParam;
<span style="color:blue else
SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);
<span style="color:blue break;
<span style="color:blue default:
<span style="color:blue base.WndProc(<span style="color:blue ref m);
<span style="color:blue break;
}
}
<span style="color:blue string GetClipboardData()
{
<span style="color:blue string str = <span style="color:blue null;
<span style="color:blue foreach (<span style="color:blue string ss <span style="color:blue in Clipboard.GetFileDropList())
str += ss+<span style="color:#a31515 "?";
<span style="color:blue return str;
}
}
}
[/code]
<br/>
<br/>
View the full article
<pre> <br/>Hello I faced a problem when I tried to watchout any Clipboard activity It gives me (The path is not of a legal form) when the program try to assign the FilePath string collection to the Clipboard file drop list. This is my code:- [/code]
<pre><span style="color:blue using System;
<span style="color:blue using System.Collections.Generic;
<span style="color:blue using System.ComponentModel;
<span style="color:blue using System.Data;
<span style="color:blue using System.Drawing;
<span style="color:blue using System.Linq;
<span style="color:blue using System.Text;
<span style="color:blue using System.Windows.Forms;
<span style="color:blue using System.Runtime.InteropServices;
<span style="color:blue using System.Collections.Specialized;
<span style="color:blue using System.IO;
<span style="color:blue namespace ClipBoardMultiDistantCopy
{
<span style="color:blue public <span style="color:blue partial <span style="color:blue class frmCBMDC : Form
{
[DllImport(<span style="color:#a31515 "User32.dll")]
<span style="color:blue protected <span style="color:blue static <span style="color:blue extern <span style="color:blue int SetClipboardViewer(<span style="color:blue int hWndNewViewer);
[DllImport(<span style="color:#a31515 "User32.dll", CharSet = CharSet.Auto)]
<span style="color:blue public <span style="color:blue static <span style="color:blue extern <span style="color:blue bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext);
[DllImport(<span style="color:#a31515 "user32.dll", CharSet = CharSet.Auto)]
<span style="color:blue public <span style="color:blue static <span style="color:blue extern <span style="color:blue int SendMessage(IntPtr hwnd, <span style="color:blue int wMsg, IntPtr wParam, IntPtr lParam);
IntPtr nextClipboardViewer;
StringCollection FilePath = <span style="color:blue new StringCollection();
<span style="color:blue public frmCBMDC()
{
InitializeComponent();
nextClipboardViewer = (IntPtr)SetClipboardViewer((<span style="color:blue int)<span style="color:blue this.Handle);
}
<span style="color:blue private <span style="color:blue void Exit_Click(<span style="color:blue object sender, EventArgs e)
{
<span style="color:blue this.niMultiCopy.Visible = <span style="color:blue false;
Application.Exit();
}
<span style="color:blue protected <span style="color:blue override <span style="color:blue void WndProc(<span style="color:blue ref System.Windows.Forms.Message m)
{
<span style="color:blue const <span style="color:blue int WM_DRAWCLIPBOARD = 0x308;
<span style="color:blue const <span style="color:blue int WM_CHANGECBCHAIN = 0x030D;
<span style="color:blue switch (m.Msg)
{
<span style="color:blue case WM_DRAWCLIPBOARD:
{
<span style="color:blue string[] str;
StringCollection FilePath = <span style="color:blue new StringCollection();
str = GetClipboardData().Split(<span style="color:#a31515 ?);
<span style="color:blue foreach (<span style="color:blue string Str <span style="color:blue in str)
{
FilePath.Add(Str.ToString().Replace(<span style="color:#a31515 "\", "\\"));
}
Clipboard.SetFileDropList(FilePath);
SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);
}
<span style="color:blue break;
<span style="color:blue case WM_CHANGECBCHAIN:
<span style="color:blue if (m.WParam == nextClipboardViewer)
nextClipboardViewer = m.LParam;
<span style="color:blue else
SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);
<span style="color:blue break;
<span style="color:blue default:
<span style="color:blue base.WndProc(<span style="color:blue ref m);
<span style="color:blue break;
}
}
<span style="color:blue string GetClipboardData()
{
<span style="color:blue string str = <span style="color:blue null;
<span style="color:blue foreach (<span style="color:blue string ss <span style="color:blue in Clipboard.GetFileDropList())
str += ss+<span style="color:#a31515 "?";
<span style="color:blue return str;
}
}
}
[/code]
<br/>
<br/>
View the full article