?
Solved

Loading Bitmap image from ATL COM dll to MFC Client

Posted on 2006-06-02
9
Medium Priority
?
748 Views
Last Modified: 2013-12-14
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.
0
Comment
Question by:HanuSoftware
  • 4
  • 3
7 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 16817522
>>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));
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 16817532
Sorry, that should be either

LoadBitmap(hInst,MAKEINTRESOURCE("THEBITMAP");

or

LoadBitmap(hInst,IDR_THEBITMAP);
0
 
LVL 8

Assisted Solution

by:mrblue
mrblue earned 500 total points
ID: 16822858
You could:

1. pack this bitmap in DLL into VARIANT structure and pass it as binary to client if you need OLE Automation

BITMAPINFO (if any palette entries follows)
bitmap bits

IYourInterface::GetBitmapMethod([out] VARIANT *pvBitmap)

2. turn bitmap into header & bitmap bits and pass it directly to client through (local or non-local) custom interface (no OLE automation)

IYourInterface::GetBitmapMethod([out] LPBITMAPINFO *pbih, [out] BYTE *pbtBitmap)

============================================
I think that above is a little bit more correct from COM point of view
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
LVL 8

Expert Comment

by:mrblue
ID: 16822865
Sorry it should be
2.

IYourInterface::GetBitmapMethod([out] LPBITMAPINFO **pbih, [out] BYTE **pbtBitmap)
0
 
LVL 86

Expert Comment

by:jkr
ID: 16823853
Why would one pass the bitmap via a function call if you can just load it??
0
 
LVL 8

Expert Comment

by:mrblue
ID: 16824058
"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.

0
 
LVL 86

Expert Comment

by:jkr
ID: 16825793
You have a point there, but I'd rather pass the module name to keep that transparent, but not the whole resource.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question