PC Review


Reply
Thread Tools Rate Thread

Cursors & MDI Apps

 
 
a
Guest
Posts: n/a
 
      14th Jul 2004
Hello,

I am doing some multithreading in an MDI app, and I can't seem to get the
cursor to stay as an Hourglass. I call:

Cursor.Current = cursors.wait

at the beginning of my routing, and set it back to cursors.default when the
thread ends (using a callback)

Any ideas here? Does Cursor.Current work, if called in the MDIParent, on
MDIChildren forms?

Thanks!

Kevin


 
Reply With Quote
 
 
 
 
Peter Huang
Guest
Posts: n/a
 
      14th Jul 2004
Hi Kevin,

This may be caused by that another thread accessed the control on the
winform.
You may take a look at the Control.Invoke method.
Control.Invoke Method
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemWindowsFormsControlClassInvokeTopic.asp

Here are some articles about Multithreading in Windows Forms.
Safe, Simple Multithreading in Windows Forms, Part 1
http://msdn.microsoft.com/library/de...us/dnforms/htm
l/winforms06112002.asp

Safe, Simple Multithreading in Windows Forms, Part 2
http://msdn.microsoft.com/library/de...us/dnforms/htm
l/winforms08162002.asp

Safe, Simple Multithreading in Windows Forms, Part 3
http://msdn.microsoft.com/library/de...us/dnforms/htm
l/winforms01232003.asp

Give Your .NET-based Application a Fast and Responsive UI with Multiple
Threads
http://msdn.microsoft.com/msdnmag/is...g/default.aspx

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
a
Guest
Posts: n/a
 
      14th Jul 2004
I don't think it was (is) a thread issue. I changed from Cursor.Current =
Cursors.WaitCursor to Cursor = Cursors.WaitCursor and half of my issue is
fixed. The other part is that when I 'mouseover' a listview in Details
view, i get the default, but anywhere else seems to show the WaitCursor.

Any ideas on this? Do I need to rig a handler to the listview? Seems odd.

Kevin



""Peter Huang"" <v-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Kevin,
>
> This may be caused by that another thread accessed the control on the
> winform.
> You may take a look at the Control.Invoke method.
> Control.Invoke Method
>

http://msdn.microsoft.com/library/de...us/cpref/html/
> frlrfSystemWindowsFormsControlClassInvokeTopic.asp
>
> Here are some articles about Multithreading in Windows Forms.
> Safe, Simple Multithreading in Windows Forms, Part 1
>

http://msdn.microsoft.com/library/de...us/dnforms/htm
> l/winforms06112002.asp
>
> Safe, Simple Multithreading in Windows Forms, Part 2
>

http://msdn.microsoft.com/library/de...us/dnforms/htm
> l/winforms08162002.asp
>
> Safe, Simple Multithreading in Windows Forms, Part 3
>

http://msdn.microsoft.com/library/de...us/dnforms/htm
> l/winforms01232003.asp
>
> Give Your .NET-based Application a Fast and Responsive UI with Multiple
> Threads
> http://msdn.microsoft.com/msdnmag/is...g/default.aspx
>
> Best regards,
>
> Peter Huang
> Microsoft Online Partner Support
>
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no

rights.
>



 
Reply With Quote
 
Peter Huang
Guest
Posts: n/a
 
      14th Jul 2004
Hi Kevin,

I am sorry for misunderstanding your meaning.
I think the Cursor.Current is used to set the current cursor only when the
message loop is stopped.
e.g. In the senario below, the message loop will stop because it is busy
running Button1_Click function, so after we set the Cursor.Current =
Cursors.WaitCursor it will keep the Cursors.WaitCursor.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Cursor.Current = Cursors.WaitCursor
For i As Long = 0 To 1000000000000
Dim j As Long = i
Next
Cursor.Current = Cursors.Default
End Sub

While the Cursor you refer to in your second statement means the Cursor
property of a control, it may be a window form or another control.
e.g.
If we set the Cursor property of winform as below, if we move the cursor
over windows forms area, the cursor will became Cursors.WaitCursor, while
it will become Cursors.Default if we move the cursor on a control whose
Cursor property is Cursors.Default even if it is on the windows form.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Cursor = Cursors.WaitCursor
End Sub

As for the problem that when we set the listview's Cursor property to
Cursors.WaitCursor, the cursor will not change when mouse moves over the
listview, that is a known issue.
So far as a workaround, we need to derived ourselves' listview and override
the wndproc to set the cursor.
Here is the sample code.
Imports System.Runtime.InteropServices

Public Class MyListView
Inherits ListView
Const WM_SETCURSOR = &H20
Public Declare Function SetCursor Lib "user32" Alias "SetCursor" (ByVal
hCursor As IntPtr) As IntPtr
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
if m.Msg = WM_SETCURSOR
SetCursor(Me.Cursor.Handle)
Return
End If
MyBase.WndProc(m)
End Sub
End Class

You may have a try and let me know the result.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
a
Guest
Posts: n/a
 
      14th Jul 2004
JOKE: WHat do you call a known-issue when it's not known to you?
ANSWER: A Pain in the @$$

Thanks for the help.

Not susre I follow the Cursor.Current deal, I'll have to look into it later.

I will try to implement your listview fix later.

Thanks!

Kevin




""Peter Huang"" <v-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Kevin,
>
> I am sorry for misunderstanding your meaning.
> I think the Cursor.Current is used to set the current cursor only when the
> message loop is stopped.
> e.g. In the senario below, the message loop will stop because it is busy
> running Button1_Click function, so after we set the Cursor.Current =
> Cursors.WaitCursor it will keep the Cursors.WaitCursor.
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> Cursor.Current = Cursors.WaitCursor
> For i As Long = 0 To 1000000000000
> Dim j As Long = i
> Next
> Cursor.Current = Cursors.Default
> End Sub
>
> While the Cursor you refer to in your second statement means the Cursor
> property of a control, it may be a window form or another control.
> e.g.
> If we set the Cursor property of winform as below, if we move the cursor
> over windows forms area, the cursor will became Cursors.WaitCursor, while
> it will become Cursors.Default if we move the cursor on a control whose
> Cursor property is Cursors.Default even if it is on the windows form.
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Me.Cursor = Cursors.WaitCursor
> End Sub
>
> As for the problem that when we set the listview's Cursor property to
> Cursors.WaitCursor, the cursor will not change when mouse moves over the
> listview, that is a known issue.
> So far as a workaround, we need to derived ourselves' listview and

override
> the wndproc to set the cursor.
> Here is the sample code.
> Imports System.Runtime.InteropServices
>
> Public Class MyListView
> Inherits ListView
> Const WM_SETCURSOR = &H20
> Public Declare Function SetCursor Lib "user32" Alias "SetCursor"

(ByVal
> hCursor As IntPtr) As IntPtr
> Protected Overrides Sub WndProc(ByRef m As

System.Windows.Forms.Message)
> if m.Msg = WM_SETCURSOR
> SetCursor(Me.Cursor.Handle)
> Return
> End If
> MyBase.WndProc(m)
> End Sub
> End Class
>
> You may have a try and let me know the result.
>
> Best regards,
>
> Peter Huang
> Microsoft Online Partner Support
>
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no

rights.
>



 
Reply With Quote
 
Peter Huang
Guest
Posts: n/a
 
      15th Jul 2004
Hi Kevin,

I am sorry for misunderstanding the problem at the first time, I did not
relate the problem with the listview at the first reply, so I did not give
the information as the second reply do.

From your second reply, I redo the research and find the problem.

Anyway, I look forward to your reply after you have tried my suggestion, if
you still have any concern please feel free to let me know.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
a
Guest
Posts: n/a
 
      15th Jul 2004
That does it!

Thanks


""Peter Huang"" <v-(E-Mail Removed)> wrote in message
news:kgym$(E-Mail Removed)...
> Hi Kevin,
>
> I am sorry for misunderstanding the problem at the first time, I did not
> relate the problem with the listview at the first reply, so I did not give
> the information as the second reply do.
>
> From your second reply, I redo the research and find the problem.
>
> Anyway, I look forward to your reply after you have tried my suggestion,

if
> you still have any concern please feel free to let me know.
>
> Best regards,
>
> Peter Huang
> Microsoft Online Partner Support
>
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no

rights.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What's the difference between Cursor = Cursors.WaitCursor and CurrentCursor=Cursors.WaitCursor Just Me Microsoft VB .NET 10 24th Mar 2005 02:57 PM
web apps and cursors =?Utf-8?B?U3Vl?= Microsoft Dot NET 4 15th Dec 2004 09:41 PM
config files question for console apps / windows apps jai hanuman Microsoft Dot NET Framework Forms 2 15th Mar 2004 08:44 AM
winsock problem? some apps can't access any web site, most apps have no problems. W2K SP4+ Clark Wilson Microsoft Windows 2000 Networking 1 14th Sep 2003 02:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:54 AM.