[Lazarus] Setting a cursor from resource

patspiper patspiper at gmail.com
Wed Mar 23 11:25:05 CET 2011


Hi,

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');

function LoadCursor(hInstance: HINST; lpCursorName: pchar): HCURSOR;
var
  ResType: TResourceType;
  ResHandle: TFPResourceHandle;
  GlobalHandle: TFPResourceHGlobal;
begin
  ResType := RT_GROUP_CURSOR;
  ResHandle := FindResource(hInstance, lpCursorName, PChar(ResType));
  if ResHandle = 0 then
    raise Exception.Create('ResName');
  GlobalHandle := LoadResource(hInstance, ResHandle);
  //LockResource(GlobalHandle);
  Result := ResHandle;
  //Result := GlobalHandle;
end;

Stephano




More information about the Lazarus mailing list