|
Hi,
I have a Visual C++ ActiveX control and a VB project who is using it and I would like to know how I can pass an object from the control to VB.
The VC++ control "knows" that object from #import but I cannot write it as a parameter type because it's not a COM standard.
I have used a VARIANT type to pass the object to the Control from VB and it seems to work, but I just can't figure out how to make it work the other way around.
Any help would be appreciated.
Thanks,
|
|
|
|
|
O.k. Thanks for nothing. I just figured it out.
I just use LPUNKNOWN and then after casting it i copy all the data.
|
|
|
|
|
Hi all,
So I have a list< double* >, which contains arrays which were created with something like new double[4]. When I'm done with the list I need to free all of the elements. At first I tried this:
list< double* > ::iterator it = my_list.begin();
while( it != my_list.end() )
delete [](*it);
but that didn't work, with MFC saying the pointer was still valid, I think because the list still contained references to the element.
So I figured the best way would be to walk thru the list, removing, then deleting, elements as I go. But I'm a little unsure about the behaviour of iterators in this situation. For example after the following code:
list< double* > ::iterator my_it = my_list.begin();
my_list.pop_front();
Would my_it stil be valid? Where would it be pointing to?
I need to figure out the quickest way to safely []delete all elements in the list.
Any pointers?
TIA,
Pete
|
|
|
|
|
Doh!
this code:
while( it != my_list.end() )
delete [](*it);
should have been:
while( it != my_list.end() )
delete [](*it++);
I guess I'm too used to good old for loops
well, I can now just run thru the list, deleting all the elements, then just delete the list.
This is probably the quickest way.... right?
Pete
|
|
|
|
|
Try the following:
list< double* >::iterator i;
while ((i = my_list.begin()) != my_list.end())
{
double *p = *i;
my_list.pop_front();
delete [] p;
}
|
|
|
|
|
That looks like it would work, but I'm not sure if it's the quickest way to do it, calling begin() every time...
|
|
|
|
|
I like to use something like:
while ( ! my_list.empty() )
{
delete [] my_list.front();
my_list.pop_front();
}
Best regards,
John
|
|
|
|
|
Yeah, that looks nice
Do you think it'd be quicker this way...
for( i = my_list.size(); i >= 0; i-- )
{
delete [] my_list.front();
my_list.pop_front();
}
Im guessing the lack of a function call would speed it up, what do you think?
Pete
|
|
|
|
|
The speed difference would be insignificant. The members of list are generally inlined, so don't add any function call overhead.
John
|
|
|
|
|
>>The speed difference would be insignificant.
Whereas the time wasted while I try to understand my 'efficient' function in two weeks would be significant... I think I'll go with your version
Thanks John
|
|
|
|
|
My original reply was written assuming that you can't change the type of the list.
If you can change the type of the list, I would do that instead.
I would use:
list< vector< double > > my_list.
Then, when you erase any elements inside the list, the vector will automatically clean up after itself.
John
|
|
|
|
|
I _could_ change the type, but it would be more [bureaucratic] effort than it's worth.
Thanks anyway,
Pete
|
|
|
|
|
For future reference though, a vector of doubles in a list would have been a much nicer solution. I usually delete pointers if I need to carry them ( because of polymorphism ) using a for_each and a function object that calls delete on everything in my container.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Even I don't see much sense in storing double* instead of double in a vector. It will also cause Heap fragmentation and your code may cause more page faults as each double may be scattered all over the memory. Unless you have very important reason against it, change it to double.
|
|
|
|
|
Well, it seems that it would be worth the effort, based on all of your posts. I shall get to it...
Thanks for the advice everyone
|
|
|
|
|
Hello. This problem has been plaguing me and I can't seem to find an answer. I am programming a Win32 App using the Win32 API. I am using MCI to play a midi and I need to figure out how long the song is. Does anyone know how to do this or can anyone direct me to a resource that would show me? I've tried many things but I just can't seem to figure it out. Thanks in advance.
|
|
|
|
|
Have you tried searching on google for information on the MIDI format?
|
|
|
|
|
Yes, and I've read it too.
|
|
|
|
|
From http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mmcmdstr_6tyl.asp
To send the status command, call the mciSendString function.
status length track number
Returns the length of the track, in time or frames, specified by number.
For PPQN format files, the length is returned in song pointer units. For SMPTE format files, it is returned as hh:mm:ss:ff, where hh is hours, mm is minutes, ss is seconds, and ff is frames.
|
|
|
|
|
is there a way i could get a specifc portion from an image in visual c++6.
i meant to say if i had a image and i want to make another file of that image of its center portion only .
looking forward from all the gurus of code
|
|
|
|
|
i'm sure the various image classes on this site can help.
or, as always, i know where you can find a commercial solution...
-c
Cheap Oil. It's worth it!
|
|
|
|
|
Chris Losinger wrote:
or, as always, i know where you can find a commercial solution...
One can only imagine!
Jeremy L. Falcon<nobr>
Homepage : Sonork = 100.16311
"It was a blind man who taught me how to see." - Aerosmith
|
|
|
|
|
i always mention the stuff here first!
-c
Cheap Oil. It's worth it!
|
|
|
|
|
Chris Losinger wrote:
i always mention the stuff here first!
It really is a nice library. I for one will revisit it if I start a project requiring serious imagine processing.
Jeremy L. Falcon<nobr>
Homepage : Sonork = 100.16311
"It was a blind man who taught me how to see." - Aerosmith
|
|
|
|
|
Chris Losinger wrote:
or, as always, i know where you can find a commercial solution...
...or use paintlib
Cheers, Marc Click to see my *real* signature
|
|
|
|