CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    1

    Wait cursor in dialog

    How to displaying the hourglass cursor during some lengthy processing of a command handler implemented in dialog base application.
    I've tried the BeginWaitCursor command, but like MSDN explain, the dialog box normally change the cursor to the standard arrow cursor, and leave the cursor in as the standard arrow cursor.



  2. #2
    Join Date
    Apr 1999
    Location
    Miami, FL
    Posts
    67

    Re: Wait cursor in dialog

    The nicest way is to use CWaitCursor, like this:

    void CMyDlg::OnLengthyOperation()
    {
    CWaitCursor wait; // set wait cursor

    ....
    } // restore cursor (on destruction)


    Alvaro

  3. #3
    Join Date
    Apr 1999
    Posts
    16

    Re: Wait cursor in dialog

    The point is that there is function
    OnSetCursor and each time u move mouse it restores old cursor. To prevent that u need:
    1st: set wait cursor by
    m_hCurrentCursor = AfxGetApp()->LoadStandardCursor(IDC_WAIT));
    SetCursor(m_hCurrentCursor);

    2nd: Overwrite function OnSetCursor in ur dialog or not dialog based application and put there code:

    BOOL CUrViewOrDialog::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
    {
    // TODO: Add your message handler code here and/or call default


    SetCursor(m_hCurrentCursor);
    return TRUE;

    //return CScrollView::OnSetCursor(pWnd, nHitTest, message);
    }

    When u need to set old cursor place next code:
    m_hCurrentCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
    SetCursor(m_hCurrentCursor);

    WBR Oak


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured