D
DanielH
Hello,
I have a very strange problem:
When using a Timer in a Word-Plugin which sets or gets the
HighlightColorIndex-Value of a range, everything that will be typed in Word
will appear two or three times.
This source-code can be used to reproduce this problem:
Connect.cpp:
STDMETHODIMP
CConnect::OnDisconnection(AddInDesignerObjects::ext_DisconnectMode
/*RemoveMode*/, SAFEARRAY ** /*custom*/ )
{
m_pApplication = NULL;
m_pAddInInstance = NULL;
return S_OK;
}
STDMETHODIMP CConnect::OnAddInsUpdate (SAFEARRAY ** /*custom*/ )
{
return S_OK;
}
void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
Word::_ApplicationPtr pApp = Word::_ApplicationPtr(&(*g_pApplication));
Word::_DocumentPtr pDoc = pApp->GetActiveDocument();
Word::WordsPtr pWords = pDoc->GetWords();
if (pWords->GetCount() > 3)
{
Word::RangePtr pWord = pWords->Item(2);
OutputDebugStr("Hi there\n");
pWord->PutHighlightColorIndex(Word::wdYellow);
}
}
STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication,
AddInDesignerObjects::ext_ConnectMode /*ConnectMode*/, IDispatch *pAddInInst,
SAFEARRAY ** /*custom*/ )
{
pApplication->QueryInterface(__uuidof(IDispatch), (LPVOID*)&m_pApplication);
pAddInInst->QueryInterface(__uuidof(IDispatch), (LPVOID*)&m_pAddInInstance);
g_pApplication = m_pApplication;
return S_OK;
}
STDMETHODIMP CConnect::OnStartupComplete (SAFEARRAY ** /*custom*/ )
{
SetTimer(NULL, NULL, 1000, TimerProc);
return S_OK;
}
STDMETHODIMP CConnect::OnBeginShutdown (SAFEARRAY ** /*custom*/ )
{
return S_OK;
}
This problem also occurs on Word2000. This is very urgent, please help.
Any help, hints, solutions and work-arounds are GREATLY appreciated.
Kind regards,
Daniel Hilgarth
I have a very strange problem:
When using a Timer in a Word-Plugin which sets or gets the
HighlightColorIndex-Value of a range, everything that will be typed in Word
will appear two or three times.
This source-code can be used to reproduce this problem:
Connect.cpp:
STDMETHODIMP
CConnect::OnDisconnection(AddInDesignerObjects::ext_DisconnectMode
/*RemoveMode*/, SAFEARRAY ** /*custom*/ )
{
m_pApplication = NULL;
m_pAddInInstance = NULL;
return S_OK;
}
STDMETHODIMP CConnect::OnAddInsUpdate (SAFEARRAY ** /*custom*/ )
{
return S_OK;
}
void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
Word::_ApplicationPtr pApp = Word::_ApplicationPtr(&(*g_pApplication));
Word::_DocumentPtr pDoc = pApp->GetActiveDocument();
Word::WordsPtr pWords = pDoc->GetWords();
if (pWords->GetCount() > 3)
{
Word::RangePtr pWord = pWords->Item(2);
OutputDebugStr("Hi there\n");
pWord->PutHighlightColorIndex(Word::wdYellow);
}
}
STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication,
AddInDesignerObjects::ext_ConnectMode /*ConnectMode*/, IDispatch *pAddInInst,
SAFEARRAY ** /*custom*/ )
{
pApplication->QueryInterface(__uuidof(IDispatch), (LPVOID*)&m_pApplication);
pAddInInst->QueryInterface(__uuidof(IDispatch), (LPVOID*)&m_pAddInInstance);
g_pApplication = m_pApplication;
return S_OK;
}
STDMETHODIMP CConnect::OnStartupComplete (SAFEARRAY ** /*custom*/ )
{
SetTimer(NULL, NULL, 1000, TimerProc);
return S_OK;
}
STDMETHODIMP CConnect::OnBeginShutdown (SAFEARRAY ** /*custom*/ )
{
return S_OK;
}
This problem also occurs on Word2000. This is very urgent, please help.
Any help, hints, solutions and work-arounds are GREATLY appreciated.
Kind regards,
Daniel Hilgarth