• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3457
  • Last Modified:

How to change a mouse cursor to a wait cursor (hourglass) in a command line application

I have a command line application that is called when a button is pressed in a seperate application (which cannot be modified). Since the command line application takes some time to run I would like to change the mouse cursor to a wait cursor (hourglass). I've tried:

Cursor.Current = Cursors.WaitCursor
 ' some method calls
Cursor.Current = Cursors.Default

I think this does not work because I have no control or form. Is there any way around this?

My code is:

    Function ResetLogin() As Boolean
        ' Purpose: Reset the login info
        Dim sUserName As String
        Dim sPassword As String
       
        Try
            deleteUserNameAndPassword(sUserName, sPassword)
            promptUserForUserNameAndPassword(sUserName, sPassword)
            Cursor.Current = Cursors.WaitCursor
            validateUserNameAndPassword(sUserName, sPassword)
        Catch ex As Exception
            MsgBox("Error: Could not start or login.  " & ex.Message, MsgBoxStyle.Exclamation + MsgBoxStyle.MsgBoxSetForeground, AppName)
            Return False
        Finally
            Cursor.Current = Cursors.Default
        End Try

        MsgBox("Reset login information successfully.  ", MsgBoxStyle.Information + MsgBoxStyle.MsgBoxSetForeground, AppName)
        Return True
    End Function


If you need any other information please let me know.
Thanks in advance for your help.
0
andrewting
Asked:
andrewting
  • 2
1 Solution
 
kouroshparsaCommented:
this does not work
        System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
so, try this:
        Me.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
===============
If none works, it is because cursor is inherited by forms of windows
I think that you should change the cursor where you have a button. You'll be able to determine the time required to load the other application in various ways depending on what the other application is.
===========
Another idea is to declare a form and dispose it at the end:
Dim tempForm as New Form
Me.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
0
 
andrewtingAuthor Commented:
Hi koouroshparsa,
I've tried all of your suggestions.
1. I am unable to do Me.Cursor.Current since my function is in a module and not in a class.
2. Unfortunately I can not change the cursor to where I have the button because that form is in a completely seperate application and my application can not 'talk' to it but only gets called by it.
3.  I've tried this as well and unfortunately this does not work.
Thanks
0
 
Bob LearnedCommented:
You need a visible form in order to change the cursor from your application.  You might be able to use the SetCursor Windows API, but I haven't tested that theory.

Bob
0
 
andrewtingAuthor Commented:
Thanks Bob.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now