C ++动画光标

时间:2010-09-07 11:45:10

标签: c++ animation c++builder

我正在使用此代码在C ++ builder中调用动画游标:

void __fastcall TcfListatArtikujtLst::FormActivate(TObject *Sender)
{
   ActiveControl = cxGrid1;
   Application->ProcessMessages();

   const int cnCursorID1 = 1;
   Screen->Cursors[cnCursorID1] = LoadCursorFromFile("cursors\\hourglas.ani");
   Cursor = cnCursorID1;

   try
   {
       dmDM1->prcArtikujt->Close();
       dmDM1->prcArtikujt->Parameters->Refresh();
       dmDM1->prcArtikujt->Prepared;

       dmDM1->CDSArtikujt->Data = dmDM1->DSPArtikujt->Data;
       dmDM1->CDSArtikujt->Open();
   }
   __finally
   {
       Screen->Cursor = crDefault;
   }
}

问题是动画在try-finally块中生效,并且不会重新执行默认光标。

干杯, Nijazi Citaku

2 个答案:

答案 0 :(得分:0)

我强烈怀疑光标已加载但未更改,直到Windows消息循环继续。

在文件加载光标后尝试一个ProcessMessages。

光标不会消失,因为您没有告诉表单返回正常光标。您告诉屏幕返回正常光标。

尝试:

__finally
{
   Cursor = crDefault;
}

答案 1 :(得分:0)

这是解决方案:

void __fastcall TcfListatArtikujtLst::FormActivate(TObject *Sender) 
{ 
   ActiveControl = cxGrid1; 
   Application->ProcessMessages(); 

   const int cnCursorID1 = 1; 
   Screen->Cursors[cnCursorID1] = LoadCursorFromFile("cursors\\hourglas.ani"); 
   Application->ProcessMessages;
   Screen->Cursor = cnCursorID1; 

   try 
   { 
       dmDM1->prcArtikujt->Close(); 
       dmDM1->prcArtikujt->Parameters->Refresh(); 
       dmDM1->prcArtikujt->Prepared; 

       dmDM1->CDSArtikujt->Data = dmDM1->DSPArtikujt->Data; 
       dmDM1->CDSArtikujt->Open(); 
   } 
   __finally 
   { 
       Screen->Cursor = crDefault; 
   } 
}