Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Game Engine Import
#1
I am trying to make a game making software run in a panel in my program. what happens now is that when my program starts, the game maker opens in its own window; I want it to open in my panel. Can someone tell me how to make it either run where it is in the panel and can have other buttons surrounding it or what I need to use to make it run INSIDE my program. I used the code

Code:
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
        System.Diagnostics.Process.Start("C:\Program Files (x86)\Unity\Editor\unity.exe")
    End Sub
#2
In order to open an extarnal program you need to get it's handle and change it and to do that you need to use 2 functions SetParent and ShowWindow , and 1 const SW_MAXIMIZE

[code2=vbnet]Declare Function ShowWindow Lib "user32" (ByVal hWnd As System.IntPtr, ByVal nCmdShow As Integer) As Boolean
Declare Function SetParent Lib "user32" (ByVal hWndChild As System.IntPtr, ByVal hWndNewParent As System.IntPtr) As System.IntPtr
Private Const SW_MAXIMIZE As Integer = 3[/code2]

Now you used Panel1.Paint event witch is the worst event to use because everytime the panel is redrawwn it will open the program again and again . I sugest using either a button or the form load event. Here is the code to open the program in your pannel

[code2=vbnet]Dim pinfo As New ProcessStartInfo("C:\Program Files (x86)\Unity\Editor\unity.exe")
Dim p As Process = System.Diagnostics.Process.Start(pinfo)
System.Threading.Thread.Sleep(50)

SetParent(p.MainWindowHandle, Me.Panel1.Handle)
ShowWindow(p.MainWindowHandle, SW_MAXIMIZE)[/code2]

The code above should do the trick.
Sssssssssoftware developer...


Possibly Related Threads…
Thread Author Replies Views Last Post
  Visual Basic Game Atri 3 15,801 09-05-2012, 02:57 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)