|
But what happed to the BOOL Create(UINT nIDTemplate, CWnd* pParentWnd = NULL); function?
|
|
|
|
|
Naveen wrote: BOOL Create(UINT nIDTemplate, CWnd* pParentWnd = NULL);
Yeah, me too thought about it, I can still see it in the headers though. Pretty strange that he got that error.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Found out the problem.
the other create overload is the one that i wanted
create(dialog number, handle)
because i am using 'this' for the handle but a dll does not have a "Form" handle so it defaulted to the overload that gave me that problem
create(template, handle)
so I use the default null for the handler.
It worked.
|
|
|
|
|
Hello everyone,
When using mapvariable[somekey] = somevalue to insert into a map variable, how to check whether there is conflicting key value in the map in an elegant way?
thanks in advance,
George
|
|
|
|
|
George_George wrote: mapvariable[somekey] = somevalue
[] operator already does a lookup before inserting. Or else just do a map find before calling [] operator .
For inserting an element into a map call insert function instead of [] operator .
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Sorry, Nibu. I think I have not made myself understood. My question is, how to check whether we insert a new key/value pair or overwrite the same key with new value if we use [] operator.
I know using insert could check whether overwriting or not.
regards,
George
|
|
|
|
|
George_George wrote: My question is, how to check whether we insert a new key/value pair or overwrite the same key with new value if we use [] operator.
You don't need to check, that happens automagically IMO.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
I am so bad to express my idea and question.
I want to ask my question in another way -- "using [] could never tell us whether we insert new pair or overwriting an old pair", correct?
regards,
George
|
|
|
|
|
George_George wrote: using [] could never tell us whether we insert new pair or overwriting an old pair
Yes IMO!
Source code for [] operator of std::map looks likewise...
mapped_type& operator[](const key_type& _Keyval)
{
iterator _Where = this->lower_bound(_Keyval);
if ( _Where == this->end() ||
this->comp(_Keyval, this->_Key(_Where._Mynode())))
_Where = this->insert(_Where,
value_type(_Keyval, mapped_type()));
return ((*_Where).second);
}
Take a look at the comment line and the return value, so we can't find out whether we have one or we don't have one, unless we do an explicit find. Also note that it's returning a reference.
George_George wrote: I am so bad to express my idea and question.
Could be my problem too.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Sorry my English is not very good. You mean there is no way to check whether insert a new element or overwriting existing element if we use [] operator?
regards,
George
|
|
|
|
|
George_George wrote: Sorry my English is not very good. You mean there is no way to check whether insert a new element or overwriting existing element if we use [] operator?
Yes!
From MSDN...
If the argument key value is not found, then it is inserted along with the default value of the data type.
operator[] may be used to insert elements into a map m using m[_Key] = DataValue; where DataValue is the value of the mapped_type of the element with a key value of _Key.
When using operator[] to insert elements, the returned reference does not indicate whether an insertion is changing a pre-existing element or creating a new one. The member functions find and insert can be used to determine whether an element with a specified key is already present before an insertion.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Thanks for your great comment, Nibu!
regards,
George
|
|
|
|
|
George_George wrote: When using mapvariable[somekey] = somevalue to insert into a map variable, how to check whether there is conflicting key value in the map in an elegant way?
You can use map::find() to check whether the key is already present in map. Well, the [] operator will overwrite the existing entry if the key already exists.
OT: Be a little careful while using [] operator with map, especially while reading from map. For instance, if you try to get a key-value which is not in map, it create a new entry and return the default value. For instance,
map<cstring,cstring> TempMap;
CString LookupKey = _T("key");
CString Value = TempMap[LookupKey];
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Thanks Jijo,
Good to know that. Previously I wrongly think we can check whether the expression mapvariable[somekey] returns null or not to check whether the element exists. Now I think I am wrong, and using find is the optimum solution to check existence, and using [] could never tell us whether we insert new pair or overwriting an old pair, all are correct understanding?
regards,
George
|
|
|
|
|
George_George wrote: using find is the optimum solution to check existence, and using [] could never tell us whether we insert new pair or overwriting an old pair, all are correct understanding?
Yes! You are right. Since map is tuned for lookup, map::find() will not be a big performance hit. So it seems optimal.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Thanks Jijo!
Question answered.
regards,
George
|
|
|
|
|
i want to allow user that he can press enter in edit control
and i want to set text in edit control like this
SetDlgItemText(IDC_EDIT1,' abc \n xyz ');
\n normaly use for new line my edit control in multil line but \n does not add new line
how i can set mulity line text in mulityline edit control?
|
|
|
|
|
ani_ikram wrote: SetDlgItemText(IDC_EDIT1,' abc \n xyz ');
Did you try "\r\n" ???
SetDlgItemText(IDC_EDIT1," abc \r\n xyz ");
|
|
|
|
|
yes it is working but like thie
SetDlgItemText(IDC_EDIT1,_T("abc \r\n sdfj");
|
|
|
|
|
ani_ikram wrote: yes it is working but like thie
Is this supposed to mean something?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
In the program, there are two CArrays.
One CArray is having another CArray in it.
Sometimes unhandled exception happens in RemoveAt() of outer CArray.
The code looks like:
CArray_Outer[i]->CArray_Inner.RemoveAll();<br />
CArray_Outer.RemoveAt(i);
Is it standard way to delete some item in CArray?
Thanks,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
What is the exception and what is the code causing it?
Are you doing that code in a loop?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am attempting to access the file names as they get displayed in the listview of the Common File Dialog and change the file name text in certain ways. I was able to do this when the listview was not of style Ownerdata (which seems to be in XP), but in Vista they seem to be of style Ownerdata and I am not able to do a SetItemText anymore. Has anyone done something like this, and can help?
|
|
|
|
|
Hi..
I want to display the all content of a list.
I have this function in Band.cpp:
void Band::show_available_music()
{
list<Music>::iterator it;
for ( it=available_music_list.begin() ; it != available_music_list.end(); it++ )
cout << *it << endl;
}
Now in Main.cpp I want to have an option of all the music in the list.
The only thing that comes to my mind is:
band->show_available_music();
But obviously it doesn't work.. can anyone help with this? Thanks
"Failure is always an option."
|
|
|
|
|
what does not work ?
have you tried debugging your code ?
is the method show_available_music called ?
is the list available_music_list filled with data ?
what is Music and does it make sens to use std::cout to print out its data ?
instead of
cout << *it << endl;
have a method in your Music class (I assume it's a class and it have fields) that prints
out each fields individually.
(something like this
for ( it=available_music_list.begin() ; it != available_music_list.end(); it++ )
(*it).PrintMe();
void Music::PrintMe()
{
cout << artist << endl;
cout << band << endl;
cout << release_year << endl;
}
This signature was proudly tested on animals.
|
|
|
|