Cursor.Current = Cursors.WaitCursor[...]Dim result As DialogResult = printDialog.ShowDialog()If result = DialogResult.Cancel Then ReturnEnd IfCursor.Current = Cursors.WaitCursor[...]解决方法 我刚用你的代码做了一个小测试.使用你的代码时,我的VS2012没有显示Cursor.Current,但在使用它时没有抛出任何异常.所以我改成了
Me.Cursor = Cursors.WaitCursorDim result As DialogResult = printDialog.ShowDialog()If result = DialogResult.Cancel Then ReturnEnd If' not necesary any more'Cursor.Current = Cursors.WaitCursor
并且在显示printDialog之后WaitCursor停留了.
编辑:找到一个很好的解释Cursor.Current and Cursor之间的差异!
EDIT2:我改变了我的代码,以利用上面提到的@HansPassant的例子中的HourGlass类.即使您输入textBox,WaitCursor也会保留.无论如何 – 当我悬停在例如边界上时,我仍然能够失去waitCursor.一个textBox.
总而言之IMO我认为当仍然可以输入文本aso时强制使用waitCursor并不是很好.也许您可以考虑在某种 *** 作完成之前禁用控件,然后再将光标更改回来.
Private Sub button1_Click(sender As Object,e As EventArgs) Handles button1.Click Hourglass.Enabled = True Dim result As DialogResult = PrintDialog1.ShowDialog() If result = windows.Forms.DialogResult.Cancel Then Return End If 'Cursor.Current = Cursors.WaitCursorEnd Sub
Hourglass.vb – 我希望在将其转换为vb.net时没有犯任何错误
Public Class Hourglass Implements Idisposable Public Shared Property Enabled As Boolean Get Return Application.UseWaitCursor End Get Set(ByVal value As Boolean) If value = Application.UseWaitCursor Then Return Application.UseWaitCursor = value Dim f As Form = Form.ActiveForm If Not f Is nothing AndAlso f.Handle <> IntPtr.Zero Then SendMessage(f.Handle,32,f.Handle,1) End If End Set End Property <System.Runtime.InteropServices.Dllimport("user32.dll")> Private Shared Function SendMessage(hWnd As IntPtr,msg As IntPtr,wp As IntPtr,lp As IntPtr) As IntPtr End Function Public Sub dispose() Implements Idisposable.dispose Enabled = False End SubEnd Class总结
以上是内存溢出为你收集整理的vb.net – printDialog之后的Cursor.Wait全部内容,希望文章能够帮你解决vb.net – printDialog之后的Cursor.Wait所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)