Make a form not focusable in C#

前端 未结 2 1545
忘了有多久
忘了有多久 2020-12-06 10:51

I\'m wanting to write a virtual keyboard, like windows onscreen keyboard for touchscreen pcs. But I\'m having problem with my virtual keyboard stealing the focus from the ap

2条回答
  •  盖世英雄少女心
    2020-12-06 11:02

    Its solved!

    I've tried the solution from gehho, but I also needed to override the CreateParams method:

    private const int WS_EX_NOACTIVATE = 0x08000000;
    protected override CreateParams CreateParams
    {
        get
        {
            var createParams = base.CreateParams;
    
            createParams.ExStyle |= WS_EX_NOACTIVATE;
            return createParams;
        }
    }
    

提交回复
热议问题