MSTSCAX RdpClient FullScreenTitle

  • Thread starter Thread starter mail dude
  • Start date Start date
M

mail dude

Guest
Hi All

I'm developping an application to initiate connection on remote server.

I have a bug : i set the FullScreenTitle, but the server property is displayed in the bar on the top of the rdpClient in fullscreen Mode.

I read in the doc that i don't have to set this value when use the ContainerHandledFullScreen because the title of the containing form will be used to replace the fullScreenTitle.

But it doesn't works. Also i try to add dynamicaly a RdpClient to my mainForm wich doesn't rely on a container, set the FullScreenTitle, and only my server property is displayed.

Here is the code of my RdpClient included in a Form :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using MSTSCLib;
namespace CardManager
{
public partial class RdpForm : System.Windows.Forms.Form
{
private const int SC_MAXIMIZE = 0xF030;
private const int WM_SYSCOMMAND = 0x0112;
private User user;
private Delegate logger;
private Boolean isFormActive = false;
private Boolean secured = false;
public Boolean Secured { get { return secured; } }
public RdpForm(Delegate delegateLogger, User user)
{
InitializeComponent();
SystemEvents.DisplaySettingsChanged += new EventHandler(resizeRdpDesktop);
adjustRdpDesktopToScreen();
rdpClient.FullScreen = true;
rdpClient.AdvancedSettings3.SmartSizing = true;
rdpClient.AdvancedSettings2.ContainerHandledFullScreen = 1;
rdpClient.AdvancedSettings4.ConnectionBarShowRestoreButton = true;
logger = delegateLogger;
secured = !String.IsNullOrWhiteSpace(user.CardId);
isFormActive = true;
this.user = user;
}
public void connectToRdp() {
rdpClient.Server = "myServer";
rdpClient.UserName = user.Username;
IMsTscNonScriptable secured = (IMsTscNonScriptable)rdpClient.GetOcx();
secured.ClearTextPassword = user.Password;
rdpClient.Connect();
}
public void setTitle(String title) {
this.Text = title;
}
private void resizeRdpDesktop(object sender, EventArgs e)
{
adjustRdpDesktopToScreen();
rdpClient.Invalidate();
}
private void adjustRdpDesktopToScreen() {
rdpClient.DesktopWidth = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width;
rdpClient.DesktopHeight = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Height;
}
private void RdpForm_FormClosed(object sender, FormClosedEventArgs e)
{

}
private void rdpClient_OnMinimize(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
private void rdpClient_OnMaximize(object sender, EventArgs e)
{
this.rdpClient.FullScreen = true;

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
}
private void rdpClient_OnLeaveFullSreen(object sender, EventArgs e)
{
this.rdpClient.FullScreen = false;
this.WindowState = FormWindowState.Normal;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;

}
private void rdpForm_Resize(object sender, EventArgs e){
if (this.isFormActive){
if (this.WindowState == FormWindowState.Maximized)
{
this.rdpClient.FullScreen = true;
if (this.FormBorderStyle != System.Windows.Forms.FormBorderStyle.None)
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
}
}
}
private void rdpClient_OnConnected(object sender, EventArgs e)
{
CacheManager cacheManager = CacheManager.Instance;
if (!String.IsNullOrWhiteSpace(user.CardId) && !cacheManager.UserExists(user.CardId))
{
cacheManager.AddUser(user);
logger.DynamicInvoke(new object[] { "User " + user.Username + " stored in memchache" });
}

logger.DynamicInvoke(new object[] { "User " + user.Username + " is connected" });

}
public void closeAndDisconnect() {
rdpClient.Disconnect();
}
public String getCurrentUser() {
return this.user.Username;
}
private void rdpClient_OnIdleTimeoutNotification(object sender, EventArgs e)
{
logger.DynamicInvoke("User " + user.Username + " has been disconnected by server due to Idle Timeout.");
}
private void rdpClient_OnDisconnected(object sender, AxMSTSCLib.IMsTscAxEvents_OnDisconnectedEvent e)
{
logger.DynamicInvoke("User " + user.Username + " has been disconnected.");
this.Close();
this.Dispose();
}
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
// Listen for operating system messages.
switch (m.Msg)
{
case WM_SYSCOMMAND:
if ((int)m.WParam == SC_MAXIMIZE) {
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Invalidate();
}
break;
}
base.WndProc(ref m);
}
}
}

And here is the code of my standAlone RdpClient :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MSTSCLib;
namespace CardManager
{
class RdpClient : AxMSTSCLib.AxMsRdpClient5NotSafeForScripting{
private Delegate logger;
private User user;
public RdpClient(Delegate delegateLogger, User user) {
this.logger = delegateLogger;
this.user = user;
}
public void init() {
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
this.SuspendLayout();
//this.rdpClient.Dock = System.Windows.Forms.DockStyle.Fill;
Enabled = true;
Location = new System.Drawing.Point(0, 0);
Name = "rdpClient";
OcxState = ((System.Windows.Forms.AxHost.State)(GetOcx()));
Size = new System.Drawing.Size(554, 395);
TabIndex = 0;
OnConnected += new System.EventHandler(this.rdpClient_OnConnected);

((System.ComponentModel.ISupportInitialize)(this)).EndInit();
this.ResumeLayout();
}
public void close(){
if (Connected == 1)
{
Disconnect();
while (Connected != 0)
{
System.Threading.Thread.Sleep(100);
Application.DoEvents();
}
}
}
public void connectMesApplis() {
Server = "myServer";
UserName = user.Username;
IMsTscNonScriptable secured = (IMsTscNonScriptable)GetOcx();
secured.ClearTextPassword = user.Password;
FullScreen = true;
FullScreenTitle = String.Format("Mes Applis - {0:S}", user.Username);
DesktopWidth = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width;
DesktopHeight = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Height;
Connect();
}
private void rdpClient_OnConnected(object sender, EventArgs e)
{
logger.DynamicInvoke(new object[] { "User " + user.Username + " is connected" });
FullScreenTitle = String.Format("Mes Applis - {0:S}", user.Username);
Invalidate();
Update();
}
}
}

Does someone has an answer ?

Thank you very much

--

Mickael

Continue reading...
 
Back
Top