HanuSoftware
asked on
Loading Bitmap image from ATL COM dll to MFC Client
Dear Experts,
We have a ATL COM dll which populates its control over remote MFC Client.
MFC Client passes RemoteHandle to COM dll for this job.
Now we have to load a bitmap image from dll over the dialog of MFC Client.
We have tried to it in OnPaint handler of dll but loading bitmap by LoadBitmap api requires Handle to the instance of the module whose executable file contains the bitmap to be loaded which i think is not possible to retreive.
Kindly let us know how can we do it.
We have a ATL COM dll which populates its control over remote MFC Client.
MFC Client passes RemoteHandle to COM dll for this job.
Now we have to load a bitmap image from dll over the dialog of MFC Client.
We have tried to it in OnPaint handler of dll but loading bitmap by LoadBitmap api requires Handle to the instance of the module whose executable file contains the bitmap to be loaded which i think is not possible to retreive.
Kindly let us know how can we do it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry it should be
2.
IYourInterface::GetBitmapM ethod([out ] LPBITMAPINFO **pbih, [out] BYTE **pbtBitmap)
2.
IYourInterface::GetBitmapM
Why would one pass the bitmap via a function call if you can just load it??
"Why would one pass the bitmap via a function call if you can just load it?"
1. To follow COM rules (bending them a little if necessary).
Accessing COM object through properties & methods.
Alternatively HBITMAP handler could be passed as a method parameter (can be only used as local object).
IYourInterface::GetBitmap( [out] HBITMAP *phBmp)
{
// _Module.m_hInstance - DLL instance handle kwown to COM object in ATL
}
2. From COM point of view implementing DLL is hidden - there's only CLSID & object instance and no COM method of knowing DLL or instance handle.
1. To follow COM rules (bending them a little if necessary).
Accessing COM object through properties & methods.
Alternatively HBITMAP handler could be passed as a method parameter (can be only used as local object).
IYourInterface::GetBitmap(
{
// _Module.m_hInstance - DLL instance handle kwown to COM object in ATL
}
2. From COM point of view implementing DLL is hidden - there's only CLSID & object instance and no COM method of knowing DLL or instance handle.
You have a point there, but I'd rather pass the module name to keep that transparent, but not the whole resource.
>>contains the bitmap
Not a big deal, just use
HINSTANCE hInst = GetModuleHandle("AtlComDll
LoadBitmap(hInst,MAKEINTRE