不可能设置window在top of top的top window?

Impossible to set the window on top of the top of the top window?

我有 kiosk 应用程序,我已经有 kiosk 应用程序 运行 但最重要的是 window 我需要放置一个我的 window,无论谁都可以永远使用曾经在顶部,window 必须在最顶部的顶部 window 一如既往地在顶部。

我尝试了几种方法,但仍然无法保持在 window 的顶部,在 window

的所有顶部

为什么我的申请还是无法停留在最顶层?

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

[编辑]:

我尝试了 Me.TopMost = True 和后续事件,但我的红色十字仍然没有在所有其他顶部 windows 之上。看到下面的红色是我的,所有其他人都比我更优先留在上面。我怎样才能超越所有这些?

  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

你指的也是VB.Net程序吗?将该表格的 TopMost 属性 更改为 True

解决方案 1

或者在你的表格中添加这个Me.TopMost = True在你的Form_LostFocus这里是link我也和我给你的一样回答,你有同样的问题

不要忘记,您放置代码的形式就是您将在程序中显示的形式

更新

试试这个。

解决方案 2

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

解决方案 3

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