-1

I'm trying to use C# to make some kind of frond end. This front end will manipulate some engine files which are all text files. It's just going good with the text part but I'm trying something else that I don't know if it's possible or not.

I want the front end to execute the engine .exe file but this will appear in the current window rather than popping up in a new one. Is there a way to do this?

I tried StartInfo."something" but it seems to be something only for CMD or I'm not having any success with it(the window pop up every single time).

I would be glad if anybody could help me with this. Thanks in advice.

  • 1
    This is relevant: http://stackoverflow.com/questions/1469764/run-command-prompt-commands – Exceptyon May 29 '13 at 17:57
  • Please also check http://msdn.microsoft.com/en-us/library/system.diagnostics.processwindowstyle.aspx – ncite May 29 '13 at 18:53
  • Sorry it was not what I meant. What I exactly want is open a new program(file.exe) within the current windows without the new one popping out. Current = [ ] [ ] front end called the .exe and it popped out the front end window My goal = [[ ]] frond end calls the .exe and it started in the same window. Is that possible anyhow? I know it's a much more complex situations but somehting similar to what NRS did with Mortal Kombat Kollection. But I want to do it with only one .exe(an engine written in other language), just run it in the same window. – user2433607 May 29 '13 at 19:53

1 Answers1

0

I think you want to embed new program window in your current window?

It can be done by rewrite that program as ActiveX control. Or you can use win api SetParent in your engine.exe to set your main window frame as parent (you need to find a way to pass parent window handle to engine.exe):

SetParent(hWnd, hWndParent);

SetWindowLong(hWnd, GWL_STYLE, WS_CHILD);

SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

// or use MoveWindow

C# code to get windows handle:

Window window = Window.GetWindow(this);
var winh = new WindowInteropHelper(window);
IntPtr hWnd = winh.Handle;
ncite
  • 533
  • 1
  • 4
  • 19
  • Sorry if I'm asking too much but can you show me a better example? I never worked with this fuctions before. – user2433607 May 29 '13 at 23:39
  • Please take a look @Luke Quinaneat's reply in this post: http://stackoverflow.com/questions/758494/how-can-i-run-another-application-within-a-panel-of-my-c-sharp-program – ncite May 29 '13 at 23:52
  • Ho sorry to bother you guys so much. it led me to an awesome tutorial thank you so much. I'll eventually post here if I make it through. See ya'll – user2433607 May 30 '13 at 00:11
  • unfortunately, I haven't found a solution yet. It seems like it's not possible, only with some windows .exe(such as notpad and IE). Thank you guys anyway. – user2433607 May 30 '13 at 12:33
  • I'm trying to use the SetParent but it seems like XNA projetcs does not use System.Windows namespace. Any hint? – user2433607 May 30 '13 at 14:33
  • I think the inter-process embed tricks won't work for XNA. Maybe you are asking for this kind of implementation? http://stackoverflow.com/questions/8747535/embeding-a-xna-game-in-a-windows-form-user-control – ncite May 30 '13 at 20:00