0

I have kiosk application, where i have already kiosk application running but on top of that window i need to put one of my window which is forever available no matter who ever is on top, that window has to be on top of the top of the very top window as always on top.

enter image description here enter image description here

i tried several way but still it fails to stay on top of the window out all top of the window

Why is my application still unable to stay to the very top of the top?

Imports System.Runtime.InteropServices

Public Class Form1

  <DllImport("user32.dll", SetLastError:=True)>
  Private Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As Integer) As Boolean
  End Function

  Private Const SWP_NOSIZE As Integer = &H1
  Private Const SWP_NOMOVE As Integer = &H2

  Private Shared ReadOnly HWND_TOPMOST As New IntPtr(-1)
  Private Shared ReadOnly HWND_NOTOPMOST As New IntPtr(-2)

  Public Function MakeTopMost()
    SetWindowPos(Me.Handle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
  End Function

  Public Function MakeNormal()
    SetWindowPos(Me.Handle(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
  End Function

  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.TransparencyKey = Color.LightBlue
    Me.BackColor = Color.LightBlue
  End Sub

  Private Sub Form1_LocationChanged(sender As Object, e As EventArgs) Handles Me.LocationChanged
    Me.Top = 5
    Me.Left = 1185
    Me.Visible = True
    Me.BringToFront()
    'Me.TopMost = True
    Me.MakeTopMost()
    'Me.BackColor = Color.Transparent
  End Sub

  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Shell("cmd.exe /c cd C:\ & taskkill /f /im testingVB.net.exe", AppWinStyle.Hide)
    End


  End Sub
End Class

[EDIT]:

I tried Me.TopMost = True and following event too, but still my RED cross is not on top of all the other on top windows. see below the RED is mine and all others are taking more priority then me to stay on top. how can i be on top of all those?

enter image description here

  Private Sub Form1_LostFocus(sender As Object, e As EventArgs) Handles Me.LostFocus
    MsgBox("lost")

    Me.Top = 5
    Me.Left = 1185
    Me.Visible = True
    Me.BringToFront()
    'Me.TopMost = True
    Me.MakeTopMost()
    'Me.BackColor = Color.Transparent
  End Sub

  Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

Me.Top = 5
Me.Left = 1185
Me.Visible = True
Me.BringToFront()
'Me.TopMost = True
Me.MakeTopMost()
'Me.BackColor = Color.Transparent
 End Sub
weston
  • 54,145
  • 21
  • 145
  • 203
  • Do you have task manager set to always on top? – A Friend Dec 20 '16 at 09:30
  • 1
    Sigh, there is no SuperDuperTopMostPlusOne property. If there was the other app would already use it of course. So using TopMost is completely pointless to implement a kiosk. A correct kiosk prevents other apps from getting started, like the ones that want to be on top. You do so with machine configuration, not software. How to do so is well known, Google knows. – Hans Passant Dec 21 '16 at 07:18
  • Sir, Logmein.com and there are many softwares which take over the SuperDuperGodMode to set there application always on top of all. i am just trying to get that like Logmein.com is doing when you remotely connect and Logmein.com shows a small popup and it always sits on top of everything. I am exactly trying to do that kind of popup. https://i.stack.imgur.com/PtPZT.png –  Dec 21 '16 at 07:20

1 Answers1

0

Is it a VB.Net program your pointing too? Change the TopMost property of that form to True

Solution 1

Or in your form add this Me.TopMost = True in your Form_LostFocus here is the link I also answer it the same as I given to you, you have the same problem

Keep form open when clicking on another application

Dont forget that the form you will put the code is the form that you will show in your program

Update

Try This.

Solution 2

Dim form1 As Form = new Form
form.TopMost = True
form.Owner = Me
form.ShowDialog()
form.Dispose()

Solution 3

Dim frmMessage As New Form() frmMessage.Owner = form1 frmMessage.Show()

Community
  • 1
  • 1
Shadow Fiend
  • 351
  • 6
  • 18