Registriert seit: 8. Mai 2005
Ort: Sondershausen
4.274 Beiträge
Delphi 6 Personal
|
AW: Animiertes LoadCursor?
25. Sep 2016, 11:45
Hi bei Delphi 6 PE funktioniert folgendes:
Delphi-Quellcode:
program AniCurFromRes;
{$R '_res\ExtraAppResources.res' '_res\ExtraAppResources.rc'}
uses
Forms,...;
{$R *.res}
begin
...
Delphi-Quellcode:
const
MY_CURSOR = $100;
// 8, 24 BPP for >= Win 7
// 1, 4, 8 BPP for < Win 7
function LoadAnimCursorFromRes(hInst: Cardinal; ResName, resourceTypeName: PChar): HCURSOR; overload;
var
hCur: HCURSOR;
hIco: HICON;
hRes: HRSRC;
dwResourceSize: DWORD;
hRsrcGlobal: HGLOBAL;
pResource: PBYTE;
begin
hCur := 0;
if (hInst > 0) then
begin
hRes := FindResource(hInst, ResName, resourceTypeName);
dwResourceSize := SizeofResource(hInst, hRes);
if (dwResourceSize > 0) then
begin
hRsrcGlobal := LoadResource(hInst, hRes);
if (hRsrcGlobal > 0) then
begin
pResource := PBYTE(LockResource(hRsrcGlobal));
if (pResource <> nil) then
begin
hIco := CreateIconFromResource(pResource, dwResourceSize, FALSE, $00030000);
//- or ->
//hIco := CreateIconFromResourceEx(pResource, dwResourceSize, FALSE, $00030000,
// 0, 0, LR_DEFAULTSIZE or LR_SHARED or LR_DEFAULTCOLOR);
//<-
UnlockResource(hRsrcGlobal);
end;
FreeResource(hRsrcGlobal);
end;
end;
end;
Result := HCURSOR(hIco);
end;
function LoadAnimCursorFromRes(hInst: Cardinal; ResName: PChar): HCURSOR; overload;
const
RT_ANICURSOR: PChar = 'ANICURSOR';
begin
Result := LoadAnimCursorFromRes(hInst, ResName, RT_ANICURSOR);
end;
procedure TForm1.Test;
begin
Screen.Cursors[MY_CURSOR] := LoadAnimCursorFromRes(hInstance, MAKEINTRESOURCE(100));
Cursor := MY_CURSOR;
end;
|
|
Zitat
|