瀏覽代碼

Added bcimagebutton LoadFromBitmapResource to load the image stored inside the executable.

lainz 10 年之前
父節點
當前提交
d40aac6fac
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. 14 0
      bcimagebutton.pas

+ 14 - 0
bcimagebutton.pas

@@ -229,6 +229,7 @@ type
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
     { It loads the 'BitmapFile' }
+    procedure LoadFromBitmapResource(Resource: string; ResourceType: PChar);
     procedure LoadFromBitmapFile;
     procedure Assign(Source: TPersistent); override;
     { Streaming }
@@ -1148,6 +1149,19 @@ begin
   inherited Destroy;
 end;
 
+procedure TBCCustomImageButton.LoadFromBitmapResource(Resource: string; ResourceType: PChar);
+var
+  res: TResourceStream;
+begin
+  res := TResourceStream.Create(HInstance, Resource, ResourceType);
+
+  if BitmapOptions.Bitmap <> nil then
+    BitmapOptions.Bitmap.Free;
+
+  BitmapOptions.Bitmap := TBGRABitmap.Create(res);
+  res.Free;
+end;
+
 procedure TBCCustomImageButton.LoadFromBitmapFile;
 begin
   if BitmapFile <> '' then