LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default adding custom verb to OLE object that changes its appearance

I have posted the question with the same subject and similar content to
microsoft.public.vc.mfcole . There I was said that my problem appears to be a
bug in Excel. I was suggested that I could post the mail here also. I got no
response from MS since then and when I try to contact Charles Wang (who I
mailed with) the mail is undeliverible. Could anybody help me? That's the
problem:

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
permenent appearance of the drop down arrow when adding validation toa cell thread Excel Worksheet Functions 2 March 24th 08 05:20 PM
Adding custom list and text boxes to the custom tool bar from Excel C API Mousam Excel Discussion (Misc queries) 0 August 7th 07 09:19 AM
Adding custom property to Range object Morgan[_5_] Excel Programming 1 April 27th 07 11:42 AM
The opposite of .Verb in OLE Object [email protected] Excel Programming 1 July 21st 05 02:18 PM
Changing button appearance on custom toolbar. amescha Excel Programming 2 September 28th 04 05:25 PM


All times are GMT +1. The time now is 07:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"