#StackBounty: #c# #winforms #rdp #mstsc #windows-controls AxMSTSCLib display disappear in taskbar after minimize from full-screen mode

Bounty: 50

I am using AxMSTSCLib to develop a Windows App for creating RDP connections.

The steps listed below caused my remote desktop display disappear:

  1. Start an RDP connection with full-screen mode
  2. Click "restore down" button from connection bar
  3. Click "maximize" button again to re-enter full-screen mode
  4. Click "minimize" button
  5. Then my app disappears, I can’t see it in taskbar (but still be listed / running in taskmanager)

enter image description here

If I skip steps 2 & 3, it won’t disappear when I click "minimize" button from connection bar, it’s really weird.

I post some part of my code here, hope anyone can help me to find out the problem.

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);
  }
}

I’ve tried some methods, but none of them worked.

oRemote.Bounds = Screen.PrimaryScreen.WorkingArea;
oRemote.IsAccessible = true;
this.ShowInTaskbar = true;

or

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

So far, the only solution that came into my mind is disable the restore button, like this:

oRemote.AdvancedSettings7.ConnectionBarShowRestoreButton = false;

I would appreciate any help.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.