Keep form open when clicking on another application

时光总嘲笑我的痴心妄想 提交于 2019-12-25 17:49:13

问题


I've got an application that I'm trying to use as a keyboard to type special characters. It currently has this function (not my code!):

Protected Overrides ReadOnly Property CreateParams() As CreateParams
    Get
        Dim baseParams As CreateParams = MyBase.CreateParams

        Const WS_EX_NOACTIVATE As Integer = &H8000000
        Const WS_EX_TOOLWINDOW As Integer = &H80
        baseParams.ExStyle = baseParams.ExStyle Or CInt(WS_EX_NOACTIVATE Or WS_EX_TOOLWINDOW)

        Return baseParams
    End Get
End Property

This makes it so the form never receives focus, as I don't want to press a button on the form and then steal the focus. However, it also means that when I click outside the form, the window disappear, as it's positioned behind the focused application. The only way to use this program is to resize the application I want to type in, and position the window next to it. In other words, I can only use it like this:

So what I want to know is, how do I make it so I can position this application over the application I want to use it in, but when I press a button on the application, it still doesn't focus on that window?


回答1:


You can add Me.Topmost = True on your code or you can set the Forms Property to TopMost = True



来源:https://stackoverflow.com/questions/41214450/keep-form-open-when-clicking-on-another-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!