Windows ALWAYS on top ... 
Author Message
 Windows ALWAYS on top ...

Hi all,
   is there a way to make my application always on top, without the
possibility of switch to the other running at the same time?

The final customers of my app would not have to leave the program
after launching it: I would want to prevent that they were distracted
from other programs (Internet explorer, Windows Media Player,
pc-games) during their job ...

Someone has never met the same problem?

Many thanks

yom



Wed, 23 Nov 2005 22:47:56 GMT  
 Windows ALWAYS on top ...
You can set the TopMost property = True, but other programs can still take
Focus, they will just be covered by your form that is on top.

HTH,
Jeremy


Quote:
> Hi all,
>    is there a way to make my application always on top, without the
> possibility of switch to the other running at the same time?

> The final customers of my app would not have to leave the program
> after launching it: I would want to prevent that they were distracted
> from other programs (Internet explorer, Windows Media Player,
> pc-games) during their job ...

> Someone has never met the same problem?

> Many thanks

> yom



Thu, 24 Nov 2005 00:20:58 GMT  
 Windows ALWAYS on top ...

Hi,

        Two ways.  1 set the TopMost Property of the form to true(doesnt always work).  2 SetWindowPos API.
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Integer, _

ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, _

ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer

Const HWND_TOPMOST = -1

Const SWP_NOMOVE = &H2

Const SWP_NOSIZE = &H1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

SetWindowPos(Me.Handle.ToInt32, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE)

End Sub

Ken

---------

Quote:

> Hi all,
>    is there a way to make my application always on top, without the
> possibility of switch to the other running at the same time?

> The final customers of my app would not have to leave the program
> after launching it: I would want to prevent that they were distracted
> from other programs (Internet explorer, Windows Media Player,
> pc-games) during their job ...

> Someone has never met the same problem?

> Many thanks

> yom



Thu, 24 Nov 2005 00:23:02 GMT  
 Windows ALWAYS on top ...

FYI: the SetWindowPos API doesn't always work either. The TopMost property
is just a wrapper for the API.



  Hi,

          Two ways.  1 set the TopMost Property of the form to true(doesnt
always work).  2 SetWindowPos API.
  Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal
hwnd As Integer, _

  ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer,
_

  ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As
Integer

  Const HWND_TOPMOST = -1

  Const SWP_NOMOVE = &H2

  Const SWP_NOSIZE = &H1

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

  SetWindowPos(Me.Handle.ToInt32, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE +
SWP_NOSIZE)

  End Sub

  Ken

  ---------



  > Hi all,
  >    is there a way to make my application always on top, without the
  > possibility of switch to the other running at the same time?
  >
  > The final customers of my app would not have to leave the program
  > after launching it: I would want to prevent that they were distracted
  > from other programs (Internet explorer, Windows Media Player,
  > pc-games) during their job ...
  >
  > Someone has never met the same problem?
  >
  > Many thanks
  >
  > yom



Thu, 24 Nov 2005 00:30:52 GMT  
 Windows ALWAYS on top ...
Just a suggestion, alter your declaration to accept an IntPtr for the first
parameter, then you don't need to convert the form's handle to an Int32

--
Happy to help,
-- Tom Spink

Please respond to the newsgroup,
so all can benefit.

One Day,

Hi,

        Two ways.  1 set the TopMost Property of the form to true(doesnt
always work).  2 SetWindowPos API.
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd
As Integer, _
ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, _
ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As
Integer
Const HWND_TOPMOST = -1
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SetWindowPos(Me.Handle.ToInt32, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE +
SWP_NOSIZE)
End Sub
Ken
---------

Quote:
> Hi all,
>    is there a way to make my application always on top, without the
> possibility of switch to the other running at the same time?

> The final customers of my app would not have to leave the program
> after launching it: I would want to prevent that they were distracted
> from other programs (Internet explorer, Windows Media Player,
> pc-games) during their job ...

> Someone has never met the same problem?

> Many thanks

> yom



Thu, 24 Nov 2005 07:33:06 GMT  
 Windows ALWAYS on top ...
Hello Tom,


Quote:
> Just a suggestion, alter your declaration to accept an IntPtr
> for the first parameter, then you don't need to convert the
> form's handle to an Int32

He can alter the hWndInsertAfter parameter to IntPtr too (it's a handle).

;-)))

Regards,
Herfried K. Wagner
--
http://www.mvps.org/dotnet



Thu, 24 Nov 2005 08:09:32 GMT  
 Windows ALWAYS on top ...
Infact, he could delete the declare, and use the .TopMost property, I don't
see why it shouldn't work, because .TopMost will be a wrapper for
SetWindowPos. (Thanks to Jeremy)

--
Happy to help,
-- Tom Spink

Please respond to the newsgroup,
so all can benefit.

One Day,


Quote:
> Hello Tom,


> > Just a suggestion, alter your declaration to accept an IntPtr
> > for the first parameter, then you don't need to convert the
> > form's handle to an Int32

> He can alter the hWndInsertAfter parameter to IntPtr too (it's a handle).

> ;-)))

> Regards,
> Herfried K. Wagner
> --
> http://www.mvps.org/dotnet



Thu, 24 Nov 2005 19:34:52 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Windows Always On Top - How?

2. windows always on top

3. Windows Always on top

4. Windows Always on top

5. Showing inactive windows on top or showing always...

6. always on top of my windows

7. Always On Top Windows

8. Showing inactive windows on top or showing always...

9. How? Windows always on the top

10. Making Always On Top windows

11. Always On-Top Windows

12. Always on Top for Windows 95

 

 
Powered by phpBB® Forum Software