65.9K
CodeProject is changing. Read more.
Home

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

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Feb 28, 2012

CPOL
viewsIcon

15472

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.

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