作为启动RDP程序运行时,如何停止初始形式最大化? [英] How to stop initial form maximising when run as startup RDP program?

查看:147
本文介绍了作为启动RDP程序运行时,如何停止初始形式最大化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的VB6应用程序中的启动表单在终端服务(远程桌面)会话中启动时表现异常,主机和客户端均为XP Pro计算机.表单本来应该居中,但实际上是最大化的,其内容位于左上角,看起来很奇怪.请注意,只有在RDP客户端的程序"选项卡下的在连接时启动以下程序"字段中使用了应用程序路径时,才会发生这种情况.

The startup form in my VB6 app is behaving strangely when started in a Terminal Services (Remote Desktop) session, with both the host and client being XP Pro machines. The form is meant to be centered but it actually maximises and its content goes to the top left and it looks very strange. Note, this only happens when the app path is used for the "Start the following program on connection" field under the Program tab in the RDP client.

如果您正在运行具有TS配置工具的服务器,显然有一个解决方案:

Apparently there is a solution if you are running Server which has TS Configuration tool: http://www.windows-server-answers.com/microsoft/Windows-Terminal-Services/29117908/start-program-on-connection--it-isnt-centered.aspx

但是两台机器都是XP Pro,所以我无法获得TS配置.

But both machines are XP Pro so I can't get TS Configuration.

在此处查看示例VB6项目:链接到Google文档上的zip文件

See example VB6 project here: Link to zip file on Google Docs

如果仅创建上述项目的EXE(正常运行时将以居中的非最大化形式运行),并在程序"选项卡下的在连接时启动以下程序"字段中设置时使用此EXE路径. RDP客户端,您会发现该应用程序以最大化的形式开始,其内容在左上角.

If you simply create an EXE of the above project (which runs with a centered non-maximised form when run normally), and use this EXE path when setting the "Start the following program on connection" field under the Program tab in the RDP client, you will find that the app starts with the form maximised with its content in the upper left.

推荐答案

显然,终端服务器正在使用

Apparently Terminal Server is starting your startup application with ShellExecute function, passing SW_MAXIMIZE for nShowCmd instead of SW_SHOWDEFAULT.

您可以在Form_Resize这样的事件中通过简单的修改来解决它

You can fix it with a simple hack in Form_Resize event like this

Option Explicit

Private m_bActivated            As Boolean

Private Sub Command_Click()

Me.Text = "HELLO"

End Sub

Private Sub Form_Resize()
    If Not m_bActivated Then
        m_bActivated = True
        WindowState = vbNormal
    End If
End Sub

这篇关于作为启动RDP程序运行时,如何停止初始形式最大化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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