|
|
|
Hello together,
this is very basic question. I am trying to write an MFC Application
that will take advantage of the automation features of Excel (NOT an add-in with vsto).
Now here is the poblem:
I have created a basic MFC application using the wizard. That worked fine.
Next step I added a MFC typelib class. I picked Microsoft Excel11 from registry.
Whenever I try to include the generated header files ( Worksheet, Workbook, ...)
and work with them the code will not compile. I get hundreds of errors from file
excel.tlh. And this one is automaticcaly generated.
I eliminated most of the warnings (by renaming, e. g. the "RGB" macro after the
#import statement). Though the 'excluding IFont' is still there.
I have also read a few tutorials and they almost all used the same approach
as I did. Am I missing something? Does anyone else have encountered similiar
problems?
Does anyone have a sample solution for VS2005? I found one
for VC6 but to get it to compile I had to 'hack' the afxmsg_.h file (yes, its a build in
system file for VS). I would prefer a 'clean' solution.
Please help.
Thanks in advance!
|
|
|
|
|
|
DFGM,N!
I've already exhausted that option.
|
|
|
|
|
Hai,
can anyone tell me what is the real problem in implementing malloc here
bmpsrc = (U8 *) malloc(bmpsize);
memset(bmpsrc, 0xff, 5);
Thanks
Harshadha
|
|
|
|
|
You should probably check that bmpsrc != NULL - your memory allocation could fail if there's not enough memory (or if there isn't a single chunk of memory big enough for the allocation)
|
|
|
|
|
void example()
{
U32 bmpsize; //this is an integer datatype
U8 *bmpsrc=0x00FC0; //this is the character datatype
//i want to use malloc only .....
bmpsrc =malloc(bmpsize);
memset(bmpsrc, 0x00FC0, 0);
..
..
..
}
this is my actual coding .....
i dont know how to change its memory allocation
Harshadha
|
|
|
|
|
I think you've got your initial variable setup the wrong way round. bmpsize doesn't seem to have a value, and you're setting the value of your pointer to 0x00fc0, which I guess is meant to be the actual size. If that's the case, you've also got the second and third arguments of memset the wrong way around.
I hope you'll remember to free that pointer when you're done with it.
|
|
|
|
|
What is the size of bmpsize ? If it is under 5, then you are writing outside the boundaries of your allocated area.
BTW, do you really want to code in C ? Why not use new instead of malloc ?
|
|
|
|
|
It's hard to know for sure without knowing what bmpsize is, but I would guess that bmpsize is less than 5. When you call memset, you are setting the five bytes starting at the address of bmpsrc to 0xff. If you have allocated less than five bytes, you will be writing to memory you do not own
|
|
|
|
|
harshadha wrote: bmpsrc = (U8 *) malloc(bmpsize);
memset(bmpsrc, 0xff, 5);
Did you check that bmpsrc was not NULL?
bmpsize is checked for being greater than 5?
maybe memset(bmpsrc, 0xff, max( 5, bmpsize)) would be better?
Other than that, the code snippet looks fine.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
What is U8 ? What is value of bmpsize ?
|
|
|
|
|
void example()
{
U32 bmpsize; //this is an integer datatype
U8 *bmpsrc=0x00FC0; //this is the character datatype
//i want to use malloc only .....
bmpsrc =malloc(bmpsize);
memset(bmpsrc, 0x00FC0, 0);
..
..
..
}
this is my actual coding .....
i dont know how to change its memory allocation
|
|
|
|
|
harshadha wrote: bmpsrc =malloc(bmpsize);
What is value of bmpsize ?
harshadha wrote: memset(bmpsrc, 0x00FC0, 0);
Why you are passing last parameter as 0, it should be less than or equal to bmpsize .
|
|
|
|
|
the bmpsize value is taken equal to the data type value(U32 bmpsize that is),it is taken as 2bytes.
My real problem is i want to create a buffer to draw a bmp file...
for that i have to use malloc then i need bmpsrc that is the memory allocated area and the size.....
|
|
|
|
|
harshadha wrote: the bmpsize value is taken equal to the data type value(U32 bmpsize that is),it is taken as 2bytes.
In this case, third parameter to memset in your OP should be
bmpsize . Where as in your OP, you was passing 5, that was causing problem.
harshadha wrote: i have to use malloc then i need bmpsrc that is the memory allocated area and the size.....
May be you can be little clear, what you are trying to say.
|
|
|
|
|
What does your debugger tell you?
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
The instruction at "0x006aoef8" referenced memory at "ox00000000".The memory could not be read.
|
|
|
|
|
That's not a text from your debugger. That's Windows error message.
By using the debugger you have, you can set a break point in your source code. When the program reaches the break point, the debugger will stop the execution of youe program so you can (amongst other things) inspect your variables and find out the cause of the problem.
You should learn how to use the debugger. It's not very hard to do and the debugger will definately save you heaps of time when you are looging for problems with your code.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
unhandled exception in fa.exe:cx0000005 access violation
|
|
|
|
|
Hi,
I need to erase Button edge lines. so that i can not see its rectangle line on dialogbox? But the button should work as like before.
How can i do this ?
Thanks.
|
|
|
|
|
Do you have owner draw for your button?
|
|
|
|
|
you need to owner draw the button..
nave
|
|
|
|
|
How do i that ? Can you show me few examples ?
|
|
|
|