Solved

Pass Bitmap from VB to VC++

Posted on 2002-04-28
8
323 Views
Last Modified: 2013-12-03
Hi,

I've written an MFC ActiveX control.

I want to be able to pass a bitmap into this control.

What is the 'type' of the property I need to create in order to receive the bitmap ??

I've tried creating an LPDISPATCH property, and put the following...

CBitmap MyBMP;
MyBMP=(CBitmap)m_bitmapfromvb;

But the compiler says that it can't translate from one to the other. )-:

Smg.
0
Comment
Question by:smegghead
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 10

Author Comment

by:smegghead
ID: 6974878
Sorry, forgot to mention, the bitmap is coming from VB.
0
 
LVL 25

Expert Comment

by:clockwatcher
ID: 6975333
When you say the bitmap is coming from VB, what format is it in VB and how are you trying to pass it?  Is it an array of bytes or is it a COM object supporting IPicture (like a StdPicture or the Image property of an Image Control or a PictureBox) or is it a handle to a bitmap?
0
 
LVL 10

Author Comment

by:smegghead
ID: 6976504
Hi,

Probably either using LoadPicture or LoadResPicture.

But if there's a different way, which makes it easier to pass into VC++ then I'm quite flexible on that.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:DrDelphi
ID: 6977034
I'm fairly sure that you'll have to use IPictureDisp. At least my experience sending bitmap from my Delphi/BCB libaries to VB has always entailed using it.I've no reason to believe that it would be any different going the other way.




Good luck!!
0
 
LVL 10

Author Comment

by:smegghead
ID: 6977262
OK, but do you know what OLE type I should be expecting in the C++ program ?? should I use LPUKNOWN or LPDISPATCH ?? (just a guess)
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 6977585
LPUNKNOWN. Again, to the best of my knowledge and experience.


Good luck!!
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 50 total points
ID: 6977896
The following works for me with ATL.  I don't know MFC so probably can't help much with creating a CBitmap from an IPictureDisp.

C++ code--

STDMETHODIMP CTesting::DrawImage(LPDISPATCH image)
{

   IPicture* picture;

   if (SUCCEEDED(image->QueryInterface(IID_IPicture, reinterpret_cast<void**>(&picture))))
   {
      HDC hdc = GetDC(NULL);

      OLE_YSIZE_HIMETRIC height;
      OLE_XSIZE_HIMETRIC width;


      picture->get_Height(&height);
      picture->get_Width(&width);

      picture->Render(hdc, 1, 1, 100, 100, 0, 0, width, height, NULL);
         
      picture->Release();

      ReleaseDC(NULL, hdc);
   }

   return S_OK;
}


VB code --

Sub TESTING()

    Dim myATL As Object
    Dim myPic As StdPicture
   
    Set myATL = CreateObject("VBPIC.TESTING")
    Set myPic = LoadPicture("c:\testing123.bmp")
    myATL.drawimage myPic
   
End Sub
0
 
LVL 10

Author Comment

by:smegghead
ID: 6980010
Hi,

I was being stupid... there is actually a parameter type called LPPICTUREDISP.

This accepts the return value from a LoadPicture, or LoadResPicture in VB.

Once in C++ it is coded as follows...

CPictureHolder MyPic;
MyPic.SetPictureDispatch(InPicture);

Where InPicture is of type LPPICTUREDISP.

So, it's all sorted.

I will give these points to clockwatcher, as he/she gave some other useful advice.

Thanks all
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Beginner to Unreal Engine 4 5 119
VS2015 Redefinition errors 4 104
DCT of  2D array using fftw in c++ 9 133
visual C++ 1 41
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

734 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