Browse Source

* fixed stream resource unicode issue

git-svn-id: trunk@1160 -
oro06 20 years ago
parent
commit
84cd7d6706
1 changed files with 27 additions and 5 deletions
  1. 27 5
      rtl/objpas/classes/streams.inc

+ 27 - 5
rtl/objpas/classes/streams.inc

@@ -755,30 +755,52 @@ end;
 {*                             TResourceStream                              *}
 {*                             TResourceStream                              *}
 {****************************************************************************}
 {****************************************************************************}
 
 
-procedure TResourceStream.Initialize(Instance: THandle; Name, ResType: PChar);
+{$ifdef UNICODE}
+procedure TResourceStream.Initialize(Instance: THandle; Name, ResType: PWideChar);
   begin
   begin
     Res:=FindResource(Instance, Name, ResType);
     Res:=FindResource(Instance, Name, ResType);
-    if Res=0 then 
+    if Res=0 then
       raise EResNotFound.CreateFmt(SResNotFound,[Name]);
       raise EResNotFound.CreateFmt(SResNotFound,[Name]);
     Handle:=LoadResource(Instance,Res);
     Handle:=LoadResource(Instance,Res);
     if Handle=0 then
     if Handle=0 then
       raise EResNotFound.CreateFmt(SResNotFound,[Name]);
       raise EResNotFound.CreateFmt(SResNotFound,[Name]);
-    SetPointer(LockResource(Handle),SizeOfResource(Instance,Res));    
+    SetPointer(LockResource(Handle),SizeOfResource(Instance,Res));
   end;
   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);
+  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: 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;