|
If I add new workbook sheet, WorkbookNewSheet() event gets fired. If I enter some data in newly added sheet, SheetChange event is getting fired.
Likewise, if I add some function like =sum(10,20) in newly added sheet, SheetCalculate function should get fired. But its not happening. Had I missed any bind between appEventHandler and bookEventHandler?
Expected output is SheetCalculate (event of workbook) should get fired whenever there is a change in function result of the newly added WorkBookSheet.
Please let me know if my question is not clear.
|
|
|
|
|
 Firstly - be aware that Excel does dataflow analysis and will not call SheetCalculate if a change results in no recalculation (but as far as I can tell it ALWAYS calls AfterCalculate).
This (complete) program code successfully registers event handlers which get called by Excel:
#include <iostream>
#include <atlbase.h>
#include <atlcom.h>
#import "libid:00020813-0000-0000-C000-000000000046" auto_search no_dual_interfaces rename("DialogBox", "excelDialogBox") rename("RGB", "excelRGB") rename("DocumentProperties", "excelDocumentProperties") rename("SearchPath", "excelSearchPath") rename("CopyFile", "excelCopyFile") rename("ReplaceText", "excelReplaceText")
_ATL_FUNC_INFO SheetChangeInfo = { CC_CDECL, VT_EMPTY, 2, { VT_DISPATCH, VT_DISPATCH } };
_ATL_FUNC_INFO AfterCalculateInfo = { CC_CDECL, VT_EMPTY, 0, { } };
class ExcelAppEventHandler : public IDispEventSimpleImpl<1, ExcelAppEventHandler, &__uuidof(Excel::AppEvents)>
{
public:
ExcelAppEventHandler(bool& doneFlag) : done_(doneFlag) { done_ = false; }
BEGIN_SINK_MAP(ExcelAppEventHandler)
SINK_ENTRY_INFO(1, __uuidof(Excel::AppEvents), 0x0000061c, &ExcelAppEventHandler::SheetChange, &SheetChangeInfo)
SINK_ENTRY_INFO(1, __uuidof(Excel::AppEvents), 0x00000a34, &ExcelAppEventHandler::AfterCalculate, &AfterCalculateInfo)
END_SINK_MAP()
void _stdcall SheetChange(IDispatch *, struct Excel::Range *)
{
std::cout << "ExcelAppEventHandler::SheetChange\n";
}
void _stdcall AfterCalculate()
{
std::cout << "ExcelAppEventHandler::AfterCalculate\n";
}
private:
bool& done_;
};
_ATL_FUNC_INFO SheetCalculateInfo = { CC_CDECL, VT_EMPTY, 1, { VT_DISPATCH } };
class ExcelBookEventHandler : public IDispEventSimpleImpl<1, ExcelBookEventHandler, &__uuidof(Excel::WorkbookEvents)>
{
public:
BEGIN_SINK_MAP(ExcelBookEventHandler)
SINK_ENTRY_INFO(1, __uuidof(Excel::WorkbookEvents), 0x0000061b, &ExcelBookEventHandler::SheetCalculate, &SheetCalculateInfo)
END_SINK_MAP()
void _stdcall SheetCalculate(IDispatch *)
{
std::cout << "ExcelBookEventHandler::SheetCalculate\n";
}
};
int _tmain(int argc, _TCHAR* argv[])
{
CoInitializeEx(0, COINIT_MULTITHREADED);
{
Excel::_ApplicationPtr xl;
if (SUCCEEDED(xl.GetActiveObject(__uuidof(Excel::Application))))
{
Excel::_WorkbookPtr wb = xl->Workbooks->Add();
ExcelBookEventHandler bookHandler;
bookHandler.DispEventAdvise(wb);
Excel::_WorksheetPtr ws = wb->Worksheets->Item[1];
if (ws)
std::cout << ws->Name << std::endl;
bool done = false;
ExcelAppEventHandler handler(done);
if (SUCCEEDED(handler.DispEventAdvise(xl)))
{
MSG msg;
while (!done && GetMessage(&msg, NULL, 0, 0) > 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
handler.DispEventUnadvise(xl);
}
}
}
CoUninitialize();
return 0;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Please excuse me if this has been covered and I have failed to understand. I have a C++/MFC app that reads from a database of locations, retrieves the UK/Irish ordnance survey grid reference and, amongst other things, works out the proximity of chosen sites one from another. The app is not intended to be of GPS accuracy, but rather to allow broad analysis of spatial relationships between archaeological sites. I would like to be able to interface with the terrain maps in Google earth but, as an amateur, have not been able to find any information other than an article posted here for a C# app - unfortunately I don't know C#.
Could anyone be so kind as to point me towards information on how one can interface a C++ app with GE to allow for a visual representation of data? i.e. using grid refs to plot out localities in a given area on a GE terrain map. Or, alternatively (and almost as helpful, but not quite!) tell me if this is not possible and thus save me further banging of the head on the keyboard.
Best thanks
Brian
|
|
|
|
|
Hi, i have some data in a buffer that i need to write to a file:
writing:
for(unsigned int i = 4; i<(nReceivedBytes-2); i++)
{
//_tprintf(_T("%c"), DataBuf.buf[i]);
myfile.open ("file.doc", ios::out | ios::app);
myfile<<(DataBuf.buf[i]);
myfile.close();
}
The data is in unicode (2 bytes), the first four bytes show the length of the data package and the last two are zero. The file wont open with openoffice and when i open it with notepad++ it displays some characters but most of them are NUL. What could be the problem?
Thank you
|
|
|
|
|
yeah1000 wrote: myfile.open ("file.doc", ios::out | ios::app);
What is the type of myfile object - std::ofstream or std::wofstream ?
When you write unicode data you should use std::wofstream .
Nuri Ismail
|
|
|
|
|
It was ofstream, i changed it to "wofstream myfile;" but it did't help
The data arrives over TCP, using WSABUF which i understand is actually of type char. Should i be able to write the data to file two bytes at a time so it could be opened?
|
|
|
|
|
yeah1000 wrote: The file wont open with openoffice and when i open it with notepad++ it displays some characters but most of them are NUL. What could be the problem?
For application to know that your file is a unicode one, the first two bytes of the file needs to be 0xff and 0xfe. If the first two bytes doesn't indicates any of the encoding codes, it will consider the file and ASCII file. I guess thats what happend in your case. Check http://en.wikipedia.org/wiki/Byte-order_mark[^] for more details.
|
|
|
|
|
Openoffice sometimes gives me the choice to choose in which format the file is, but when i select unicode then the file still is unreadable. Is there no way to write the file in binary format (as with binarywriter in c# for example) so that it wouldnt matter in which format it is?
|
|
|
|
|
yeah1000 wrote: (as with binarywriter in c# for example)
What difference does the file have when a string is written in c# using binary mode and in non binary mode?
|
|
|
|
|
Unicode aside, the only data that is going to exist in your file is DataBuf.buf[last_value_of_i] . You should probably be opening and closing the file outside of the for() loop.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Filemode is append, it does not help if i place it outside of the for cycle.
|
|
|
|
|
yeah1000 wrote: Filemode is append...
My bad. I overlooked that piece.
yeah1000 wrote: ...it does not help if i place it outside of the for cycle.
On the contrary, file I/O is very expensive (compared to reading from or writing to the file). If you are only writing a handful of bytes to the file, however, indeed it will never be noticed. For larger files, it's just plain wrong.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I am aware of that, i actually open and close the file far outside of the cycle, when i copied part of the code here i changed it to that. However, at the moment the problem is elsewhere.
Is it not necessary to define it somehow that i am using tchar? The buffer is in char format, if i write it to file byte by byte, at the end it should not matter that one char is actually 2 bytes in length, assuming that openoffice realizes that it is in unicode format?
|
|
|
|
|
yeah1000 wrote: However, at the moment the problem is elsewhere.
True, which is why I prefaced my initial comment as such.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
How to create shortcut in VC6? please!
|
|
|
|
|
See, for instance, "Shell Links" [^] topic at MSDN .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
gdctld wrote: How to create shortcut in VC6?
These[^] classes should do the job.
|
|
|
|
|
Hi, all
I want to do a windows service program with vs2008,
now, i want to know the steps to create windows service;
and i want to know the theory about windows service;
other,who can give a example?,hehe
|
|
|
|
|
|
Why don't you read MSDN doc about Services?!!!
There is everything, with plenty of complete samples !
|
|
|
|
|
Hi there-
How does one go about creating a virtual drive mounted in the OS?
What API's would one hook to to serve a virtual drive?
Thanks in advance.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Hi,
WinCDEmu[^] is an open source disc emulating tool. See if that helps.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
i am in dire need of someone to teach me how to compile programs, from source codes, i have tried and tried to figure it out on my own and am having no luck, i am about to lose it guys, please help me, i am trying to use cygwin, edit plus3, visual studio c# 2008, and nmap i really need some help guys any would be very appriciated thanks.
|
|
|
|
|
Compiling a program is a very basic (and well documented) task.
For instance, using Cygwin environment, just type
g++ source-file-name
This works smoothly provided:
g++ coompiler is correctly installed.- (2) there is a source-file-name
C++ source file available.
I suggest you to choose your favourite compiler or IDE (this is an important step, for instance, I wouldn't use the C# compiler for compiling C++ source files... ) and read documentation about (help, tutorials, how to, 'even' a good book).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
thank you very much i will give it a shot.
|
|
|
|
|