在Windows窗体面板中运行的外部程序窗口(VB.NET) [英] External program window running within windows form panel (VB.NET)

查看:555
本文介绍了在Windows窗体面板中运行的外部程序窗口(VB.NET)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



VB.Net相当新手,过去十年一直与Mac合作,但到目前为止享受它。



我正在尝试在Windows窗体面板中显示一个外部程序窗口,用于我正在为单个用户桌面工作的概念验证项目(我们的想法是使用ActiveX正确执行或在浏览器中重建外部程序,如果我们获得批准/资源继续)。



以下代码适用于Chrome,但用户尚未打开实例,但我有三个问题:



1)内容没有缩放到面板大小(虽然像写字板或记事本这样的东西)

2)任何需要一段时间才能加载或具有闪屏或多个的程序窗户不工作,只是在我的表格外打开



我尝试过的事情:



Hi All,

Fairly new to VB.Net, having worked with Macs for the last ten years but enjoying it so far.

I'm trying to get an external program window to display within a windows form panel for a proof of concept project I'm working on for a single user desktop (idea is to do it properly with ActiveX or rebuilding the external program in a browser if we get approval/resource to go ahead).

The code below works for Chrome providing the user doesn't already have an instance open but I have three issues:

1) the content is not scaling to the panel size (though things like Wordpad or Notepad do)
2) Any program that takes a while to load or has a splash screen or multiple windows isn't working and just opens outside of my form

What I have tried:

Option Strict On
Option Explicit On
Imports System.Threading
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("Chrome.exe")
        proc.WaitForInputIdle()
        proc.WaitForExit(1000)
        SetParent(proc.MainWindowHandle, Panel1.Handle)
        SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
    End Sub
End Class

推荐答案

从您自己的观察中可以明显看出,应用程序对容器的意识以及它们的响应方式不同(而不是回复)。



同样适用于浏览器和内容。



您需要针对每个异常进行定制。
It should be obvious from your own observations that apps differ in their "awareness" of their "containers" and how they respond (and not respond).

Same applies to browsers and content.

You need to tailor for each exception.


嗨Gerry,



对于任何混淆表示歉意,很明显,我希望能够对如何最好的帐户有所了解对于我提到的情况。
Hi Gerry,

Apologies for any confusion, it is obvious, I was hoping for some insight on how best to account for the situations I've mentioned.


这篇关于在Windows窗体面板中运行的外部程序窗口(VB.NET)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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