472,993 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 software developers and data experts.

Cursors & MDI Apps

a
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
Nov 20 '05 #1
6 2463
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.

Nov 20 '05 #2
a
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-******@online.microsoft.com> wrote in message
news:MO**************@cpmsftngxa06.phx.gbl...
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.

Nov 20 '05 #3
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.

Nov 20 '05 #4
a
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-******@online.microsoft.com> wrote in message
news:cH**************@cpmsftngxa06.phx.gbl...
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.

Nov 20 '05 #5
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.

Nov 20 '05 #6
a
That does it!

Thanks
""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:kg**************@cpmsftngxa06.phx.gbl...
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.

Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: brian.vincent | last post by:
I'm trying to use the ssh2 functions to run a graphical app. I have no problem opening ssh2_shell and running something like "/bin/ls /tmp". However when I try to do something like:...
11
by: Alban Hertroys | last post by:
Oh no! It's me and transactions again :) I'm not really sure whether this is a limitation of psycopg or postgresql. When I use multiple cursors in a transaction, the records inserted at the...
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
0
by: Deepak Rao G | last post by:
Hi all, Could someone suggest to some good material on the internet for DB2 Procedures & cursors. Just taking DBA exams (Exam-700 & Exam-701) soon. Would appreciate any notes/tips (Besides...
0
by: Glenn Engelbart | last post by:
I am trying to find out a way to get more code re-use & object orientation in the UI portion of my apps. (There already is plenty of both in the DataAccess & Business Logic portion of my apps. ...
10
by: Just Me | last post by:
Does Me.Cursor.Current=Cursors.WaitCursor set the current property of Me.Cursor to Cursors.WaitCursor And Me.Cursor.Current=Cursors.Default set the Me.Current property to something (default)...
5
by: Rob R. Ainscough | last post by:
Does anyone know why two separate ASP.NET web application running under the same web server (IIS 6) would cause this error (Application Event viewer): "It is not possible to run two different...
17
by: vishal | last post by:
I am new to sql and require some help on cursors? what are they and how and why are they used for??? it will be kind enough if anyone helps me in this regards.. regards vishal jain.
1
by: jmdeschamps | last post by:
I made a document on Tkinter cursors (mouse pointers?), pairing the cursor image with its name... Not a great deal of magic here since anyone can program something to see the different cursors on...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.