tags:

views:

30

answers:

2

how to check if window is on top through usercontrol

i would like to set focus on a button, when window in on top of all on the desktop.

+1  A: 

Pretty vague. Focus stealing is something users dislike a lot and Windows actively prevents. Just implement the Activated event of the form and have the event handler set the focus.

Hans Passant
completely agree about stealing focus.
C Johnson
A: 

The ContainsFocus property of a Form will tell you if the window has the focus of the UI. The default behavior of a window is to come to the top when it gets focus, but it may not be on top of ALL other windows if one or more windows on the desktop are set to be "always on top" (The Task Manager is a common window that has this property by default)

KeithS