views:

48

answers:

2

Hi everybody,

I'm using this code to invoke animated cursor in 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;
   }
}

Problem is that animation takes effect atre try-finally block and doesn't retun do default cursor.

Cheers, Nijazi Citaku

A: 

I strongly suspect that the cursor is loaded but not changed until the Windows message loop continues.

Try a ProcessMessages AFTER the load cursor from file.

The cursor is not going away because you have not told the form to go back to a normal cursor. You have told the Screen to go back to the normal cursor.

Try:

__finally
{
   Cursor = crDefault;
}
gbrandt
A: 

Hi everybody, here is ths solution :

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; } }

Nijazi Citaku