|
It should be
test.insert( pair< pair<string,int>,CMyClass*> > (pair<string,int>("hello",35), c));
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Here is a example that should work. It was a bit hard to read your code before, since all the bits between the < and > were thought to be html tags.
#include <map>
#include <string>
#include <utility>
void main()
{
std::map< std::pair<std::string, int*> , std::string> test;
int *value = new int;
// some useful processing ....
test.insert( std::make_pair( std::make_pair( std::string("hello"), 35), value) );
return;
}
But this is the way I prefer to do it, I find it much tidier:
void main()
{
typedef std::pair<std::string, int*> MyKey;
typedef std::map< MyKey , std::string> MyMap;
MyMap test;
int *value = new int;
// some useful processing ....
test[MyKey("hello", 35)] = value;
return;
}
Hopefully helpful,
Phil
|
|
|
|
|
Check out this article[^] where I cover dialog controls and message handling (link[^] to the relevant section)
--Mike--
"I'm working really, really fast at the moment, so a 3 minute outage becomes, due to time dilation, a 5 minute outage."
-- Chris Manuder, relativistic system administrator
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
I followed the tutorial at the following address...
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q184/6/63.asp&NoWebContent=1
It works great! But I would prefer if the excel menu did not merge with my apps menue. Is there anyway to keep the user from seeing and using the excel menu and tool bars?
In truth what I would prefer to do would be to embed the excel worksheet or spreadsheet into a dialog box like you can with office xp by using the Microsoft Office Spreadsheet 9.0 activeX Control. Does anyone know if this is possible using office 97? I was able to do it in VB, but not in MFC.
Thank you very much.
Mardigin
|
|
|
|
|
I was able to remove the formula bar and the Grid headings with the following code.
app.SetDisplayFormulaBar(FALSE);
Window win = app.GetActiveWindow();
win.SetDisplayHeadings(FALSE);
I still want to remove the "Formatting Toolbar" and all of the menus associated with Excel.
Anyideas.
Classes of interest are --> Menu, MenuBar, MenuBars, MenuItem, MenuItems, Menus, Toolbar, ToolbarButton, ToolbarButtons, Toolbars
Sincerely,
Mardigin
|
|
|
|
|
I realize this issue was addressed a few threads below
this one. However, I have attempted to implement the overloading of the > operator (unsuccessfully) as follows:
<code>
class CSpringNode
{
public:
unsigned int GetOldNodeIndex();
unsigned int EntryTracker;
double ycoord;
double xcoord;
double Energy;
unsigned int NodeIndex;
unsigned int Valence;
CM3DVector2f NodeCoords;
CSpringNode(CM3DVector2f NodeCoords, unsigned int Index);
virtual ~CSpringNode();
bool operator >(const CSpringNode& Node1, const CSpringNode& Node2) const
{
return (Node1.Energy > Node2.Energy);
}
protected:
CSpringNode(){};
private:
unsigned int m_uiOldNodeIndex;
};
</code>
but on compile I get:
--------------------Configuration: Solver2D - Win32 Debug--------------------
Compiling...
Solver2D.cpp
c:\program files\microsoft visual studio\myprojects\solver2d\springnode1.h(28) : error C2804: binary 'operator >' has too many parameters
c:\program files\microsoft visual studio\myprojects\solver2d\springnode1.h(28) : error C2333: '>' : error in function declaration; skipping function body
SpringNode1.cpp
c:\program files\microsoft visual studio\myprojects\solver2d\springnode1.h(28) : error C2804: binary 'operator >' has too many parameters
c:\program files\microsoft visual studio\myprojects\solver2d\springnode1.h(28) : error C2333: '>' : error in function declaration; skipping function body
SpringSolver.cpp
c:\program files\microsoft visual studio\myprojects\solver2d\springnode1.h(28) : error C2804: binary 'operator >' has too many parameters
c:\program files\microsoft visual studio\myprojects\solver2d\springnode1.h(28) : error C2333: '>' : error in function declaration; skipping function body
Generating Code...
Error executing cl.exe.
Creating browse info file...
Solver2D.exe - 6 error(s), 0 warning(s)
I can't seem to spot the error. Any advice?
|
|
|
|
|
Your operator > is a member of the class, so it only takes one parameter (the right-hand side of the comparison). The object on the left-hand side of the comparison is this .
bool operator >(const CSpringNode& rhs) const
{
return (Energy > rhs.Energy);
}
--Mike--
"So where does that leave us? Well, it leaves us right back where we started, only more confused than before." -- Matt Gullett
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
Michael's answer is correct.
I am not sure about this, but I think you need implement the operator <
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Yep. All ordering functions in STL are based on operator< .
--
Ich, du, sie, er, es, ihr, sie, Sie.
|
|
|
|
|
Hi
I have a project containing an ATL Simple object,
It's a VC++ server project.
I am using VB6 to connect to the object.
Now I wanted to add more ATL Simple objects.
I used the wizard and marked the new objects with
Dual support.
But when I try to connect with the objects in VB6 I get
an error msg: 430, that the object doesn’t support automation.
What did I do wrong???
Yoav
|
|
|
|
|
Although i'm not a VB programmer it sounds to me that your interface does not inherit from IDispatch (or is not a dispinterface). VB(and scripting languages) need IDispatch to communicate. Check your IDL file to see if this is the case.
|
|
|
|
|
I'm making a hyperlink control which i obviously need to color but i found out that chil controls don't automaticly receive the WM_CTLCOLORSTATIC message so i thought i needed to do this with Message Reflection. I however don't have a clue how to do this except for Notify messages. Can somebody help me out?
|
|
|
|
|
Have you looked into handling the OCM_CTRLCOLORSTATIC message with reflection?
|
|
|
|
|
If I use this, how do I reflect the message from to parrent to the child?
|
|
|
|
|
I have used something like the following:
In the parent's message map include REFLECT_NOTIFICATIONS()
like:
BEGIN_MSG_MAP(CMainFrame)
REFLECT_NOTIFICATIONS()
...
END_MSG_MSP()
And in the child message map do something like:
BEGIN_MSG_MAP(CChildWindow)
MSG_OCM_NOTIFY(OnNotify)
DEFAULT_REFLECTION_HANDLER()
END_MSG_MAP()
This has worked for me. The MSG_OCM_NOTIFY is from WTL enhanced message crackers in atlcrack.h.
Good Luck,
Tom Rieck
|
|
|
|
|
Hi All,
I can't figure out why VS.NET03 can't find my wtl7 include directory? I set the dir. path in Tools->Options->Project->VC++ Include directories. I even set it in the project settings as an additional include directory.
Any suggestions ? Here is the exact error I am getting.
Compiling...
stdafx.cpp
c:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\WTLTest\stdafx.h(15) : fatal error C1083: Cannot open include file: 'atlapp.h': No such file or directory
Thanks.
R.Bischoff | C++
.NET, Kommst du mit?
|
|
|
|
|
Partial answer to my own question:
I got it to compile by doing the following steps:
1. right click on project, select properties. Then C++/General, under 'Additional Directories' I entered C:\wtl70\include.
2. now i have an error with atlres.h not found, so again, right click on project, select properties. Then Resources/General, under 'Additional Directories' I entered C:\wtl70\include.
Now it compiles, but why doesn't setting the include of wtl7 via Tools->Options->Project->VC++ -> Include directories work ??
Thanks.
R.Bischoff | C++
.NET, Kommst du mit?
|
|
|
|
|
You're using two tools, the C++ compiler and the resource compiler (RC), and they have different settings. If you were using VC++6, and any IDL, then you'd be using a third tool as well, which also has independent settings...
Steve S
[This signature space available for rent]
|
|
|
|
|
I need to redraw composite control each time when Enabled stock property was changed.
Composite control do not use OnDraw method foor displaying itself, so technique for traditional controls is not applicable.
Or give me an example of working composite control with Font and Enabled property support
This is my property map:
BEGIN_PROP_MAP(CADialog)
PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
PROP_ENTRY("AutoSize", DISPID_AUTOSIZE, CLSID_NULL)
PROP_ENTRY("Enabled", DISPID_ENABLED, CLSID_NULL)
PROP_ENTRY("Font", DISPID_FONT, CLSID_StockFontPage)
PROP_ENTRY("TabStop", DISPID_TABSTOP, CLSID_NULL)
END_PROP_MAP()
|
|
|
|
|
How can I make a hash map with an std::string for a key? VC++ .NET barfs, complaining that it cannot convert from type 'std::string' to 'size_t'.
Why couldn't Science, in the long run, serve
As well as one's uncleared lunch-table or
Mme X en Culottes de Matador? James Merrill
|
|
|
|
|
I don't know how to do this but you need to write a hash function.
John
|
|
|
|
|
I found this on a web search:
#include <iostream>
#include <string>
#include <hash_map>
using namespace std;
namespace std
{
template<> struct hash< std::string >
{
size_t operator()( const std::string& x ) const
{
return hash< const char* >()( x.c_str() );
}
};
}
hash_map <string, int> months;
int main(void) {
months["january"] = 31;
months["february"] = 28;
return 0;
}
John
|
|
|
|
|
Here's the hash function I've been using:
namespace std {
template<>
size_t hash_compare<string>::operator()(const string &s) const
{
unsigned long retv = 0;
for (string::const_iterator iter = s.begin();
iter != s.end(); ++iter)
{
retv = 5 * retv + *iter;
}
return size_t(retv);
}
} There's probably a better way to do it, though.
- Mike
|
|
|
|
|
The other ways, of course, to get working hash_map s would be to either
- use STLPort (where
hash_map and hash_set have a hash comparison function defined for std::string s - and also you get nice features like debug mode, which tells you when you've made boo-boos like pushing an iterator outside a container, or used mismatched iterators)
- Upgrade to VS.NET 2003. It cost me GBP19 (USD30 roughly) and was worth every penny - especially for the way more compliant compiler and faster IDE (well, I think it is - subjectively).
Of course, the solution in the other posts is rather more immediate
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Here's how Java get a hash code for the string. The algorithm should be fine:
/**
* Returns a hash code for this string. The hash code for a
* <code>String</code> object is computed as
* <blockquote><pre>
* s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
* </pre></blockquote>
* using <code>int</code> arithmetic, where <code>s[i]</code> is the
* <i>i</i>th character of the string, <code>n</code> is the length of
* the string, and <code>^</code> indicates exponentiation.
* (The hash value of the empty string is zero.)
*
* @return a hash code value for this object.
*/
Best regards,
Alexandru Savescu
<small>P.S. Interested in art? Visit <a href="http://www.geocities.com/mirunadutescu" target="_blank"> this! </a></small>
|
|
|
|