Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i wrote a code for capture my mouse in panel use user32.dll and SetCapture() method:
C#
[DllImport("user32.dll")]
        static extern IntPtr SetCapture(long hWnd);
        [DllImport("user32.dll")]
        static extern long ReleaseCapture();

and in my button write like:
SetCapture(panel1.Handle);

but it dont work for me...
any idea..?
Posted

1 solution

Did you resolved?

you must use :
using System.Runtime.InteropServices;

and declare :
C#
[DllImport("user32.dll")]
static extern IntPtr SetCapture(long hWnd);

[DllImport("user32.dll")]
static extern long ReleaseCapture();


inside class declaration, where you will use or use like
GenericClass.SetCapture(Control.Handle)
if used as shared function (must be public ofcourse) and use like you write above.

Regards!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900