ATL COM DLL and Bitmaps
-
I am trying to create a visualization for the Windows Media Player. The SDK comes with a wizard that creates an ATL class for a COM DLL with the appropriate interfaces etc. One of the functions is Render which is passed a HDC. Using the HDC one can draw whatever visualization. All this works fine. Now I want to display some bitmaps. So in the DLL I added a Bitmap into the resource by importing a picture. Then I am trying to use LoadBitmap or LoadImage. Both fail. I get the following error when I call GetLastError: 1814: The specified resource name cannot be found in the image file. I am assuming I am getting this because I do not have the propoer HINSTANCE for the call to LoadImage or LoadBitmap. I am using a NULL not knowing how to get the HINSTANCE for the media player. Or should it be one for the DLL? Now I am all confused..... help........ Thanks...
-
I am trying to create a visualization for the Windows Media Player. The SDK comes with a wizard that creates an ATL class for a COM DLL with the appropriate interfaces etc. One of the functions is Render which is passed a HDC. Using the HDC one can draw whatever visualization. All this works fine. Now I want to display some bitmaps. So in the DLL I added a Bitmap into the resource by importing a picture. Then I am trying to use LoadBitmap or LoadImage. Both fail. I get the following error when I call GetLastError: 1814: The specified resource name cannot be found in the image file. I am assuming I am getting this because I do not have the propoer HINSTANCE for the call to LoadImage or LoadBitmap. I am using a NULL not knowing how to get the HINSTANCE for the media player. Or should it be one for the DLL? Now I am all confused..... help........ Thanks...
Finally got it. I needed to use _Module.GetResourceInstance()
-
I am trying to create a visualization for the Windows Media Player. The SDK comes with a wizard that creates an ATL class for a COM DLL with the appropriate interfaces etc. One of the functions is Render which is passed a HDC. Using the HDC one can draw whatever visualization. All this works fine. Now I want to display some bitmaps. So in the DLL I added a Bitmap into the resource by importing a picture. Then I am trying to use LoadBitmap or LoadImage. Both fail. I get the following error when I call GetLastError: 1814: The specified resource name cannot be found in the image file. I am assuming I am getting this because I do not have the propoer HINSTANCE for the call to LoadImage or LoadBitmap. I am using a NULL not knowing how to get the HINSTANCE for the media player. Or should it be one for the DLL? Now I am all confused..... help........ Thanks...
in your DLLMain myBitmap = LoadBitmap( hInstance , MAKEINTRESOURCE( IDB_MY_BITMAP); and in your control class, or wherever you need it, do an extern HBITMAP myBitmap; There may be other ways.