A window on top of another window

  • Thread starter Thread starter Sean
  • Start date Start date
S

Sean

Hi,

Say that I have 2 windows A and B.
If I want A to be always on top of B, how can I do this in
C# WITHOUT having to set the TopMost property of A to TRUE.


Thank you very much in advance.

regards,
Sean
 
Hi,

Sean said:
Hi,

Say that I have 2 windows A and B.
If I want A to be always on top of B, how can I do this in
C# WITHOUT having to set the TopMost property of A to TRUE.

When showing A specify B as the owner, eg:

FormB:
void ShowA()
{
FormA a = new FormA();
a.Show( this );
}

HTH,
greetings
 
You can use,

[DllImport("user32")]
public static extern int SetWindowPos(int hwnd, int hWndInsertAfter, int x,
int y, int cx, int cy, int wFlags)

you have to set

hWndInsertAfter = HWND_TOPMOST
 
Hi Shak,

Thank you for your reply.

However, I cannot use TopMost property because after I
show Form A, I want another window to be always on top of
Form A (at the sametime I also want Form A to be always on
top of Form B).

(top)
Another Form (always on top of A)
|
Form A (always on top of B)
|
Form B
(bottom)

That's why if I use TopMost, I can't get the above to work.
I tried setting
A.Owner = B
but still I can click any button on Form B.

Any help would be greatly appreciated.
Thank you in advance.


regards,
Sean
-----Original Message-----
You can use,

[DllImport("user32")]
public static extern int SetWindowPos(int hwnd, int hWndInsertAfter, int x,
int y, int cx, int cy, int wFlags)

you have to set

hWndInsertAfter = HWND_TOPMOST

--
Shak
(Houston)


Hi,

Say that I have 2 windows A and B.
If I want A to be always on top of B, how can I do this in
C# WITHOUT having to set the TopMost property of A to TRUE.


Thank you very much in advance.

regards,
Sean


.
 
Back
Top