Custom control inherits a base class usercontrol, but can not enter Chinese (End

It is the first question I spent a lot of time. Search a number of sites. Solutions are not found.
Wu Nai had forced himself to see the source code. Reference is also made MONO source. It found that the difference between them is very large. And look at the source code is very difficult in VS

No class search function. Only one class file to open a file type of look to see what other classes can only step by step with this method is used inside

. Or because I could not find a good way to do that? Eventually I gave up this method. I used decompile software Reflector.exe. This software search

Find very convenient. Clicking to find what you want to see. I'll find a UserControl class, and I can read a found overrides

The WndProc
protected void the override the WndProc (ref the Message m)
{
IF (m.Msg == 7)
{
this.WmSetFocus (ref m);
}
the else
{
base.WndProc (ref m);
}
}
Here if nothing important, I will point this.WmSetFocus. Then base.WndProc (ref m). Click on the jump to the base class

The ContainerControl
protected void the override the WndProc (REF the Message m)
{
IF (m.Msg ==. 7)
{
this.WmSetFocus (REF m);
}
the else
{
base.WndProc (REF m);
}
}
I again point this.WmSetFocus, this function reaches
Private void WmSetFocus (REF the Message m)
{

if (!base.HostedInWin32DialogManager)
{
if (this.ActiveControl != null)
{
base.WmImeSetFocus();
if (!this.ActiveControl.Visible)
{
this.OnGotFocus(EventArgs.Empty);
}
this.FocusActiveControlInternal();
}......

}
This time to see the base.WmImeSetFocus (), I was ecstatic. Secret must be in there. After the click-through

Control.WmImeSetFocus().

internal void WmImeSetFocus()
{
if (ImeModeConversion.InputLanguageTable != ImeModeConversion.UnsupportedTable)
{
this.UpdateImeContextMode();
}
}
接着再往下,
internal void UpdateImeContextMode()
{
ImeMode[] inputLanguageTable = ImeModeConversion.InputLanguageTable;
if ((!base.DesignMode && (inputLanguageTable != ImeModeConversion.UnsupportedTable)) &&

this.Focused)
{
ImeMode disable = ImeMode.Disable;
ImeMode cachedImeMode = this.CachedImeMode;
if (this.ImeSupported && this.CanEnableIme)
{
disable = (cachedImeMode == ImeMode.NoControl) ? PropagatingImeMode :

cachedImeMode;
}
if ((this.CurrentImeContextMode != disable) && (disable != ImeMode.Inherit))
{
this.DisableImeModeChangedCount++;
ImeMode propagatingImeMode = PropagatingImeMode;
try
{
ImeContext.SetImeStatus(disable, this.Handle);
}
finally
{
this.DisableImeModeChangedCount--;
if ((disable == ImeMode.Disable) && (inputLanguageTable ==

ImeModeConversion.ChineseTable))
{
PropagatingImeMode = propagatingImeMode;
}
}
if (cachedImeMode == ImeMode.NoControl)
{
if (this.CanEnableIme)
{
PropagatingImeMode = this.CurrentImeContextMode;
}
}
else
{
if (this.CanEnableIme)
{
this.CachedImeMode = this.CurrentImeContextMode;
}
this.VerifyImeModeChanged(disable, this.CachedImeMode);
}
}
}
}

Here are all the secrets and then edge up. These codes have to let me dumbfounded. How do I get it? MS code I can not change it. I want to rewrite a class

Class like it? God? Inside with so much class, msdn there simply can not be explained, for me it is too difficult. Then wanted to give up!
Here toss for a while, looked at the anti-code is repeated. Decided to found the program logic on two properties. this.CanEnableIme and

this.ImeSupported. Opening the ImeSupported seems to be no.
BOOL ImeSupported Private
{
GET
{
return (this.DefaultImeMode = ImeMode.Disable!);
}
}
then point CanEnableIme. Surprise! ............
protected Virtual BOOL CanEnableIme
{
GET
{
return this.ImeSupported;
}
}
Since it is virtual, the override try. In my custom class plus the following code

BOOL CanEnableIme the override protected
{
GET
{
return to true;
}
}
that simple. Effective? I do not know. Well now running! F5! Program up, and quickly try to open the input method, see if you can lose in

Wen. what! The world is so beautiful! I finally succeeded. Guangzhou surrogate [electric 13,802,269,370]   Beijing surrogate consulting electrical 13,802,269,370    surrogate [micro 13,802,269,370] +

Guess you like

Origin www.cnblogs.com/bbc2020/p/12503398.html