: : I assume that you linked it into the source code using the $R directive.
: : You can check if the resource exists in your app with the FindResource() function. Here is what the code should look like:
: :
: : MyRes := FindResource(hInstance, PChar(MyResourceName), RT_Bitmap);
: : if MyRes = 0 then
: : ShowMessage('Error: resource doesn't exist')
: : else
: : // Use resource;
: :
: : You can find more info on the function in the Windows SDK help files.
: :
:
: Thanks again for your input. I added your code to my procedure and I get the same result. MyRes returns a non-zero number. Here's the code.
:
: implementation
:
: {$R *.dfm}
: {$R Nikud.res}{ <--- This is the Resource File }
:
: procedure TForm1.FormCreate(Sender: TObject);
: var
: HebRes : TResourceStream;
: MyRes : Integer;
: begin
: HebRes := nil;
: try
: MyRes := FindResource(hInstance, PChar('DAGESH'), RT_Bitmap);
: if MyRes = 0 then
: ShowMessage('Error: resource doesn''t exist')
: else begin
: HebRes := TResourceStream.Create(HInstance,'DAGESH',RT_Bitmap);
: HebRes.Position := 0;
: {Next line gives ERROR: "Bitmap Image is not valid"}
: Image1.Picture.Bitmap.LoadFromStream(HebRes);
: ImageList1.AddMasked(Image1.Picture.Bitmap,clWhite);
: end;
: finally
: if HebRes <> nil then HebRes.Free;
: end;
: end;
:
: end.
:
:
:
Perhaps you could try to use the LoadResource() function, and then set the resulting handle to the bitmap in your image.
If that doesn't work, then all I can suggest is that you add a new hidden image to your form and load the bitmap into it. Then you can simply copy the bitmap from one image to the other. That will certainly work.