This is the only way to make me work.
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr End Function Public Class FenetrePrincipale Private WithEvents _btnRechercher As New Windows.Forms.ToolStripButton("Rechercher") Private WithEvents btnRechercherAccesBtn As New Button Private Sub Rechercher(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRechercherAccesBtn.Click Try Me.Cursor = Cursors.WaitCursor 'code... Finally Me.Cursor = Cursors.Default End Try End Sub Private Sub RechercherToolStripButton(ByVal sender As Object, ByVal e As System.EventArgs) Handles _btnRechercher.Click Me.UseWaitCursor = True SendMessage(Me.Handle, &H20, Me.Handle, New IntPtr(1)) Rechercher(Nothing, Nothing) Me.UseWaitCursor = False End Sub End Class
source share