Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a resource bitmap that I want in the ribbon in an Excel Add-in.

I am not using MFC or ATL.

What I have tried:

I am using IDispatch Invoke for the call to getImage from ribbon xml.

I can return a string (VARIANT - BStr) representing one of the built-in Excel images but I want to return a resource Bitmap instead.
Posted
Updated 18-Jun-18 1:40am
v2
Comments
benjaminemanuel13 17-Jun-18 19:55pm    
Thanks, but that solution is using (I think) MFC and I'm using raw c++.
Jochen Arndt 18-Jun-18 3:26am    
Please show the dispatch function declaration / description. If it is a IPictureDisp
(see https://msdn.microsoft.com/en-us/library/windows/desktop/ms680762(v=vs.85).aspx) callback function, just return the HBITMAP handle by casting to the return type.
benjaminemanuel13 18-Jun-18 6:47am    
Indeed, I create an IPictureDisp from the bitmap, set the VARIANT Type to VT_DISPATCH, set the VARIANT pdispVal to point to the picture and hey presto, it works! Thanks a lot!!
KarstenK 18-Jun-18 7:34am    
write it as answer to close the Q&A

1 solution

I simply needed to create an IPictureDisp from the resourced bitmap and in Invoke set the returned VARIANT type to VT_DISPATCH, set the VARIANT pdispVal value to the IPictureDisp and return it for the getImage function.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900