* fixed stream resource unicode issue

git-svn-id: trunk@1160 -
This commit is contained in:
oro06 2005-09-23 10:02:01 +00:00
parent 2476957db9
commit 84cd7d6706

View File

@ -755,6 +755,30 @@ end;
{* TResourceStream *} {* TResourceStream *}
{****************************************************************************} {****************************************************************************}
{$ifdef UNICODE}
procedure TResourceStream.Initialize(Instance: THandle; Name, ResType: PWideChar);
begin
Res:=FindResource(Instance, Name, ResType);
if Res=0 then
raise EResNotFound.CreateFmt(SResNotFound,[Name]);
Handle:=LoadResource(Instance,Res);
if Handle=0 then
raise EResNotFound.CreateFmt(SResNotFound,[Name]);
SetPointer(LockResource(Handle),SizeOfResource(Instance,Res));
end;
constructor TResourceStream.Create(Instance: THandle; const ResName: WideString; ResType: PWideChar);
begin
inherited create;
Initialize(Instance,PWideChar(ResName),ResType);
end;
constructor TResourceStream.CreateFromID(Instance: THandle; ResID: Integer; ResType: PWideChar);
begin
inherited create;
Initialize(Instance,PWideChar(ResID),ResType);
end;
{$else UNICODE}
procedure TResourceStream.Initialize(Instance: THandle; Name, ResType: PChar); procedure TResourceStream.Initialize(Instance: THandle; Name, ResType: PChar);
begin begin
Res:=FindResource(Instance, Name, ResType); Res:=FindResource(Instance, Name, ResType);
@ -766,19 +790,17 @@ procedure TResourceStream.Initialize(Instance: THandle; Name, ResType: PChar);
SetPointer(LockResource(Handle),SizeOfResource(Instance,Res)); SetPointer(LockResource(Handle),SizeOfResource(Instance,Res));
end; end;
constructor TResourceStream.Create(Instance: THandle; const ResName: string; ResType: PChar); constructor TResourceStream.Create(Instance: THandle; const ResName: string; ResType: PChar);
begin begin
inherited create; inherited create;
Initialize(Instance,pchar(ResName),ResType); Initialize(Instance,pchar(ResName),ResType);
end; end;
constructor TResourceStream.CreateFromID(Instance: THandle; ResID: Integer; ResType: PChar); constructor TResourceStream.CreateFromID(Instance: THandle; ResID: Integer; ResType: PChar);
begin begin
inherited create; inherited create;
Initialize(Instance,pchar(PtrInt(ResID)),ResType); Initialize(Instance,pchar(PtrInt(ResID)),ResType);
end; end;
{$endif UNICODE}
destructor TResourceStream.Destroy; destructor TResourceStream.Destroy;