失去Tab键控制 [英] Lose of the tab-key control

查看:65
本文介绍了失去Tab键控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序,该应用程序在WindowsFormsHost中托管Win32控件. Win32正在显示浏览"以操作用户 ' s 文件.

问题:将Tab键控件移至Win32之后在此应用程序中,Win32将继续处理Tab键控件.

此后,用户无法通过按Tab键进行操作在所有应用中.

Tab键的控件一次移到Win32.

感谢任何想法,

Hayato  (TKNET SERVICE LIMITED)


Hayato武田

解决方案

Tknetservice武田

>>>问题:将Tab键控件一次移至该应用程序中的Win32之后,Win32将继续处理Tab键控件
>>即使将Tab键的控件一次移到Win32之后,我也想在WPF应用程序中检测Tab键的控件

对于上述问题,根据我的经验,我认为这是由于Win32 Explore控件实现了自己的虚假焦点并继续对其进行处理,因此您无法将焦点切换到它之外的下一个控件.

这是我的示例,它托管了一个Win32 File Browser控件,它是由创建的 史蒂文·罗伯特在本文中: http://www.codeproject.com/Articles/15059/C-File-Browser

< Grid>
        < Grid.RowDefinitions>
            <行定义/>
            <行定义/>
        </Grid.RowDefinitions>
        < TextBox Text =" {Binding IsFocused,ElementName = MyWindowsFormsHost,Mode = OneWay}" />
        < WindowsFormsHost Grid.Row ="1";名称="MyWindowsFormsHost"

        </WindowsFormsHost>
    </Grid> 

隐藏代码:

公共MainWindow()
{
            InitializeComponent();

            MyWindowsFormsHost.Child = new FileBrowser.Browser();
} 

截屏:

如您所见,我们可以使用Tab键按下,在Wpf TextBox控件和WindowsFormsHost内部的Win32控件之间切换焦点.

我看到您在此线程中回复:Hi,

I have a WPF application that hosts a Win32 control in a WindowsFormsHost. Win32 is showing Explore to operate users files.

Issue: After the tab-key control has been moved to the Win32 within this application once, the Win32 will keep to handle the tab-key control.

Thereafter, the user becomes unable to operate by pressing the tab-key in all applications.

Id like to detect the tab-key control in the WPF application even after the control of the tab-key was moved to Win32 once.

Thanks for any ideas,

Hayato  (TKNET SERVICE LIMITED)


Hayato Takeda

解决方案

Hi Tknetservice takeda,

>>Issue: After the tab-key control has been moved to the Win32 within this application once, the Win32 will keep to handle the tab-key control
>>I’d like to detect the tab-key control in the WPF application even after the control of the tab-key was moved to Win32 once

For the above question, based on my experience, I think it was due to this Win32 Explore control implemented its own fake focus and keep to handle it, so you can't switch focus to next control outside it.

Here is my sample, it hosted a Win32 File Browser control, it was created by Steven Roebert in this article: http://www.codeproject.com/Articles/15059/C-File-Browser

<Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <TextBox Text="{Binding IsFocused, ElementName=MyWindowsFormsHost, Mode=OneWay}" />
        <WindowsFormsHost Grid.Row="1" Name="MyWindowsFormsHost">

        </WindowsFormsHost>
    </Grid>

Code Behind:

public MainWindow()
{
            InitializeComponent();

            MyWindowsFormsHost.Child = new FileBrowser.Browser();
}

Screenshot:

As you can see, we can switch focus between Wpf TextBox control and the Win32 control inside the WindowsFormsHost using Tab key pressing.

And I saw you replied in this thread: https://social.msdn.microsoft.com/Forums/vstudio/en-US/1cb981e8-dbe1-4f3d-b717-24b93317e41b/detect-if-keyboard-focus-moved-to-windowsformshost?forum=wpf

You can try Min's suggestion:

Alternatively, you can handle the WPF Window's message loop and use WM_KILLFOCUS to determine when the Win32 control clears the focus.


这篇关于失去Tab键控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆