Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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#
Posted
Comments
Dave Kreskowiak 8-Feb-12 23:41pm    
This doesn't make sense. What do you mean EXACTLY by:
"that allows the user to drag and drop a window into my application". To what purpose??

"and lock my application's window to keep it from hiding in the background or minimize" Why? For what purpose??
MR. AngelMendez 9-Feb-12 0:04am    
I thought it was clear enough, You see when your playing a MMO you cant pause the game therefore you are pretty much vulnerable if you have to tab in order to look at another window. A lot of programs don't support features that allows you to keep the window from hiding in the background, so by dragging a window for example a media player playing a song into my application's window I will be able to keep my window from minimizing or hiding, thus allowing me to control the media player while keeping track of the game.

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.
 
Share this answer
 
Comments
MR. AngelMendez 9-Feb-12 22:19pm    
Thanks, I'm glad you finally understand. I did some diagnostics on what you said and it seems like the game allows some options that enable it to be windowed instead of full screen. So no problem there, it displays the form first when switched to those settings. Even if I don't need to make this program anymore I can tell it will be handy to know its functionality and plus it might be more convenient in other games or programs. So its a go, if your still willing to help out.
Dave Kreskowiak 9-Feb-12 22:35pm    
You don't need the code snippet that was posted. All you need is http://msdn.microsoft.com/en-us/library/windows/desktop/ms633541(v=vs.85).aspx

That will let you set the parent window of any window to a control on your form, usually a Panel. Getting the window handle of a control is easy. Every control has a Handle property that contains its own window handle. That's going to be your Parent parameter.

Dragging a window on top of your form is not something I've done. Should be easy enough to find with a little Google though.
MR. AngelMendez 10-Feb-12 22:42pm    
I'm so dumb lol, I was searching for the solution online(which was not successful) and realized that instead of trying to dock a program into mines why not open the program within mines. Do you know how this could be done? I've done some research and haven't found anything yet. Thanks,
Dave Kreskowiak 11-Feb-12 7:53am    
You cannot launch an app inside your own. You can launch an app, wait for its window to be created, then use SetParent (the link I posted above) on it.
MR. AngelMendez 11-Feb-12 14:07pm    
I found a way to capture windows in my program in this link http://stackoverflow.com/questions/758494/how-can-i-run-another-application-within-a-panel-of-my-c-sharp-program

But I noticed that I can only capture simple things like notepad and cmd but not windows media player and others(most likely because they don't support that function). The link that you sent me is kind of confusing to me and I'm not sure how to implement the code. If your link can do any type of program then could you show an example and explain it to me?
Hi,

1. Just input this code in your form code behind:
C#
//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. Input a Panel in your form as your title bar.
C#
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.
 
Share this answer
 
v3
Comments
MR. AngelMendez 9-Feb-12 0:13am    
hey sayrecollado, I'm not sure if I put your code in the right place but I seem to be getting some errors, here is the full code.

Thanks,


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;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

}
//Drag Forms w/out titlebar
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
(error on this line) [DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd,
int Msg, int wParam, int lParam);
(error on this line) [DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
//End

private void Form1_Load(object sender, EventArgs e)
{

}





}
}


the error says the type or namespace could not be found.
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
 
Share this answer
 
Comments
MR. AngelMendez 9-Feb-12 7:25am    
lol I can tell you guys haven't played MMOs wich means massive multiplayer online. Pretty much you play the game in a server which players from all over the world can connect and play. you just can't pause the game, have you ever played world of Warcraft? That's pretty much why I want to make this app.
AmitGajjar 12-Feb-12 23:19pm    
Hehe, i never played such games... :)

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