Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Fix the focus issue on RDP Client from the AxInterop.MSTSCLib.dll

0.00/5 (No votes)
28 Feb 2012CPOL 15.4K  
I had to modify your code a little to deal with some issues I was having. This will only focus if it needs to be focused.public class MsRdpClient7 : AxMSTSCLib.AxMsRdpClient7{ public MsRdpClient7() : base() { } protected override void WndProc(ref...

I had to modify your code a little to deal with some issues I was having. This will only focus if it needs to be focused.


C#
public class MsRdpClient7 : AxMSTSCLib.AxMsRdpClient7
{
    public MsRdpClient7()
        : base()
    {
    }

    protected override void WndProc(ref System.Windows.Forms.Message m)
    {
        //Fix for the missing focus issue on the rdp client component
        if (m.Msg == 0x0021)
        //WM_MOUSEACTIVATE ref:http://msdn.microsoft.com/en-us/library/ms645612(VS.85).aspx
            if (this.ContainsFocus == false)
            {
                this.Focus();
            }
        base.WndProc(ref m);
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)