[Lazarus] Setting a cursor from resource
patspiper
patspiper at gmail.com
Wed Mar 23 12:54:46 CET 2011
On 03/23/2011 01:20 PM, Paul Ishenin wrote:
> 23.03.2011 17:25, patspiper wrote:
>> How can a control's cursor be set from a resource file?
>> The code below does not work, although the resource itself is found
>> and loaded.
>>
>> Panel1.cursor := LoadCursor(0, 'CURSOR_NAME');
> The same way as in delphi:
>
> const
> MyUserCursor = 1;
> Screen.Cursors[MyUserCursor] := LoadCursor(HInstance, 'Cursor_Name');
> Panel1.Cursor := MyUserCursor;
>
> LoadCursor works on windows only.
>
> To write cross platform code use:
>
> var
> Cur: TCursorImage;
> begin
> Cur := TCursorImage.Create;
> Cur.LoadFromResourceName('Cursor_Name');
> Screen.Cursors[MyUserCursor] := Cur.ReleaseHandle;
> Cur.Free;
> Panel1.Cursor := MyUserCursor;
> end;
EInvalidGraphic: Stream is not an icon type
Is the code above compatible with both RT_CURSOR and RT_GROUP_CURSOR
resources?
Thanks,
Stephano
More information about the Lazarus
mailing list