What you need is this:
internal static class User32Constants {
internal const int WS_EX_TOPMOST = 8;
internal const int WS_EX_NOACTIVATE = 0x08000000;
}
In your Virtual keyboard form, add:
protected override CreateParams CreateParams {
get {
CreateParams par = base.CreateParams;
if (DesignMode) return par;
par.ExStyle |= User32Constants.WS_EX_TOPMOST;
par.ExStyle |= User32Constants.WS_EX_NOACTIVATE;
return par;
}
}
The use of
WS_EX_TOPMOST
works as the property
TopMost
(which could be used instead).
There three delicate moments: topmost behavior is needed to not hide the form behind when focusing on a control to be used for input,
WS_EX_NOACTIVATE
— to avoid grabbing focus by the virtual keyboard (Nishant explained that before). The check of DesignMode is good to avoid disrupting of the Form Designer in case you use it.
I bet your next question would be about sending input from the virtual control; not many do it correctly. A hint: find an answer in one of my recent Answers.
—SA