It is currently Mon Dec 11, 2017 11:30 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Oct 26, 2017 10:10 am 
Offline
Snes9x White Belt

Joined: Thu Oct 26, 2017 9:57 am
Posts: 2
Hi every one Noob here I have set up a computer to run a couple of games but I want to have like my own front end for it where it nests buttons to launch each game by terminating snes9x and then relaunching but with the game in a panel on a vb form.

The only thing I am having trouble with is nesting the snes9x window into the panel and I feel i'm missing something very simple I have gotten the kill and launch working but not the nesting any one got any surjections or snippets of code that I could try?

Sorry the code is messy but the button2_click works and with button1_click is where I have been trying different bits of coding that I have found round the internet (well pretty much all of it is snippets from the internet)

Code:
Public Class Form1
    Private Const WM_SYSCOMMAND As Integer = 274
    Private Const SC_MAXIMIZED As Integer = 61488
    Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
    Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

    Public Sub KillProcess(ByVal processName As String)

        On Error GoTo ErrHandler

        Dim oWMI
        Dim ret
        Dim sService
        Dim oWMIServices
        Dim oWMIService
        Dim oServices
        Dim oService
        Dim servicename

        oWMI = GetObject("winmgmts:")
        oServices = oWMI.InstancesOf("win32_process")

        For Each oService In oServices

            servicename = LCase(Trim(CStr(oService.Name) & ""))

            If InStr(1, servicename, LCase(processName), vbTextCompare) > 0 Then
                ret = oService.Terminate
            End If

        Next

        oServices = Nothing
        oWMI = Nothing

ErrHandler:
        Err.Clear()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        KillProcess("snes9x")
        Dim proc As System.Diagnostics.Process
        proc = Process.Start("C:\Users\SNES_Machine_002\Desktop\Aero the Acro-Bat (USA).sfc")
        proc.WaitForInputIdle()
        SetParent(proc.MainWindowHandle, Me.Panel1.Handle)
        SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)

    End Sub

    Private Sub Button2_click(sender As Object, e As EventArgs) Handles Button2.Click
        KillProcess("snes9x")
        Process.Start("C:\Users\SNES_Machine_002\Desktop\Aladdin (U) [!].smc")
    End Sub
End Class


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 27, 2017 10:55 am 
Offline
Snes9x White Belt

Joined: Thu Oct 26, 2017 9:57 am
Posts: 2
Ok just a quick update to where I am.

I have Downloaded the source code and I'm going to try and figure out which code I will need to call to render the screen and to load roms but if any one has any knowledge on all of this then please let me know as anything will be a great help.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group