I am trying to play with the LoadIconWithScaleDown API. I am using Delphi 2007, I wrote a simple sample program where upon a button click I call COMMCTRL.LoadIconWithScaleDown. I tried various combinations, with instance zero, with instance set to hInstance, for the second parameter, I tried to pass the current module name, MAKEINTRESOURCE( IDI_APPLICATION), ... Always no luck, I always get a return value of -2147467263. Any idea what I am doing wrong?
Edited upon David's suggestion to show how I tried to call the API.
procedure TForm31.Button1Click(Sender: TObject);
var moduleName : string;
var moduleNameW : widestring;
var retVal : HRESULT;
var iconHandle : HICON;
begin
iconHandle := 0;
SetLength( moduleName, 1024);
WINDOWS.GetModuleFileName(
hInstance,
PCHAR(moduleName),
LENGTH(moduleName));
moduleNameW := moduleName;
retVal := COMMCTRL.LoadIconWithScaleDown(
HINSTANCE,
PWidechar(moduleNameW),
image1.width,
image1.height,
iconHandle);
end;
See Question&Answers more detail:os