Форум - Ответы     (  К темам )
 ?  SET: CBUILDER: работа с *.ani - анимированными указателями (16-04-2003 10:23:38)
Вопрос такой - как в прогу подгрузить нарисованный мною курсор в формате ani, и как его использовать?
 Владимир (16-04-2003 20:17:28) http://cbuilder.ru
//---------------------------------------------------------------------------

const crMyCursor = 5;
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    Screen->Cursors[crMyCursor] =  LoadCursorFromFile("C:\\WINNT\\Cursors\\banana.ani");
    Memo1->Cursor = crMyCursor;
}
//---------------------------------------------------------------------------

или засунуть его в ресурс и подгружать через LoadCursor():

This example shows how to add custom cursors to an application.  It assumes that a custom cursor with the name NewCursor has been added to the resources (.RES file) of the application. You can add the cursor using the image editor. (Tools | Image Editor)
The following code makes this cursor available to the application via the constant crMyCursor, and sets it as the Memo1 cursor to the application.


const crMyCursor = 5;

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Screen->Cursors[crMyCursor] = LoadCursor(HInstance, "NewCursor");
  Memo1->Cursor = crMyCursor;
}


Custom cursors can be added to the Cursors property for use by the application or any of its controls. To add a custom cursor to an application:

1	Create the cursor resource using a resource editor.
2	Declare a cursor constant with a value that does not conflict with an existing cursor constant.
3	Use the Windows API function LoadCursor to obtain a handle to the new cursor. 
4	Set the Cursors property, indexed by the newly declared cursor constant, to the handle obtained from LoadCursor.

Note:	Don’t call the Windows API function DestroyCursor when finished with a custom cursor; C++Builder does this automatically.

 Павел (27-04-2003 11:46:23)
Также смотрите функцию:

LoadAniCursor(Instance: THandle; ResID: PChar): HCursor;

Declaration
function LoadAniCursor(Instance: THandle; ResID: PChar): HCursor;
Description
The LoadAniCursor function loads the specified animated cursor resource from
the executable (.EXE or .DLL) file associated with the specified application instance.

Instance parameter identifies an instance of the module whose executable file contains the animated cursor to be loaded.
ResID parameter points to a null-terminated string that contains the name of the animated cursor resource (RT_ANICURSOR type) to be loaded. Alternatively, this parameter can consist of the resource identifier in the low-order word and zero in the high-order word. The MakeIntResource function can also be used to create this value.

If the function succeeds, the return value is the handle of the newly loaded
animated cursor. If the function fails, the return value is 0 (zero).


support@cbuilder.ru