Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

adding custom verb to OLE object that changes its appearance

6 views
Skip to first unread message

Przemyslaw Dzierzak

unread,
Apr 6, 2007, 8:14:02 AM4/6/07
to
I have problems with adding a custom verb to my OLE server application w/MFC.
Problem appears in our application but I could reproduce the problem in
scribble app.

I've added new OLE verb to Scribble App, named it 'Add Random Triangle'. The
problem is that I don't know how to make Excel refresh scribble object in all
cases. The verb works fine with Word and PowerPoint, but it doesn't work in
Excel in the following scenario:

1. Add a Scribble object to new Excel spreadsheet, draw a line inside.
2. save & close xls file.
3. Open saved file.
4. right-click on it and run 'Add Random Triangle' verb
5. NOTHING HAPPENS
6. if you open the Scribble object you will find there is a triangle added
7. close Scribble object edition, and add another random triangle - now it
shows up.

So my question is how should I correctly update the object when it changes
as a result on nonstandard verb?


Changes I made to scribble:

1. add new verb - scribble.cpp, InitInstance method, line 143:
VERIFY( CRegKey::SetValue( HKEY_CLASSES_ROOT,
"CLSID\\{7559FD90-9B93-11CE-B0F0-00AA006C28B3}\\verb\\2", "Add Random
&Triangle,0,2" ) == ERROR_SUCCESS );

2. add new verb implementation - overriden CScribbleItem::OnDoVerb:

#define SIZE 200

void CScribbleItem::OnDoVerb(LONG iVerb)
{
// "Add Random Triangle" verb implementation
if( iVerb == 2 )
{
CScribbleDoc *pDoc = GetDocument();
srand( (unsigned int)time(NULL) );
CStroke *pStroke = pDoc->NewStroke();
CPoint p1( (int)( rand()*(double)SIZE/RAND_MAX),
-(int)(rand()*(double)SIZE/RAND_MAX) );
pStroke->m_pointArray.Add( p1 );
pStroke->m_pointArray.Add( CPoint( (int)(rand()*(double)SIZE/RAND_MAX),
-(int)(rand()*(double)SIZE/RAND_MAX) ) );
pStroke->m_pointArray.Add( CPoint( (int)(rand()*(double)SIZE/RAND_MAX),
-(int)(rand()*(double)SIZE/RAND_MAX) ) );
pStroke->m_pointArray.Add( p1 );
pStroke->FinishStroke();

// question: How should I save changes so that Excel (and all other OLE
clients) both save & redraw the object (and close it)?
pDoc->SetModifiedFlag();
pDoc->NotifyChanged();
pDoc->SaveEmbedding();
pDoc->NotifyClosed();
}
else
COleServerItem::OnDoVerb(iVerb);
}


3. stdafx.h :
#include <atlbase.h> // CRegKey class


Charles Wang[MSFT]

unread,
Apr 8, 2007, 10:14:45 PM4/8/07
to
Hi,
This is a quick note to let you know that I am performing research on this
issue. I will let you know the result as soon as possible.
Appreciate your patience.

Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.


Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================

Charles Wang[MSFT]

unread,
Apr 12, 2007, 6:06:46 AM4/12/07
to
Hi,
I am sorry for the late response due to two days sick leave.
I downloaded the scribble example from MSDN and changed the code as yours;
however the code did not work well at my side. There is an exception when
I close the view. I am struggling with it now.
If it is convenient for you, you may mail me
(changliw_at_microsoft_dot_com) your sample to speed up the research
proccess.

Also, you may want this reference:
How To Debug OLE Applications
http://support.microsoft.com/kb/q154116/

Charles Wang[MSFT]

unread,
Apr 18, 2007, 4:21:37 AM4/18/07
to
Hi, Przemek,
After looked at your code and discussed this issue with other engineers, we
think that this issue may not be caused by your code since it can work fine
in Word and PowerPoint. I am consulting Excel product team to see if this
is a product issue. If there is any response, I will let you know.
Also, We recommend that you have a new post at
microsoft.public.excel.programming or
microsoft.public.office.developer.com.add_ins
for wider audience.

If you have any other questions or concerns, please feel free to let me
know.

0 new messages