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)
this.Focus();
base.WndProc(ref m);
}
Luke 12:2 “There is nothing concealed that will not be disclosed, or hidden that will not be made known”
Tuesday, May 18, 2010
AxMsRdpClient Focus Issues
Had some time this week, so I fixed a few bugs in my mtRemote (which is modeled after mRemote) RDP tab tool. The most troublesome bug to figure out was a lost focus issue after clicking out of the AxMsRdpClient control within the parent tab. After doing this, then coming back, all UI control to the RDP window was lost. As a quick workaround, I added a button on the tab which would call .Focus(). This worked fine, but was annoying and not the best way around the issue. After watching the messages in the RDP control using Winspector Spy, I was able to capture the initial mouse activate event when overriding WndProc. Since this overrides all messages, I wanted to ensure I was not calling .Focus() unnecessarily. Here was the solution:
Subscribe to:
Post Comments (Atom)
Mike, I have been ruthlessly searching the internet for a solution to this issue... started by having a timer that autofocused every 5 seconds if rdp.containsfocus = false (baddd idea) i finally stumbled upon your solution and I must say THANK YOU!!!!
ReplyDeleteAfter all my struggling trying to find a solution, I figured others would benefit from my pain :') Glad you found it useful Tony!
ReplyDelete