PDA

Ver la Versión Completa : TImageList & cursor raton


gallipi
16-05-2008, 13:27:46
Hola a todos,

Trabajo en una aplicación que tiene una barra de herramientas llena de iconos. Estos iconos estan almacenados en un Imagelist.

Cuando pulso un botón de la barra de herramientas quiero asignar el icono de éste, al cursor del ratón.


Código Delphi [-] (http://www.clubdelphi.com/foros/#) bmp:TBitmap
bmp :=TBitmap.Create;
...
...
imagelist1.getBitmap(index,bmp);

SetCursorIcon(bmp);




Imaginaba q la funcion getBitmap, cargaría el icono en la variable BMP, pero lo cierto es q no es asi.
¿Como puedo sacar una imagen del imgaList?


Gracias!!!!

juanlaplata
29-05-2008, 14:16:40
Me intereso lo que planteas, y buscando me tope en la ayuda del propio delphi. Eso si, no es tan facil como elegir cual image de la ImageList, pero tampoco tan dificil, al menos eso parece.

Lists the cursors available to the application.

property Cursors[Index: Integer]: HCursor;

Description

Use Cursor to access a particular cursor for use by the application or by a control within the application. TScreen includes several built-in cursors that are indexed by symbolic cursor constants. The image associated with the built-in cursors constants can be changed by setting the Cursors property.

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; Delphidoes this automatically.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 global cursor to the application.

const

crMyCursor = 5;
procedure TForm1.FormCreate(Sender: TObject);
begin
Screen.Cursors[crMyCursor] := LoadCursor(HInstance, 'NewCursor');
Cursor := crMyCursor;
end;
Suerte.
PD: como dije antes me intereso, y estoy probando de como hacerlo tambien. Cualquier avance estara por aqui. Saludos.

juanlaplata
06-06-2008, 15:09:14
Bueno, buceando un poco en el foro me tope con este hilo donde trataron el tema.
http://www.clubdelphi.com/foros/showthread.php?t=56107&highlight=agregar+imagenes+al+ejecutable