How to prevent my C# winforms application from stealing focus when I set the visible properly to true? -
I have a C # Winforms app that runs in the background, listening to hotkeys to be pressed. When a hotkey is pressed, my form shows a brief form. This form is always going on, but until I did not get a hotkey event, it was hidden, at that time I set the property to the right that the code looks like this:
Zero Hook_Wallmdown (Object Sender, KPpressAvent E) {this.Visible = true; }
It should be noted that the highest property of this form is set to true
is actually a strange part, my C # After focusing, it will never do this again, for example: I launch my app, then launch some fullscreen app like Team Fortale 2. Then I press my hotkey Team fortress is at least 2, and I see my form again, nevertheless, I can restore TF2, and again I want to hit my hattie again (the desired effect Together), and TF2 will be centered
At any rate, I'm exploring a way to fix it. I am getting a lot of problems here on which such problems are coming, but all of them are related to forming / launching a new form, do not make an existing visible (unless I miss something). Every time I need one, the application will have to work again to create a new form, but it will only have to make another form of invisible to be invisible at all times to wait for hot events, So I want to leave it and leave it.
Any thoughts?
I think that you are related to the problem that is visible = different between true first and subsequent calls - The first behavior is called first time and the window handle is not created, the window has been created by calling on CreateWindowEx, in which there are some style parameters that how windows should behave. I think that you need to make sure that the window style is created with WS_EX_NOACTIVATE, which you can do while overriding CreateParams.
To try in other ways:
1) The ShowWindow function (visible = true is used by) is the first time the focus parameter is called (), if the program STARTUPINFO provides structure. Dig into the reflector and find out that the form class provides the STARTUPINFO structure and if so, how it can be manipulated.
2) The form can be overused and set to the right, is it?
Sorry for "no exact answer", but I hope at least you will get some starting points for further investigation.
Comments
Post a Comment