|
|
I program an appwizard for VC6 recently,and want to create a project( using the appwizard) which has the follwoing name of a project's configuations,for example,
project's configuations:
default: new:
win32 Debug ===> Checked
win32 Release ===> Free
thanks!
|
|
|
|
|
I want to write an AppWizard for vc6,but I don't know how to get a project's active configuration.
(I am newbie in ATL)
could someone give me a hand?
void CWinDriverAppWiz::CustomizeProject(IBuildProject* pProject)
...
IApplication *pApp;
CComBSTR projname;
CComPtr<idispatch> iDisp=NULL;
...
pApp->get_ActiveConfiguration(&iDisp);
CComQIPtr<igenericproject,&iid_igenericproject> pActiveConf(iDisp);
iDisp=NULL;
pActiveConf->get_Name(&projname);
}
modified on Thursday, February 19, 2009 5:51 AM
|
|
|
|
|
This worked for me with an add-in I wrote (note - m_piApplication , declared with type CComPtr<IApplication> is the IApplication pointer:
CComPtr<IDispatch> actCfgDisp;
if (FAILED(m_piApplication->get_ActiveConfiguration(&actCfgDisp)) || !actCfgDisp) return E_FAIL;
CComQIPtr<IConfiguration> activeConfiguration(actCfgDisp);
if (!activeConfiguration) return E_FAIL;
CComBSTR configurationName;
CString configuration;
if (SUCCEEDED(activeConfiguration->get_Name(&configurationName)))
{
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I don't know how to initialize "m_piApplication"(IApplication* m_piApplication) by pProject(IBuildProject* pProject).
The problem puzzles me so long time1
|
|
|
|
|
You can't get m_piApplication from an IBuildProject.
Instead, you need to remember it from when VisualStudio calls the OnConnection method of your add-in object (that's the one that implements IDSAddIn).
I found this article[^] very useful when implementing my add-in.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Why the code not work?
I think it's expected that the output should be 4 , but it asserts.
#include <iostream>
#include <vector>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
vector<int> v(10);
for (int i=0; i<10; ++i)
{
v[i] = i;
}
vector<int>::iterator it = v.begin();
it += 3;
vector<int>::iterator it0 = it + 1;
v.erase(it);
cout << *it0 <<endl;
cin.get();
return 0;
}
modified on Wednesday, February 18, 2009 9:33 PM
|
|
|
|
|
What is the assertion code, because i have tried your source and the result is: "5". And it should be "5" because v.erase(it); removes the element pointed to by it, so after this operation our fourth element is "5".
|
|
|
|
|
In the cout statement.
Compiled in VC9 SP1.
|
|
|
|
|
I have tried your code in VC6 and it works fine there, but in VC9 it asserts. So why this happens? The answer is "because of The STL implementation in VC8 and VC9". The new STL implementation includes additional checks, this line is from vector file, which comes with VC9
#if _HAS_ITERATOR_DEBUGGING
if (this->_Mycont == 0
|| _Myptr < ((_Myvec *)this->_Mycont)->_Myfirst
|| ((_Myvec *)this->_Mycont)->_Mylast <= _Myptr)
{
_DEBUG_ERROR("vector iterator not dereferencable");
_SCL_SECURE_OUT_OF_RANGE;
}
#else
After you call erase(it); the "it" iterator and all iterators pointing elements after the erased element will be invalidated, so you have to change your code if you don't want your iterators to become invalid. Here is one possible solution, it works fine on VC9:
...............
int main()
{
vector<int> v(10);
for (int i=0; i<10; ++i)
{
v[i] = i;
}
vector<int>::iterator it = v.begin();
it += 3;
it = v.erase(it);
vector<int>::iterator it0 = it + 1;
cout << *it0 <<endl;
cin.get();
return 0;
}
</int></int></int>
The result must be: 5.
|
|
|
|
|
The v.erase(it); line invalidates it0 . vector iterators are invalidated when an element is added to or removed from a vector.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
To re-iterate what I said - you program is erronous - it has no meaning under the semantics of C++ as defined by the C++ standard. Erasing a vector element with v.erase(it); means that you cannot rely on it0 to reference a sensible value.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
OK, I realise I'm way behind the curve here, having spent my professional life maintaining MFC + FORTRAN apps, but now I'm trying to make use of some STL because it looks helpful.
Suppose I have the following:
struct Info
{
Point3D JunctionPt;
Point3D EndPtOne;
Point3D EndPtTwo;
double LengthOne;
double LengthTwo;
double DistToRef;
};
map<LONG, Info> m_PtsInfo;
I use a map because each JunctionPt is associated with a unique ID. Also, my loop for adding the info may come across each JunctionPt numerous times, thus I can use m_PtsInfo.count(ID) to see if I have added any of the info already.
Once my map is populated, what I really want is it sorted by DistToRef, but I'm not sure how best to achieve this. I didn't think using DistToRef as the key was a great idea...
Should I copy my Info from the <map> to a <set> with the appropriate comparison defined? Then sort the set? Or is there some other cunning STL trick I've missed to achieve what I want?
Cheers!
|
|
|
|
|
The purpose of map is that of a key/value pair.
The key is stored internally for fast access.
So if you want it sorted, there is no point in using a map .
You could probably use a pair .
«_Superman_»
|
|
|
|
|
I appreciate that maps and sorting don't go together, but as I tried to explain, I used a map to take advantage of its other properties...
But I can do the same with a vector of pairs ?
|
|
|
|
|
Kyudos wrote: I appreciate that maps and sorting don't go together
Actually, the original response wasn't quite correct - map s and sorting do go together. The C++ Standard specifies that:
the fundamental property of iterators of associative containers is that they iterate through the containers in the nondescending order of keys where nondescending is defined by the comparison that was used to construct them.
Which means that when you iterate through a map or a set , you start at the smallest key and end at the biggest.
That duality of map s and set s is the reason that unordered_map [^] was added to the TR1 version of the standard library - taking away the ordering requirement may permit more efficient implementations.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: the fundamental property of iterators of associative containers is that they iterate through the containers in the nondescending order of keys where nondescending is defined by the comparison that was used to construct them.
Yes, this used to be a problem for us when we really didn't want the map to behave so.
But not aware that an unordered one exists.! thanks.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
[edit]Modified code after actually building and running it...[/edit]
There are lots of ways of doing this. I wouldn't use a set, 'cause it's generally quicker to use a sorted std::vector and then do a std::lower_bound or std::upper_bound to find the relevant item.
What I'd do (have done!) would be to make a secondary index, which is a vector of Info pointers and sort it.
bool OrderOnDistToRef(Info const* l, Info const* r) const { return l->DistToRef < r->DistToRef; }
std::vector<const Info*> index;
for(std::map<LONG, Info>::const_iterator i=m_PtsInfo.begin();i!=m_PtsInfo.end();++i)
{
index.push_back(&i->second);
}
std::sort(index.begin(), index.end(), OrderOnDistToRef);
Then we can do lookups using something like
Info lookingForStruct;
lookingForStruct.DistToRef = distToRefWeAreLookingFor;
std::vector<const Info*>::const_iterator found = std::lower_bound(index.begin(), index.end(), &lookingForStruct, OrderOnDistToRef);
Alternatively, you could use a Boost Multi-Index[^], which gives you a mappish container with multiple lookups.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
modified on Tuesday, February 17, 2009 4:17 PM
|
|
|
|
|
I need it when writing an algorithm, but surprisingly it is there.
|
|
|
|
|
You could implement something like the following to get the same functionality
string s;
try
{
s.at(s.size() - 1)
}
catch (exception& e)
{
}
«_Superman_»
|
|
|
|
|
The most flexible way to get that functionality is probably a function like this
template<class StringType>
typename StringType::value_type back(StringType const& s)
{
return *s.rbegin();
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
How do we Inherit struct from another struct in IDL file
|
|
|
|
|
Hi,
I have Add In developed in ATL COM which will take care of open, close etc...events. I am able to get the events for Word 2007 but when I am using perticular cell in Excel 2007 and my cursor is in the same cell I wont be able to get name of the excel file. Since my cursor is in cell then I wont get file activate event.
I would like to know how to get the name of excel file even if my cursor is in cell (note:- cell is not selected. cursor is present in the cell)
Thanks
SNI
|
|
|
|
|
Hi,
I am using the ATL COM DLL. In this I am createng two threads.
I have added new ATL object which supports connceting point, appartment thereaded model,
Dual interface and agregation=yes. While creating thread and passing the interface pointer as this pointer.
hStatusThread = CreateThread(NULL,
o,
LPTHREAD_START_ROUTINE(StatusThread),
(LPVOID)this,
0,
&dwThStId);
::SetThreadPriority(hStatusThread, THREAD_PRIORITY_HIGHEST);
I am accessing the interface pointer in thread and firing the event..
UINT StatusThread(LPVOID param)
{
CMyConnectObj *ptrObj = NULL;
ptrObj = (CMyConnectObj*)param;
if(ptrObj == NULL)
return 0;
if(WaitForSingleObject(g_Mutex,INFINITE) == WAIT_OBJECT_0)
{
ptrObj->Fire_ErrorCode(lErrorCode);
ReleaseMutex(g_Mutex);
}
}
I am using vb6.0 client to use this dll.
but while firing event at line i
ptrObj->Fire_ErrorCode(lErrorCode);
it's giving error as "Unhandled Exception in ConnectProg.exe (MSVBVM60.dll)0x0000005: Access Violation.
But if I tried to fire event for one of the ATL object function there is no problem at all.
Please help me for this with perect solution..
It's very urgent.
|
|
|
|
|
chetanjoshi9 wrote: THREAD_PRIORITY_HIGHEST
That's a bit evil for a start - you really don't want to be altering thread priorities.
chetanjoshi9 wrote: MSVBVM60
That's likely your problem - your contorl might be thread aware, but I don't think VB6 is...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|