c#中的setcapture()方法 [英] setcapture() method in c#

查看:792
本文介绍了c#中的setcapture()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
i在面板中使用user32.dll和SetCapture()方法编写了捕获鼠标的代码:

hi i wrote a code for capture my mouse in panel use user32.dll and SetCapture() method:

[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..?

推荐答案

你有没有解决?



你必须使用:

Did you resolved?

you must use :
using System.Runtime.InteropServices;



并声明:


and declare :

[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!


这篇关于c#中的setcapture()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆