在flashscreen之后打开表单中的应用程序? - Vb.net [英] Opening an application in form after flashscreen? - Vb.net

查看:58
本文介绍了在flashscreen之后打开表单中的应用程序? - Vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨:)



我正在创建一种虚拟盒(我只是想学习迷你项目和东西)。我找到了一种在Windows窗体的维度内打开应用程序的方法。所以,一旦我认为我找到了解决方案,我开始在不同的应用程序上进行测试;它适用于记事本,firefox等(它们都在表单内打开)。但是,我在一个视频游戏(RuneScape [不判断lel])上尝试了它,并且只在表单中打开了启动画面。一旦启动屏幕加载了游戏的资源,并且主客户端/游戏进程开始,客户端就会在框外打开。在任务管理器中,似乎启动器和客户端进程相互依赖(即如果我杀死rs2client.exe并让runescape.exe运行,它们都会自杀并且游戏死亡 - 反之亦然)。我是如何制作的,以便在启动画面后打开的窗口(主游戏客户端)保留在表单中,就像启动画面一样?



这是我目前的代码:

 选项 严格 开启 
选项 明确 < span class =code-keyword> On
公共 Form1
声明自动功能 SetParent Lib user32.dll ByVal hWndChild 作为 IntPtr ByVal hWndNewParent 作为 IntPtr 作为 整数
声明自动功能 SendMessage Lib user32.dll ByVal hWnd 作为 IntPtr ByVal 消息 As 整数 ByVal wParam 作为 整数 ByVal lParam 作为 整数作为 整数
私人 Const WM_SYSCOMMAND 作为 整数 = 274
私有 Const SC_MAXIMIZE As 整数 = 61488
Dim proc 作为处理
私有 Sub Form1_Load(发件人作为 对象,e As EventArgs)句柄 MyBase .Load
proc = Process.Start( C:\Program Files\Jagex\RuneScape Launcher\runescape.exe
proc.WaitForInputIdle()
proc.WaitForExit( 1000
SetParent(proc.MainWindowHandle,Panel1.Handle)
结束 Sub
结束 Class





我尝试过:



我试过这个(可能是一个非常糟糕的尝试解决方案):

 选项 严格  
选项 明确 开启
公开 Form1
声明自动功能 SetParent Lib user32.dll ByVal hWndChild 正如 IntPtr ByVal hWndNewParent As IntPtr 作为 整数
声明自动功能 SendMessage Lib user32.dll ByVal hWnd 作为 IntPtr ByVal 消息 As 整数 ByVal wParam As 整数 ByVal lParam 作为 整数作为 整数
私有 Const WM_SYSCOMMAND 作为 整数 = 274
私有 Const SC_MAXIMIZE 作为 整数 = 61488
Dim proc 作为处理
私人 < span class =code-keyword> Sub Form1_Load(sender As Object ,e < span class =code-keyword> As EventArgs)句柄 MyBase .Load
proc = Process.Start( C:\ Program Files \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ $ b proc.WaitForExit( 1000
SetParent(proc.MainWindowHandle,Panel1.Handle)
proc = Process.Start( C:\ProgramData \Jagex \ Launcher \rs2client.exe
proc.WaitForInputIdle ()
proc.WaitForExit( 1000
SetParent(proc.MainWindowHandle,Panel1.Handle)
结束 Sub
结束 班级





非常感谢您的帮助!如果你给出了一个非常复杂的答案,我不知道如何实际实现,请准备好忍受我的经验(我正在努力学习xD)!

解决方案

< blockquote>问题不是你的代码,而是你试图放在窗口中的游戏。



大多数游戏默认运行在全屏中。这意味着他们不会绘制到窗口,而是直接绘制到屏幕上。没有窗口可以放入你的窗口。



游戏必须支持窗口模式。如果没有,你就不会让它发挥作用。一个游戏正在绘制到一个窗口,然后你可以获得窗口句柄并将父窗口设置为你的窗口。


Hi :)

I'm creating a kind of virtualbox (I'm just trying to learn with mini-projects and stuff). I've found a way to open applications within the dimensions of the windows form. So once I thought I had found a solution for this, I began testing it on different applications; it works with notepad, firefox, etc (they all open within the form itself). However, I tried it on a video game (RuneScape [don't judge lel]) and only the splash screen opened in the form. Once the splash screen had loaded the game's resourced, and the main client/game process started, the client opened outside of the box. In the task manager, it seems like the launcher and the client process rely on one another (i.e. if I kill rs2client.exe and leave runescape.exe running, both kill themselves and the game dies - and vice versa). How do I make it so that the window (main game client) that opens after the splash screen remains inside the form, just as the splash screen did?

This is my current code:

Option Strict On
Option Explicit On
Public Class Form1
    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
    Private Const WM_SYSCOMMAND As Integer = 274
    Private Const SC_MAXIMIZE As Integer = 61488
    Dim proc As Process
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        proc = Process.Start("C:\Program Files\Jagex\RuneScape Launcher\runescape.exe")
        proc.WaitForInputIdle()
        proc.WaitForExit(1000)
        SetParent(proc.MainWindowHandle, Panel1.Handle)
    End Sub
End Class



What I have tried:

I've tried this (probably a very ill attempt for a solution):

Option Strict On
Option Explicit On
Public Class Form1
    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
    Private Const WM_SYSCOMMAND As Integer = 274
    Private Const SC_MAXIMIZE As Integer = 61488
    Dim proc As Process
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        proc = Process.Start("C:\Program Files\Jagex\RuneScape Launcher\runescape.exe")
        proc.WaitForInputIdle()
        proc.WaitForExit(1000)
        SetParent(proc.MainWindowHandle, Panel1.Handle)
        proc = Process.Start("C:\ProgramData\Jagex\Launcher\rs2client.exe")
        proc.WaitForInputIdle()
        proc.WaitForExit(1000)
        SetParent(proc.MainWindowHandle, Panel1.Handle)
    End Sub
End Class



Thanks so much for any help! If you give a really complicated answer, that I don't know how to actually implement, be prepared to endure my inexperience (I'm trying to learn xD)!

解决方案

The problem is not your code, but the game you're trying to put in your window.

Most games run, by default, in "fullscreen". Meaning they don't draw to a window but draw directly to the screen. There is no window to "put in your window".

The game has to support "windowed" mode. If it doesn't, you're not going to get this to work. One the game is drawing to a window, you can then get the window handle and set the parent to your window.


这篇关于在flashscreen之后打开表单中的应用程序? - Vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆