Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

EResNotFound exception thrown by custom component

mtronixmtronix Posts: 10Member
Hello,
OK, so here is some background. I am upgrading this old program from builder 4. Now, the old program contained custom built components which I can re-build. However, these guys have issues. The components were all made as *.bpl packages which you can later add using Component->add component in the IDE
One of the components has several bitmaps in it. The *.bpl file has a resource file, "rmsctrl.rc" which points to each graphic like this

IDB_LEVEL8 BITMAP "level8.bmp"

and I have picture level8.bmp extracted in my directory.

Now this file has a header that says #include "Resource.h" at the top of it.

Inside Resource.h I have

#define IDB_LEVEL8 1009

So now, the main program makes a call using

FBitmap->LoadFromResourceID((int)HInstance, S_BitmapIndex[FLevel]);

// Draw stuff on canvas
FBitmap->Canvas->StretchDraw(Rect, FBitmap);

// Draw RMS values
DrawElectrodes(FBitmap->Canvas, false);
DrawVectors(FBitmap->Canvas);

The package will build. When I place the package on a form, it even shows the bitmap. However, at runtime, it throws the error EResNotFound exception 'Resource 1009 not found'

Any ideas?

Thanks

Comments

  • mtronixmtronix Posts: 10Member
    Hi,
    I needed to add a pragma statement to include the resource file in the original component project.

    : Hello,
    : OK, so here is some background. I am upgrading this old
    : program from builder 4. Now, the old program contained custom built
    : components which I can re-build. However, these guys have issues.
    : The components were all made as *.bpl packages which you can later
    : add using Component->add component in the IDE
    : One of the components has several bitmaps in it. The *.bpl
    : file has a resource file, "rmsctrl.rc" which points to each graphic
    : like this
    :
    : IDB_LEVEL8 BITMAP "level8.bmp"
    :
    : and I have picture level8.bmp extracted in my directory.
    :
    : Now this file has a header that says #include "Resource.h" at the
    : top of it.
    :
    : Inside Resource.h I have
    :
    : #define IDB_LEVEL8 1009
    :
    : So now, the main program makes a call using
    :
    : FBitmap->LoadFromResourceID((int)HInstance, S_BitmapIndex[FLevel]);
    :
    : // Draw stuff on canvas
    : FBitmap->Canvas->StretchDraw(Rect, FBitmap);
    :
    : // Draw RMS values
    : DrawElectrodes(FBitmap->Canvas, false);
    : DrawVectors(FBitmap->Canvas);
    :
    : The package will build. When I place the package on a form, it even
    : shows the bitmap. However, at runtime, it throws the error
    : EResNotFound exception 'Resource 1009 not found'
    :
    : Any ideas?
    :
    : Thanks
  • mtronixmtronix Posts: 10Member
    Hello,
    I found the solution. I needed to add a #pragma "Resource.rc" statement at the top of the package. This let it work.

    : Hi,
    : I needed to add a pragma statement to include the resource file
    : in the original component project.
    :
    : : Hello,
    : : OK, so here is some background. I am upgrading this old
    : : program from builder 4. Now, the old program contained custom built
    : : components which I can re-build. However, these guys have issues.
    : : The components were all made as *.bpl packages which you can later
    : : add using Component->add component in the IDE
    : : One of the components has several bitmaps in it. The *.bpl
    : : file has a resource file, "rmsctrl.rc" which points to each graphic
    : : like this
    : :
    : : IDB_LEVEL8 BITMAP "level8.bmp"
    : :
    : : and I have picture level8.bmp extracted in my directory.
    : :
    : : Now this file has a header that says #include "Resource.h" at the
    : : top of it.
    : :
    : : Inside Resource.h I have
    : :
    : : #define IDB_LEVEL8 1009
    : :
    : : So now, the main program makes a call using
    : :
    : : FBitmap->LoadFromResourceID((int)HInstance, S_BitmapIndex[FLevel]);
    : :
    : : // Draw stuff on canvas
    : : FBitmap->Canvas->StretchDraw(Rect, FBitmap);
    : :
    : : // Draw RMS values
    : : DrawElectrodes(FBitmap->Canvas, false);
    : : DrawVectors(FBitmap->Canvas);
    : :
    : : The package will build. When I place the package on a form, it even
    : : shows the bitmap. However, at runtime, it throws the error
    : : EResNotFound exception 'Resource 1009 not found'
    : :
    : : Any ideas?
    : :
    : : Thanks
    :

Sign In or Register to comment.