Setting the cursor of a dialog box, please help! 
Author Message
 Setting the cursor of a dialog box, please help!

I have a form and a dialog box.

When I open the dialog box, the dialog box does a lot of processing.  So, in
the dialog box code I set the cursor to the hourglass.

However, if the mouse is not over the dialog box when the dialog box is first
shown, the cursor stays as the default cursor.  Moving the mouse over the
dialog box doesn't change this.  I don't want to do an Application.DoEvents
during the processing in the dialog box, so any solution that uses the
MouseMove is out.

I don't want to move the mouse from code since this isn't a good UI thing to
do.

I can set the cursor in the form before showing the dialog box and then
everything is okay.  Here is where my problem is -- when the dialog box is up
and it updates its information the wait cursor is needed again.  However, the
cursor again will not go to the hourglass unless it is over the dialog box when
the processing starts.

How do I have the code in the dialog box set the cursor for the main form?  I'd
prefer not to introduce a method or public function in the main form.

I tried

Me.ParentForm.Cursor = ...

but this generates a runtime error that says it wasn't set to an object.

Thanks!



Mon, 31 Jan 2005 01:13:55 GMT  
 Setting the cursor of a dialog box, please help!
Hi,
It appears that your last line is failing because the ParentForm has not
been set.  Here are two ways to do this:
1)Make your dialogbox a child of the mainform -
    in the mainform designer, set IsMdiContainer = True
    when you create the dialogbox, set its parent to mainform:
        dialogbox.MdiParent = Me 'assuming me is mainform

Your last line of code should now work:
    Me.ParentForm.Cursor = System.Windows.Forms.Cursors.WaitCursor

2)if you don't want your main form to be an MdiContainer then you can pass
the mainform object to the dialogbox's constructor:
create a private member variable in your dialogbox's class
    private m_ParentForm as form

expand the "Windows Form Designer generated code" region and edit the New
sub:
  Public Sub New(ByVal ParentForm As Form)
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        m_ParentForm = ParentForm

  End Sub

Then make your cursor call change where you want by using m_ParentForm:
        m_ParentForm.Cursor = System.Windows.Forms.Cursors.WaitCursor
        me.Cursor = System.Windows.Forms.Cursors.WaitCursor

Hope this helps.
Steve, Ernest and Sunder
VB.Net

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> I have a form and a dialog box.

> When I open the dialog box, the dialog box does a lot of processing.  So,
in
> the dialog box code I set the cursor to the hourglass.

> However, if the mouse is not over the dialog box when the dialog box is
first
> shown, the cursor stays as the default cursor.  Moving the mouse over the
> dialog box doesn't change this.  I don't want to do an

Application.DoEvents
Quote:
> during the processing in the dialog box, so any solution that uses the
> MouseMove is out.

> I don't want to move the mouse from code since this isn't a good UI thing
to
> do.

> I can set the cursor in the form before showing the dialog box and then
> everything is okay.  Here is where my problem is -- when the dialog box is
up
> and it updates its information the wait cursor is needed again.  However,
the
> cursor again will not go to the hourglass unless it is over the dialog box
when
> the processing starts.

> How do I have the code in the dialog box set the cursor for the main form?
I'd
> prefer not to introduce a method or public function in the main form.

> I tried

> Me.ParentForm.Cursor = ...

> but this generates a runtime error that says it wasn't set to an object.

> Thanks!



Mon, 31 Jan 2005 04:09:34 GMT  
 Setting the cursor of a dialog box, please help!
That worked perfectly.  Thanks very much!


Mon, 31 Jan 2005 07:00:53 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help setting cursor position in a text box

2. Please help--Setting wait cursor for ENTIRE app

3. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

4. Open file Dialog Box in Access..Please Help

5. Please, help with find dialog box!

6. Fonts Common Dialog and Rich Text Box problem...please help

7. Activex and Dialog box!! help please getting crazy

8. Help please, Tabbed dialog box

9. Setting printing margins for rich text box - please help

10. How to Set Cursor Position in a Text Box

11. Having problem with Common Dialog Font Dialog - Please Help

12. Select Directory dialog box like Comm Dialog Box

 

 
Powered by phpBB® Forum Software