术语 | CCmdTarget::BeginWaitCursor |
释义 | CCmdTarget::BeginWaitCursor void BeginWaitCursor( ); 说明: 本函数用于显示沙漏标(通常在命令执行时间较长时采用)。框架调用本函数显示沙漏标,告诉用户系统忙,例如在加载一个CDocument对象或把它保存到文件时。 在不是处理单个消息时,BeginWaitCursor可能不象其它函数那样有效,例如OnSetCursor的处理也能改变光标形状。调用函数EndWaitCursor可以恢复此前的光标。 示例: //The following example illustrates the most common case //of displaying the hourglass cursor during some lengthy //processing of a command handler implemented in some //CCmdTaget-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... MyDialog dlg; dlg.DoModal( ); RestoreWaitCursor( ); //some more processing } // If the dialog is invoked from a member function of // some non-CCmdTarget,the you 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 } 请参阅: CWaitCursor, CCmdTarget::EndWaitCursor, CCmdTarget::RestoreWaitCursor, CWinApp::DoWaitCursor |
随便看 |
|
MFC类库中文详解手册包含4274条MFC类库参考词条,基本涵盖了Microsoft基本类库中的类、全局函数、全局变量和宏的内容,是计算机编程的有利工具。