Link to home
Start Free TrialLog in
Avatar of HanuSoftware
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.
Avatar of jkr
jkr
Flag of Germany image

>>loading bitmap  by LoadBitmap api requires Handle to the instance of the module whose executable file
>>contains the bitmap

Not a big deal, just use

HINSTANCE hInst = GetModuleHandle("AtlComDll.dll");

LoadBitmap(hInst,MAKEINTRESOURCE(IDR_THEBITMAP));
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry it should be
2.

IYourInterface::GetBitmapMethod([out] LPBITMAPINFO **pbih, [out] BYTE **pbtBitmap)
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.

You have a point there, but I'd rather pass the module name to keep that transparent, but not the whole resource.