Problems with CAnimateCtrl::Open(resourceID)
Posted on 1997-06-03
I am having considerable trouble getting CAnimateCtrl::Open(ID) to work,
where ID is a resource ID. Microsoft support seems totally clueless
about how to help me figure out what's wrong myself (I don't expect them
to tell me what's wrong, given the complexity of the program.)
Here's my scenario:
Windows NT 4.0
MFC SDI app
main executable contains only an icon resource
Several code DLLs which are all MFC Extension DLLs
A number of resource-only DLLs, which are also MFC Extension DLLs
The app's InitInstance method does the following:
1. dynamically activates the two major resource-only DLLs (one
contains our general message text, the other the resources for the
app's GUI). This is for Internationalization purposes.
3. initializes our underlying 'workbench' code, which is a large
amount of shared code in DLLs
5. Calls OnFileNew
The app's mainframe::OnCreate() method does the following:
1. calls the CFrameWnd::OnCreate() method
2. calls the CreateToolBar method
The CreateToolBar method does the following:
1. Creates the toolbar in the standard way
2. expands one of the toolbar 'buttons' to the appropriate size for a
3. Sets up the button's window and rectangle, and does a
CAnimateCtrl::Create() (the Toolbar class I'm using is derived from
CToolBar, and includes a single member: a CAnimateCtrl.)
4. At this point, the code tries to CAnimateCtrl::Open() the
appropriate .AVI file. If it opens a file, the animation works;
If it opens the same AVI in a resource, it doesn't -- the Open returns FALSE,
meaning it failed.
I have tried about 3 or 4 ways of entering the AVI file into the
1. In the resource-only DLL that already contains the resources for
2. In the main executable (added to the simple Icon resource)
3. Directly, by editing the .RC file
4. Through the MSDEV Insert Resource/Custom mechanism
5. Through the MSDEV Import (file) mechanism
6. Directly, by editing the .RC2 file in the \res directory
They all appear to be equivalent, but nothing changes -- the Open on the
resource ID always fails. I have checked obvious things such as
uniqueness of the ID -- it is unique, and I've tried several different
values to make absolutely sure.
I'm assuming that the problem is that the resource isn't being found,
but I can't understand why. The code just preceding the call to Open
contains things like:
and it finds the resource from the IDR_TOOLBAR1 id; it's in the same
resource-only DLL as the resource ID for the AVI.
What makes it stranger is that I have modified the CMNCTRLS sample app
to test whether there might be a problem with CAnimateCtrl::Open(ID) --
it worked fine for that situation (the resource was added to the main
executable in that case). Furthermore, we have another group that is
doing something very similar (main executable, with several DLLs,
including a resource-only DLL that they are dynamically activating).
Their AVI animation code works, and I am at a loss to figure out what is
different (they use a different code base, but the operations are
I've stepped into the Open and through the mystical forest of Afx
stuff. I have a feeling that the problem might be related to the Afx
module state, but I can't figure out why one resource id is found in the
code just before, and this one isn't.
I'm pulling out my hair at this point.
Can anyone suggest how I might go about figuring out what's wrong? Like
hook into the code (somewhere in the SDK, I believe) that can tell me
whether it's finding the resource ID, whether it's the right kind of
resource, whether it's corrupted, whatever -- so that I can figure out
what to do to fix it.
All suggestions much appreciated...
I am using VC++ 4.2
I have tried setting the resouce handle before calling the CAnimateCtrl::Open(resourceID); no luck.
I also tried a number of variations using AFX_MANAGE_STATE(AfxSetStaticModuleState()) with no luck.