using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace CSharp_GeographyGame { public partial class presidentsnamesForm : Form { public const int WM_NCLBUTTONDOWN = 0xA1; public const int HT_CAPTION = 0x2; [System.Runtime.InteropServices.DllImport("user32.dll")] public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); [System.Runtime.InteropServices.DllImport("user32.dll")] public static extern bool ReleaseCapture(); public presidentsnamesForm() { InitializeComponent(); } private void lbPresNames_KeyDown(object sender, KeyEventArgs e) { if (e.Control == true && e.KeyCode == Keys.C) { string s = lbPresNames.SelectedItem.ToString(); Clipboard.SetData(DataFormats.StringFormat, s); e.SuppressKeyPress = true; // important function which prevents jump from copied name to the next name beginning with the same letter } } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } private void panel1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { ReleaseCapture(); SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); } } } }