|
Kevin McFarlane wrote: I would if they were using the older non-templated versions though
I didn't know that such a nightmare even existed....
Yeah, the core problem is people using what they've always used, instead of moving forward.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: They are in every way inferior to STL containers list and vector.
This is a gross mistatement. The MFC containers are FAR from inferior to STL containers. They are different, and designed to serve a different purpose, but that does not make them inferior. In fact, in many ways (e.g. iterating though a collection) they are actually superior to STL containers (although, granted, if you code STL properly, you should be doing very little iterating, but that is another topic altogether).
My point is, do not compare apples to oranges and state that apples are superior. MFC containers were designed to fill the need for flexible containers in Windows (specifically MFC) applications. STL containers were designed to be portable across many platforms.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I did post a lengthy reply, the site lost it. In brief
1 - My understanding has always been that the MFC containers existed because there was no STL at the time, MFC containers do not have any special purpose beyond that. They naturally integrate somewhat with MFC, they are part of it.
2 - MFC containers are in my opinion a real pain to iterate over compared to STL, not least because they follow no standard or pattern. This is worse if you need to copy items between containers.
3 - Yes, even a pointer is a random access iterator. This is one way in which the STL shows sign of intelligent design and the MFC containers do not.
4 - Most people who use MFC containers don't even know the STL exists, or assume they need to use the MFC ones because they were written by MS. That is the sort of ignorance that leads me to tell people to look into the STL.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: My understanding has always been that the MFC containers existed because there was no STL at the time, MFC containers do not have any special purpose beyond that. They naturally integrate somewhat with MFC, they are part of it.
STL "existed" when the MFC containers were designed, but the S part was missing (that is, there wasn't a formalized standard yet (which is why many systems still have the .h versions of the standard header files). They were not designedas a gap filler until STL was formalized; they were designed to provide convinient containers to make MFC programming easier. Hence the reason they have built-in serialization support.
Christian Graus wrote: MFC containers are in my opinion a real pain to iterate over compared to STL, not least because they follow no standard or pattern. This is worse if you need to copy items between containers.
MFC containers use iteration techniques tha follow a logical pattern for the type of a given container. It can be confusing (and a grave, and all to common, mistake) to assume that you can just change the type of a STL container in a "drop-in" fashion. MFC at least makes you think, "Do I really want to change this array container to a list?" I view that as more of a feature than a pain; especially when dealing with newer programmers.
Christian Graus wrote: Yes, even a pointer is a random access iterator. This is one way in which the STL shows sign of intelligent design and the MFC containers do not.
While this is a nice feature for STL, it also makes it more complicated to teach to newer programmers (try explaining why you should use iterators to someone who has been programming for 3 weeks after you just got them to understand pointers).
Christian Graus wrote: Most people who use MFC containers don't even know the STL exists, or assume they need to use the MFC ones because they were written by MS. That is the sort of ignorance that leads me to tell people to look into the STL.
While I don't disagree with that statement (not completely anyway), that is a bold jump from the original question. And the fact remains, use the correct datatype (and correct library) for the task at hand.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
|
-Mohan- wrote: Please briefly explin the difference between the CList and CArray.
The biggest difference is that items in a CArray collection can be accessed directly. For example, to get to the fourth item, there's no need to iterate items 1-3 first.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hello friends,
I am working with dialog based application,I have created a menu bar for that,Now i want by clicking a menu option like "quote" it will open a another window and from that window function I want to call other function so taht it start display what in that window.How is that possible.
By which function i will do this.
thanks
|
|
|
|
|
if you can catche handle of a window , then you can do any thing
|
|
|
|
|
Thanks for your reply,
How to catche handle of a window so taht i can call all other function from there.So taht window will start display which i am getting from server.
|
|
|
|
|
All you need is have one more modal dialog and then do a DoModal dialog in the menu command handler.
|
|
|
|
|
Thanks for your reply,
Can you pls explain me more.As i am new to CV++ ,so all the concept are not clear to me.
If you need more information then pls.
|
|
|
|
|
See CWnd::GetParent
if Main is Main class you can use this code ion another class
CMain* m_Main=(CMain*)GetParent();
m_Main->functiron or data
|
|
|
|
|
Thanks for reply,
I need to ask my project is dialog based wil these work with that.
If yes what should all other thing/class should i include to make these function work
|
|
|
|
|
Priyanka... Let me know whether you want to create another dialog box from this dialog box?
If yes
Just place this code in the hanlder of that menu item
<br />
CSecondDlg secDlg;<br />
secDlg.Domodal();
if this isn't enough come with your next question.
KIRAN PINJARLA
|
|
|
|
|
no kiran i dont want to create second dialog,
let me expalin you....
I have function which i am calling through dialog box.now i want that by clicking a button it will open a window(which will open untill click to exit) and from that window i will b able to call all other function so that it will start display the data getting from server.
Hope i am clear if not pls remind me
Thanks for your reply
priyanka
-- modified at 1:27 Monday 7th August, 2006
|
|
|
|
|
if your program dialog yes and see GetParent in msdn this function obtain a pointer to parent window
|
|
|
|
|
problem is that I want to disable one of buttons in the toolbar,
for example:
I create a toolbar in an application based dialog:
if (!toolbar.CreateEx(this,<br />
TBSTYLE_FLAT|TBSTYLE_TRANSPARENT <br />
, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP, <br />
CRect(0, 0, 0, 0), AFX_IDW_TOOLBAR) <br />
||!toolbar.LoadToolBar(IDR_TOOLBAR1) )<br />
{<br />
TRACE0("failed to create toolbar\n");<br />
return FALSE;<br />
}<br />
<br />
toolbar.SetButtonText(0," config "); <br />
toolbar.SetButtonText(1," connect ");
toolbar.SetButtonText(2," transport ");<br />
toolbar.SetButtonText(3," disconnect ");<br />
CRect rc(0, 0, 0, 0);<br />
CSize sizeMax(0, 0);<br />
CToolBarCtrl& bar = toolbar.GetToolBarCtrl();<br />
for (int nIndex = bar.GetButtonCount() - 1; nIndex >= 0; nIndex--)<br />
{<br />
bar.GetItemRect(nIndex, rc);<br />
rc.NormalizeRect();<br />
sizeMax.cx = __max(rc.Size().cx, sizeMax.cx);<br />
sizeMax.cy = __max(rc.Size().cy, sizeMax.cy);<br />
}<br />
toolbar.SetSizes(sizeMax, CSize(16,15));<br />
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);<br />
Now, I want to disable the button , which that ID is IDC_CONNECT, I had mark it , what can I do , how to add codes to change the state of the toolbar's button?
waiting for answers online!
-- modified at 0:02 Sunday 6th August, 2006
Just my interest for these common things
|
|
|
|
|
toolbar.EnableButton(IDC_CONNECT, FALSE);
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
EnableWindow()
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
thank you very much, I believe I can do it now !
Just my interest for these common things
|
|
|
|
|
Does anyone know about a decent standalone c-cpp pre-processor (preferably with source code), written in c or cpp.
LateNightsInNewry
|
|
|
|
|
|
If you are not looking for source code, but want to see how pre processing takes place , the /E option of Microsoft c/c++ (cl.exe) compiler will generate preprocessed output.
|
|
|
|
|
Check out Boost's Wave library here[^].
Steve
|
|
|
|