键盘应用程序中的SetWindowLong和GetWindowLong [英] SetWindowLong and GetWindowLong in keyboard application

查看:107
本文介绍了键盘应用程序中的SetWindowLong和GetWindowLong的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个键盘应用程序.有人请解决这个问题吗? ?我的猜测是即时通讯使用user32.dll SetWindowLong和GetWindowLong ....
[DllImport("user32.dll"))
公共静态外部IntPtr GetActiveWindow();
[DllImport("user32.dll"))
公共静态外部int SetWindowLong(IntPtr hWnd,int nIndex,IntPtr dwNewLong);

在window_loaded
中的以下代码中声明了此代码
const int GWL_EXSTYLE =(-20);
GetWindowLong(HWND,GWL_EXSTYLE);
SetWindowLong(HWND,GWL_EXSTYLE,(IntPtr)(0x8000000));

im trying to create one keyboard application..everythin is fine but if i drag the the keyboard ,its dragging fine but only after i release the mouse..i want that to drag along with the mouse..so can anyone pls solve this issue ? ? my guess is im using user32.dll SetWindowLong and GetWindowLong....here is the prob..jus tel me an alternate way for tat dll..

[DllImport("user32.dll")]
public static extern IntPtr GetActiveWindow();
[DllImport("user32.dll")]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);

Declared this below code in window_loaded

const int GWL_EXSTYLE = (-20);
GetWindowLong(HWND, GWL_EXSTYLE);
SetWindowLong(HWND, GWL_EXSTYLE, (IntPtr)(0x8000000));

推荐答案

永远不要使用P/Invoke解决诸如鼠标拖动之类的简单问题. 常规的鼠标事件和简单的逻辑足以将其用纯.NET编写.只需尝试一下.发布您的代码,并在遇到问题时说明问题.

请理解,通过使用P/Invoke,您将大大降低代码质量.您将失去与纯.NET的跨平台兼容性.我在Linux上运行Window .NET应用程序时无需重新编译(也无需用鼠标拖动:-)),这真是太好了.我是否使用过一种P/Invoke方法-我将失去这种可能性.

(此外,您无法从尝试使用的Windows API函数中获得任何有用的行为.您的想法是什么?解决问题没有什么用.)

祝你好运,
—SA
You should never use P/Invoke to solve such a simple problem as dragging with the mouse. Regular mouse events and simple logic is quite enough to write it in pure .NET. Just give it a try. Post you code and explain the problem if you face one.

Please understand that by using P/Invoke you dramatically compromise the quality of your code. You would loose cross-platform compatibility you have with pure .NET. I run my Window .NET applications on Linux without recompilation (and with dragging by mouse :-)), and this is wonderful. Has I used a single P/Invoke method — I would have lost this possibility.

(Besides you cannot get any useful behavior from the Windows API functions you''re trying to use. What''s you idea? There is nothing useful for solving your problem.)

Good luck,
—SA


这篇关于键盘应用程序中的SetWindowLong和GetWindowLong的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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