12 Replies - 1277 Views - Last Post: 31 May 2013 - 09:10 AM Rate Topic: -----

#1 BlackCyraxCO   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 30-May 13

Question: How do I host a another application in my game window?

Posted 30 May 2013 - 08:55 AM

Hello! I've been searching for a way to embed a external app window in my game in XNA. What I exactly want to do is put .exe window, which was "called" by the game, inside of the game window. I've seen and done it with notepad but only with windows form app(I opened a notepad within the windows form). But as you know we can't use System.Windows namespace in a XNA framework project. Well, as it is written here, I don't want the pre-written code, I would like somebody to point a way out for this. What could I use to make ti possible?

Here more explanations:

I want it to use in a front end I'm building for a fighting engine called MUGEN. Which has its files all in texts and that's how I will manipulate it. And also using some command lines, my goal is to make the engine a little better, this part I've figured out, the only thing that is bothering me is this "hosted window" part.

If anyone could point me a way through this I'd be thankful.

Is This A Good Question/Topic? 0
  • +

Replies To: Question: How do I host a another application in my game window?

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14096
  • View blog
  • Posts: 56,495
  • Joined: 12-June 08

Re: Question: How do I host a another application in my game window?

Posted 30 May 2013 - 09:08 AM

Why exactly would a game throw up a command line prompt? Wouldn't you manipulate the external script files and then start the engine - not quite change them as they are being used?
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6220
  • View blog
  • Posts: 21,469
  • Joined: 05-May 12

Re: Question: How do I host a another application in my game window?

Posted 30 May 2013 - 09:56 AM

Wouldn't you be better off with xnaMUGEN ( https://code.google.com/p/xnamugen/ ) instead of trying to make MUGEN ( http://www.elecbyte.com/mugen ) a program that wasn't meant to run in XNA run within XNA?

This post has been edited by Skydiver: 30 May 2013 - 09:56 AM

Was This Post Helpful? 0
  • +
  • -

#4 BlackCyraxCO   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 30-May 13

Re: Question: How do I host a another application in my game window?

Posted 30 May 2013 - 11:17 AM

View Postmodi123_1, on 30 May 2013 - 09:08 AM, said:

Why exactly would a game throw up a command line prompt? Wouldn't you manipulate the external script files and then start the engine - not quite change them as they are being used?



It makes the game goes right to the fight without going to title neither select screen WHICH in mugen are LAME coded unfortunately. You can use command lines to manipulate which chars will fight, how much AI level stage and so on. All I want is a way for XNA(C#) to OPEN mugen window in the XNA game window(share the same). I've already done the other parts all I need is a hint on how it is supposed to work. It's possible with windows forms, it stays in "idle" state while the program is simply running using the same window.

View PostSkydiver, on 30 May 2013 - 09:56 AM, said:

Wouldn't you be better off with xnaMUGEN ( https://code.google.com/p/xnamugen/ ) instead of trying to make MUGEN ( http://www.elecbyte.com/mugen ) a program that wasn't meant to run in XNA run within XNA?


It will not "RUN" in XNA all I want is SHARE the same window I have seen something similar in windows forms applications where it runs external apps hosted in the window form. The problem is XNA network project does not use System.Windows which is where the methods that I saw are(id there is a way I could like to know).

Rsuming: all I want to know is a way for XNA game window SHARE the same .exe window that it is supposed to call.

PS.: I've seen this xnaMUGEN but still I'd be stuck the same way. and this mugen version got too much bugs the new mugen versions don't(xnaMUGEN doesn't even open some times).

Thank you so much guys for taking some time to answer.
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6220
  • View blog
  • Posts: 21,469
  • Joined: 05-May 12

Re: Question: How do I host a another application in my game window?

Posted 30 May 2013 - 11:31 AM

View PostBlackCyraxCO, on 30 May 2013 - 02:17 PM, said:

It will not "RUN" in XNA all I want is SHARE the same window I have seen something similar in windows forms applications where it runs external apps hosted in the window form.

Yes like krazyshank is doing with the flash player in this other thread: http://www.dreaminco...arent-children/

There is nothing magical about the System.Windows namespace other than in saves you a lot of typing. You could make the same Win32 API call to SetWindowParent(), assuming that XNA lets you call Win32 APIs. http://msdn.microsof...1(v=vs.85).aspx
Was This Post Helpful? 0
  • +
  • -

#6 BlackCyraxCO   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 30-May 13

Re: Question: How do I host a another application in my game window?

Posted 30 May 2013 - 11:48 AM

Quote

Yes like krazyshank is doing with the flash player in this other thread: http://www.dreaminco...arent-children/

There is nothing magical about the System.Windows namespace other than in saves you a lot of typing. You could make the same Win32 API call to SetWindowParent(), assuming that XNA lets you call Win32 APIs. http://msdn.microsof...1(v=vs.85).aspx



Hum. yeah but this SetParent always gives an error saying that "it doesn't exist in the current context". Which name space is it from?

This post has been edited by JackOfAllTrades: 30 May 2013 - 03:00 PM
Reason for edit:: Fixed quote tags

Was This Post Helpful? 0
  • +
  • -

#7 Momerath   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1021
  • View blog
  • Posts: 2,463
  • Joined: 04-October 09

Re: Question: How do I host a another application in my game window?

Posted 30 May 2013 - 01:37 PM

It's not in a namespace, it's a Win32 API call. You'll need to use P/Invoke to access it.
Was This Post Helpful? 1
  • +
  • -

#8 Curtis Rutland   User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5103
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Question: How do I host a another application in my game window?

Posted 30 May 2013 - 01:53 PM

This page might give you a better idea:

http://pinvoke.net/d.../SetParent.html

Again, this is assuming you can use System.Runtime.InteropServices (from mscorlib.dll) I don't know what XNA does/doesn't support from the Framework.
Was This Post Helpful? 1
  • +
  • -

#9 BlackCyraxCO   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 30-May 13

Re: Question: How do I host a another application in my game window?

Posted 30 May 2013 - 06:03 PM

View PostCurtis Rutland, on 30 May 2013 - 01:53 PM, said:

This page might give you a better idea:

http://pinvoke.net/d.../SetParent.html

Again, this is assuming you can use System.Runtime.InteropServices (from mscorlib.dll) I don't know what XNA does/doesn't support from the Framework.


View PostCurtis Rutland, on 30 May 2013 - 01:53 PM, said:

This page might give you a better idea:

http://pinvoke.net/d.../SetParent.html

Again, this is assuming you can use System.Runtime.InteropServices (from mscorlib.dll) I don't know what XNA does/doesn't support from the Framework.


I didn't know about P/invoke Now I understand how it is supposed to work I'm gonna try as soon I can and post here what I got. Thank you two very much.
Was This Post Helpful? 0
  • +
  • -

#10 BlackCyraxCO   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 30-May 13

Re: Question: How do I host a another application in my game window?

Posted 30 May 2013 - 09:34 PM

Unfortunately I'm still too "newbie" in this P/invoke I was trying what I saw in this post LINK But somethings are not recognized and it keeps saying that it doesn't exist in the current context. I'll keep searching I'm sure it's possible. Thanks for wasting you time on my question guys, unfortunately it was not meant for this time. :P
Was This Post Helpful? 0
  • +
  • -

#11 BlackCyraxCO   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 30-May 13

Re: Question: How do I host a another application in my game window?

Posted 31 May 2013 - 07:08 AM

Hello again! I've got it guys the MUGEN window starts inside of the game window. I'm searching here for an another thing. I don't know if it is possible. Is there a way to remove the child window buttons? ( [-][■][X] ) If not I'm also searching a way to make the child window unmovable at least. Then, I remove the parent window ones and set it to close if the child window was closed(if there is way to of course XD).

This is what I'm using so far:
Import:
[DllImport("user32.dll", CharSet = CharSet.Auto)]
        static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);

        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

        [DllImport("user32.dll")]
        static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

        [DllImport("user32.dll", SetLastError = true)]
        private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint);

        const int WM_SYSCOMMAND = 274;
        const int SC_MAXIMIZE = 61488;


Executing:
proc = Process.Start(
        new ProcessStartInfo()
        {
        FileName = @"C:\..\mugen.exe",
        Arguments = "-p1 ??? -p2 ??? -rounds 2",
        WindowStyle = ProcessWindowStyle.Maximized
        });
        Thread.Sleep(1000);
        ShowWindow(proc.MainWindowHandle, 0);
        SetParent(proc.MainWindowHandle, window.Handle);
        ShowWindow(proc.MainWindowHandle, 1);
        SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);

Was This Post Helpful? 0
  • +
  • -

#12 BlackCyraxCO   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 30-May 13

Re: Question: How do I host a another application in my game window?

Posted 31 May 2013 - 09:04 AM

I got it guys. Thank you very much!
Was This Post Helpful? 0
  • +
  • -

#13 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14096
  • View blog
  • Posts: 56,495
  • Joined: 12-June 08

Re: Question: How do I host a another application in my game window?

Posted 31 May 2013 - 09:10 AM

What did you do to get it working? Did you get the buttons removed, or just make it immovable?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1