Can't Figure out the Null Reference
Here is my code (places the form on top of ALL aplications:
Imports System.Runtime.InteropServices _ 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()
If SetWindowPos(Me.Handle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or
SWP_NOSIZE).Equals(True) Then
SetWindowPos(Me.Handle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or
SWP_NOSIZE)
End If
End Function
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
MakeTopMost()
End Sub
VS 2010 says "Function... doesn't return a value on all code paths. A null
reference exception could occur at run time when the result is used.
I have been at this for hours but annot figgure it out. Does anyone know?
No comments:
Post a Comment