The blog has moved to a new address. The blog is now located at

Tuesday, June 27, 2006

TopMost Form

"A topmost form is a form that overlaps all the other (non-topmost) forms even if
it is not the active or foreground form. Topmost forms are always displayed at
the highest point in the z-order of the windows on the desktop. You can use this
property to create a form that is always displayed in your application,
such as a Find and Replace tool window."

The well known issue that the TopMost Form stealing focus ...
The fallowing code can solve the problem.

private const int SW_SHOWNA = 8;
private const int SW_SHOWNA = 8;
[DllImport("user32", CharSet = CharSet.Auto)]
private extern static int ShowWindow( IntPtr hWindow, int nCmd );

public void MakeTopMostForm(Form frm)
ShowWindow(frm.Handle, SW_SHOWNA);

1 comment:

Anonymous said...

That does not create a TopMost Form.