I found several topics about this, but none of them helped me with my problem, I want to adjust the focus on the newly created winform window after it started.
I run the form in my new thread with:
application.Run(new InvisibleForm());
and a form will appear, but the focus is still set in the last selected window from the windows. this form has no title and is not in the taskbar to view, it also has a set of TransparencyKey:
this.AutoScaleDimensions = new SizeF(6F, 13F); this.AutoScaleMode = AutoScaleMode.Font; this.BackColor = SystemColors.AppWorkspace; this.ClientSize = new Size(992, 992); this.ControlBox = false; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "InvisibleForm"; this.Opacity = 0.5; this.ShowInTaskbar = false; this.TransparencyKey = SystemColors.AppWorkspace; this.Load += new EventHandler(this.InvisibleForm_Load);
now I tried several methods, but none of them made me focus on the form or could set the form in the foreground / top of all other windows:
this.TopMost = true; this.Focus(); this.BringToFront(); this.Activate();
Is there a way to programmatically trigger the click / focus event on the form so that it sets itself with this event in focus?
dontcare
source share