30-10-22, 08:21 PM
السلام عليكم ورحمة الله وبركاته
هل يوجد طريقة لجعل البرنامج يظهر فوق جميع البرامج المفتوحة حتي اقوم انا باغلاقه بنفسي ؟
فعلت خاصية TopMost لكنها احيانا تعمل واحيانا لا تعمل
(30-10-22, 08:21 PM)mohamedahmed1 كتب : [ -> ]السلام عليكم ورحمة الله وبركاته
هل يوجد طريقة لجعل البرنامج يظهر فوق جميع البرامج المفتوحة حتي اقوم انا باغلاقه بنفسي ؟
فعلت خاصية TopMost لكنها احيانا تعمل واحيانا لا تعمل
Me.TopMost = true
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 UInt32) As Boolean
End Function
ReadOnly HWND_TOPMOST As New IntPtr(-1)
ReadOnly HWND_NoTOPMOST As New IntPtr(-2)
Shared ReadOnly SWP_NOSIZE As UInt32 = Convert.ToUInt32(&H1)
Shared ReadOnly SWP_NOMOVE As UInt32 = Convert.ToUInt32(&H2)
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
SetWindowPos(Me.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
Else
SetWindowPos(Me.Handle, HWND_NoTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End If
End Sub
End Class