OnAction callback IRibbonControl C++

M

Michael Tissington

My OnAction callback is being invoked for a button.

I assign pDispParams->rgvarg[0].pdispVal to an IRibbonControlPtr (QI works)
but when I try to do anything (ptr->GetId()) with the ptr I get an Access
Violation

Any idea what else I need to do with the pointer ?
 
M

Michael Tissington

Some more information ...

I can do a GetIdsFromNames for "Id" and it returns the correct dispid of 1
However when I try to invoke it I get back the error 800a01a8 which seems to
be something about Object required ...

Any ideas please ?
 
W

Wei Lu [MSFT]

Hello Michael,

I would like to know this issue more clearly.

1.Do you mean that when you try to click the Button to invoke your callback
and you get the error message?

2. What does your OnAction do? Could you post the content here?

3. If you only try to show a MessageBox in the OnAction, did this issue
appeared?

The whole code of your add-in will be appreciated so that I can do further
troubleshoot.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Michael Tissington

Hello,

Not quite .. when I press a button my C++ OnAction function is called, and
as I understand it I should be passed a pointer to an IButtonControl.

Ribbon::IRibbonControlPtr pCtrl = NULL;
(LPDISPATCH)(pDispParams->rgvarg[0].pdispVal)->QueryInterface(Ribbon::IID_IRibbonControl,
(LPVOID *)&pCtrl);

OLECHAR * szId = L"Id";

DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
DISPID dspid;
VARIANT vtResult;

hr = pCtrl->GetIDsOfNames(IID_NULL, &szId, 1, LOCALE_SYSTEM_DEFAULT,
&dspid);
hr = pCtrl->Invoke(dspid, IID_NULL, LOCALE_SYSTEM_DEFAULT,
DISPATCH_PROPERTYGET, &dispparamsNoArgs, &vtResult, NULL, NULL);

The GetIDsOfName returns S_OK aand a dispid of 1 (which looks correct)
The Invoke on the IButtonControl fails with an error code of 800a01a8
(something about object required)
 
P

Patrick Schmid [MVP]

There is no IButtonControl interface for this.
Did you read
http://blogs.msdn.com/jensenh/archive/2006/12/08/using-ribbonx-with-c-and-atl.aspx?

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Hello,

Not quite .. when I press a button my C++ OnAction function is called, and
as I understand it I should be passed a pointer to an IButtonControl.

Ribbon::IRibbonControlPtr pCtrl = NULL;
(LPDISPATCH)(pDispParams->rgvarg[0].pdispVal)->QueryInterface(Ribbon::IID_IRibbonControl,
(LPVOID *)&pCtrl);

OLECHAR * szId = L"Id";

DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
DISPID dspid;
VARIANT vtResult;

hr = pCtrl->GetIDsOfNames(IID_NULL, &szId, 1, LOCALE_SYSTEM_DEFAULT,
&dspid);
hr = pCtrl->Invoke(dspid, IID_NULL, LOCALE_SYSTEM_DEFAULT,
DISPATCH_PROPERTYGET, &dispparamsNoArgs, &vtResult, NULL, NULL);

The GetIDsOfName returns S_OK aand a dispid of 1 (which looks correct)
The Invoke on the IButtonControl fails with an error code of 800a01a8
(something about object required)



Wei Lu said:
Hello Michael,

I would like to know this issue more clearly.

1.Do you mean that when you try to click the Button to invoke your
callback
and you get the error message?

2. What does your OnAction do? Could you post the content here?

3. If you only try to show a MessageBox in the OnAction, did this issue
appeared?

The whole code of your add-in will be appreciated so that I can do further
troubleshoot.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
 
M

Michael Tissington

Yes, I read it - I miss typed - should have said IRibbonControl - which in
fact is what the code snippet is using - but I still get back the error
800a01a8.

Patrick Schmid said:
There is no IButtonControl interface for this.
Did you read
http://blogs.msdn.com/jensenh/archive/2006/12/08/using-ribbonx-with-c-and-atl.aspx?

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Hello,

Not quite .. when I press a button my C++ OnAction function is called,
and
as I understand it I should be passed a pointer to an IButtonControl.

Ribbon::IRibbonControlPtr pCtrl = NULL;

(LPDISPATCH)(pDispParams->rgvarg[0].pdispVal)->QueryInterface(Ribbon::IID_IRibbonControl,
(LPVOID *)&pCtrl);

OLECHAR * szId = L"Id";

DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
DISPID dspid;
VARIANT vtResult;

hr = pCtrl->GetIDsOfNames(IID_NULL, &szId, 1, LOCALE_SYSTEM_DEFAULT,
&dspid);
hr = pCtrl->Invoke(dspid, IID_NULL, LOCALE_SYSTEM_DEFAULT,
DISPATCH_PROPERTYGET, &dispparamsNoArgs, &vtResult, NULL, NULL);

The GetIDsOfName returns S_OK aand a dispid of 1 (which looks correct)
The Invoke on the IButtonControl fails with an error code of 800a01a8
(something about object required)



Wei Lu said:
Hello Michael,

I would like to know this issue more clearly.

1.Do you mean that when you try to click the Button to invoke your
callback
and you get the error message?

2. What does your OnAction do? Could you post the content here?

3. If you only try to show a MessageBox in the OnAction, did this issue
appeared?

The whole code of your add-in will be appreciated so that I can do
further
troubleshoot.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader
so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
 
W

Wei Lu [MSFT]

Hello Michael,

I would like to suggest you use the early binding with a GetID method.

...........

CComBSTR bstr;

hr = pCtrl->GetId(&bstr);

..............

What's the result?

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Michael Tissington

The result is EXCTLY the same, I get the same error. I am using
GetIdsFromNames and Invoke to see if I could figure out where the problem
is.
 
W

Wei Lu [MSFT]

Hello Michael,

It seems that the Invoke method did not get the correct object.

When you use the GetID method, did you still get the Access Violation error?

I would like to suggest you to import the IDTExtensibility2 interface and
then, you could find the IRibbonControl Class. So that you may try to use
the get_id() method instead of the GetID in the pointer.

#pragma warning( disable : 4278 )
#pragma warning( disable : 4146 )
//The following #import imports the IDTExtensibility2 interface
based on
it's LIBID
#import "libid:AC0714F2-3D04-11D1-AE7D-00A0C90F26F4" version("1.0")
lcid("0") raw_interfaces_only named_guids
//The following #import imports the MSO interface based on it's LIBID
#import "libid:2DF8D04C-5BFA-101B-BDE5-00AA0044DE52" version("2.4")
lcid("0") raw_interfaces_only named_guids auto_rename
#pragma warning( default : 4146 )
#pragma warning( default : 4278 )

This post may give you some clue.

http://groups.google.com/group/microsoft.public.office.developer.com.add_ins
/browse_frm/thread/543251ea1a391846/ea65f0e8422316b7

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Michael Tissington

I am using #import already to get the definitions of the IRibbon etc.

The problem occurs if I use Invoke or GetId() or raw_GetId ... It seems to
me that what Outlook is giving me in the callback is not correct.
 
W

Wei Lu [MSFT]

Hello Michael,

My suggestion is please tested on another machines and if it persist, would
you please generate a simple Ribbon control and a C++ project and then send
it to me for further troubleshooting?

You may zip the folder and send to me directly. I understand the
information may be sensitive to you, my direct email address is
(e-mail address removed) ( Please remove ONLINE when you send the email
), you may send the file to me directly and I will keep it secure.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Wei Lu [MSFT]

Hello Michael,

Thanks for the email. I will try to reproduce this issue on my side. It
will cost some time and I will back to you ASAP.

I appreciated your patience.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Wei Lu [MSFT]

Hello Michael,

My colleague is helping me to reproduce this issue. I appreciate your
patience.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Wei Lu [MSFT]

Hello Michael,

Per my colleague's test, we could not compile the project.

Also, it seems that you implement the IDispatch interface by yourself.

Have you tested on the Visual Studio 2005?

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Michael Tissington

Hello,

The project was developed in C++ VC 6.0 - the main project is far to big to
convert to VS 2005.
So I created a test project also using VC 6.0 to demonstrate the problem.

You are correct I implement IDispatch myself (which is nothing complicated)
.... the problem still remains. If you are not able to help resolve this
please let me know who I need to speak to.
 
W

Wei Lu [MSFT]

Hello Michael,

Could you send me an email and so that I can involved other resources to
help on this issue?

To reach me, please remove the ONLINE in my email address.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top