AxMSTSCLib全屏模式最小化后在任务栏中消失

4

我正在使用AxMSTSCLib开发一个Windows应用程序来创建RDP连接。

以下列出的步骤会导致我的远程桌面显示消失:

  1. 以全屏模式启动RDP连接
  2. 从连接栏中单击“还原”按钮
  3. 再次单击“最大化”按钮以重新进入全屏模式
  4. 单击“最小化”按钮
  5. 然后我的应用程序消失了,我无法在任务栏中看到它(但仍会在任务管理器中列出/运行)

enter image description here

如果我跳过步骤2和3,当我从连接栏中单击“最小化”按钮时,它不会消失,这真的很奇怪。

我在这里发布了部分代码,希望有人能帮我找出问题所在。

public partial class RdpShowForm : Form
{
  public AxMSTSCLib.AxMsRdpClient9NotSafeForScripting oRemote;
  public RdpShowForm()
  {
    InitializeComponent();
    oRemote = new AxMSTSCLib.AxMsRdpClient9NotSafeForScripting();
    ((System.ComponentModel.ISupportInitialize)(this.oRemote)).BeginInit();
    oRemote.Dock = System.Windows.Forms.DockStyle.Fill;
    oRemote.Enabled = true;
    oRemote.Name = "WindowsVM";
    this.Controls.Add(oRemote); // Controls contains 'panel1' and 'oRemote'
    ((System.ComponentModel.ISupportInitialize)(this.oRemote)).EndInit();            
    oRemote.CreateControl();
    this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
  }

  private void RdpShowForm_Load(object sender, EventArgs e)
  {
    NewRdpConnectionInstance();
  }

  private void NewRdpConnectionInstance()
  {
    oRemote.Server = 'xxx';
    ...
    oRemote.FullScreen = true;
    oRemote.AdvancedSettings7.DisplayConnectionBar = true;
    oRemote.AdvancedSettings7.ConnectionBarShowMinimizeButton = true;
    oRemote.AdvancedSettings7.ConnectionBarShowRestoreButton = true;
    oRemote.OnConnected += rdpClient_OnConnected;
    oRemote.OnLeaveFullScreenMode += rdpClient_OnLeaveFullScreenMode;

    oRemote.Connect();
    oRemote.Show();
    oRemote.Focus();
  }

  private void rdpClient_OnConnected(object sender, EventArgs e)
  {
    this.panel1.Visible = false;
    this.Visible = false;            
  }

  private void rdpClient_OnLeaveFullScreenMode(object sender, EventArgs e)
  {
    this.Visible = true;
  }

  protected override void WndProc(ref Message m)
  {
    if (m.Msg == WM_SYSCOMMAND)
    {
      if (m.WParam.ToInt32() == MAXIMIZE)
      {
        this.Visible = false;
        oRemote.FullScreen = true;
        oRemote.Show();
      }
    }
    base.WndProc(ref m);
  }
}

我尝试了一些方法,但没有一个起作用。
oRemote.Bounds = Screen.PrimaryScreen.WorkingArea;
oRemote.IsAccessible = true;
this.ShowInTaskbar = true;

或者

this.Visible = ture; // do not hide the main form


if (m.WParam.ToInt32() == MAXIMIZE)
{
  oRemote.FullScreen = true;
  oRemote.Show();
  oRemote.Update();
  oRemote.Refresh();
}

目前,我唯一想到的解决方案是禁用还原按钮,操作如下:

oRemote.AdvancedSettings7.ConnectionBarShowRestoreButton = false;

这种方式并不能解决问题,只是避免触发该问题。 我将不胜感激任何帮助。
1个回答

0

由于 AxMSTSCLib 存在还原问题,我转而使用一个窗体来处理其全屏模式。这样,我可以对全屏模式的行为进行广泛的控制,并编写代码告诉容器在调用还原按钮时该做什么。

// enable container-handled full-screen mode
oRemote.AdvancedSettings7.ContainerHandledFullScreen = 1;

然后,自定义OnRequestGoFullScreenOnRequestLeaveFullScreenOnRequestContainerMinimize

oRemote.OnRequestGoFullScreen += corey_OnRequestGoFullScreen;
oRemote.OnRequestLeaveFullScreen += corey_OnRequestLeaveFullScreen;
oRemote.OnRequestContainerMinimize += corey_OnRequestContainerMinimize;

private void corey_OnRequestGoFullScreen(object sender, EventArgs e)
{
    // set the form to fullscreen
}

private void corey_OnRequestLeaveFullScreen(object sender, EventArgs e)
{
    // set the form back to non-fullscreen mode
}

private void corey_OnRequestContainerMinimize(object sender, EventArgs e)
{
    // minimize the form
}

我在这里发布的方法可以是解决此问题的一种变通方法。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接