如何在程序启动时显示沙漏
2005-12-13 12:14
633 查看
Call this function to display the cursor as an hourglass when you expect a command to take a noticeable time interval to execute.
The actions of BeginWaitCursor are not always effective outside of a single message handler as other actions, such as OnSetCursor handling, could change the cursor.
Call EndWaitCursor to restore the previous cursor.
void BeginWaitCursor( );
Remarks
The framework calls this function to show the user that it is busy, such as when a CDocument object loads or saves itself to a file.The actions of BeginWaitCursor are not always effective outside of a single message handler as other actions, such as OnSetCursor handling, could change the cursor.
Call EndWaitCursor to restore the previous cursor.
Example
// The following example illustrates the most common case // of displaying the hourglass cursor during some lengthy // processing of a command handler implemented in some // CCmdTarget-derived class, such as a document or view. void CMyView::OnSomeCommand() { BeginWaitCursor(); // display the hourglass cursor // do some lengthy processing EndWaitCursor(); // remove the hourglass cursor } // The next example illustrates RestoreWaitCursor. void CMyView::OnSomeCommand() { BeginWaitCursor(); // display the hourglass cursor // do some lengthy processing // The dialog box will normally change the cursor to // the standard arrow cursor, and leave the cursor in // as the standard arrow cursor when the dialog box is // closed. CMyDialog dlg; dlg.DoModal(); // It is necessary to call RestoreWaitCursor here in order // to change the cursor back to the hourglass cursor. RestoreWaitCursor(); // do some more lengthy processing EndWaitCursor(); // remove the hourglass cursor } // In the above example, the dialog was clearly invoked between // the pair of calls to BeginWaitCursor and EndWaitCursor. // Sometimes it may not be clear whether the dialog is invoked // in between a pair of calls to BeginWaitCursor and EndWaitCursor. // It is permissable to call RestoreWaitCursor, even if // BeginWaitCursor was not previously called. This case is // illustrated below, where CMyView::AnotherFunction does not // need to know whether it was called in the context of an // hourglass cursor. void CMyView::AnotherFunction() { // some processing ... CMyDialog dlg; dlg.DoModal(); RestoreWaitCursor(); // some more processing ... } // If the dialog is invoked from a member function of // some non-CCmdTarget, then you can call CWinApp::DoWaitCursor // with a 0 parameter value to restore the hourglass cursor. void CMyObject::AnotherFunction() { CMyDialog dlg; dlg.DoModal(); AfxGetApp()->DoWaitCursor(0); // same as CCmdTarget::RestoreWaitCursor }
相关文章推荐
- 如何让程序启动后不显示窗体?
- 如何使对话框程序启动以及主窗口最小化时不在任务栏上显示
- A程序后台启动的B的Activity后,A程序后台又启动了A的Activity,如何在A的Activity中按返回不显示B的Activity
- VB程序启动后如何在通知区域显示
- VB程序启动后如何在通知区域显示
- 如何在程序中启动并显示“设置”程序
- IOS开发中如何判断程序第一次启动(根据判断结果决定是否显示新手操作引导)
- Android如何做到应用程序图标隐藏,由第三方程序显示启动
- 如何使对话框程序启动以及主窗口最小化时不在任务栏上显示
- [VB.NET]如何在程序启动后让视图正好显示datagridview的最后一行?
- 已启动程序,再启动通知原程序显示
- 7.Linux内核如何装载和启动一个可执行程序
- winform 入门开发,VS 程序自带的日历控件日期显示格式是xxxx年x月x日,如何改成xxxx-xx-xx 的格式 ?
- Android adb.exe程序启动不起来,如何处理
- 如何在应用程序中启动其他程序(三种方法)
- 如何给自己编写的程序隐蔽的设置开机启动
- Linux非root用户如何使用80端口启动程序
- iOS程序启动的时候隐藏状态栏,启动完成之后显示状态栏
- 如何编写51单片机超声波测距SR04_lcd1602显示程序
- VS2013 编程环境设置,如何显示C++程序行号。