Bonjour à tous,
Voila, mon petit problème est de pouvoir déplacer un contrôle,ex: un bouton, a l'aide de la souris. J'ai déjà un code qui fonctionne très bien, le voici :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace déplacement_objet { public partial class Form1 : Form { private const int HTCAPTION = 0x2; private const int WM_NCLBUTTONDOWN = 0xA1; [DllImport("User32.dll")] public static extern bool ReleaseCapture(); [DllImport("User32.dll")] public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); public Form1() { InitializeComponent(); } private void button1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { ReleaseCapture(); SendMessage(this.button1.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0); } } } }
Le problème est que mon patron ne souhaite pas avoir recours a l'importation de la dll User32.dll
Quelqu'un aurait-il une solution autre que celle la SVP?
Merci de m'aider si vous le pouvez...![]()
Partager