Changing Cursor Shape in Visual Cobol

[Migrated content. Thread originally posted on 09 December 2011]

Hi All,

Any one know the code to change the cursor shape to an hour glass when going off and doing a large SQL job and then resetting back to an arrow when finished?

Kind regards

  • Verified Answer

    In a Windows Forms project you can do the following:

          $set ilusing"System.Windows.Forms"
           class-id testhourglass.Form1 is partial
                     inherits type System.Windows.Forms.Form.
           working-storage section.
           method-id NEW.
           procedure division.
               invoke self::InitializeComponent
           end method.

           method-id button1_Click final private.
           procedure division using by value sender as object e as type System.EventArgs.

               set type Cursor::Current to type Cursors::WaitCursor
               invoke type System.Threading.Thread::Sleep(5000)
               set type Cursor::Current to type Cursors::Default

              end method.
           end class.
  • Hi Chris,

    Again many thanks that works really well.

    Out of interest can you pls advise what this line does?

    $set ilusing"System.Windows.Forms"

    Kind regards

  • It brings the namespace System.Windows.Forms into the program so that the compiler will recognize its classes without having to specify the entire name.

    For instance, the class named Cursor is actually in the namespace System.Windows.Forms so if you did not specify:
    $set ilusing"System.Windows.Forms"

    You would have to reference the Cursor and Cursors classes using the full name like:

    set type System.Windows.Forms.Cursor::Current to type System.Windows.Forms.Cursors::WaitCursor

    You can also set these on the Namespace tab of the Project Properties page by selecting the namespaces to include.