如何将窗口拖放到我的应用程序? [英] how to drag and drop a window to my application?

查看:68
本文介绍了如何将窗口拖放到我的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在玩一款需要全屏才能运行的游戏,但我也想听一些音乐或在一边做其他事情.但是为了在窗口之间切换,我不得不将游戏置于无人看管的状态,这在玩MMO时很糟糕(任何事情都可能在不到一秒钟的时间内发生),所以我在考虑开发一款允许用户拖放游戏的应用程序进入我的应用程序窗口并锁定我的应用程序窗口,以防止它隐藏在后台或最小化.这可能吗?如果是这样,该怎么办?


Windows 7操作系统,可视化编程语言C#

Hi, I am playing a game that requires full screen in order to run but I also want to listen to some music and or do other things on the side. but in order to switch between windows I would have to leave the game unattended which is bad when your playing an MMO(anything can happen in less than a second)So I was thinking of making an app that allows the user to drag and drop a window into my application and lock my application''s window to keep it from hiding in the background or minimize. Is this possible? if so, how can this be done?


operating system windows 7, programing language visual C#

推荐答案

好,我知道您现在正在做什么.首先,您MMO可以全屏播放吗?如果是这样,您就遇到了问题. DirectX将不断重绘屏幕,从而完全覆盖您放置在屏幕上方的任何窗口,使其消失.

不过,您可能会摆脱这种情况.要测试这一切,您需要做的是创建一个空白表单,将其TopMost属性设置为True,启动它,然后播放您的MMO.如果您的窗口消失了,那么您甚至在开始之前就沉没了.
OK, I see what you''re doing now. First, does you MMO play fullscreen?? If so, you''ve got a problem. DirectX will constantly be redrawing the screen, thereby completely overdrawing any window you put on top of it, making it vanish.

You might get away with this though. All you have to do to test this is create a blank form, set it''s TopMost property to True, launch it, then play your MMO. If your window disappears, your sunk before you even get started.


您好,

1.只需在下面的表单代码中输入此代码即可:
Hi,

1. Just input this code in your form code behind:
//Drag Forms w/out titlebar
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd,
int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
//End



2.在表单中输入一个面板作为标题栏.



2. Input a Panel in your form as your title bar.

private void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}





希望这一点对您有所帮助.

谢谢.





I hope this one can help.

Thank You.




只是一个建议,当用户切换到其他应用程序时您不能暂停游戏吗?对用户不好吗?

谢谢
-Amit
Hi,

just a suggestion, can''t you pause game when user switch to other application ? isn''t it will be good for users?

Thanks
-Amit


这篇关于如何将窗口拖放到我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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