|
M$'s STL implementation isn't the best.
In fact, the STL included in VC6 was developed by PJ Plauger of Dinkumware.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I guess I just don't get it - what does the STL bring to the table that MFC doesn't do as well or better?
I'm only repeating myself and others, but I've already noted I am an STL zealot, so.....
I've actually recently read that the MFC containers were a stopgap as STL only recently became part of the standard. Having said that, you should certainly get stlport instead of using M$ crappy implimentation.
STL gives you a whole swag of cool functions you can plug in, a number of containers such as queue, vector, map ( which is a tree ), list, all of which can be plugged into the algorythms and work with each other ( so I can copy the contents of a tree into a vector in one line of code ). You can also write custom iterators for your own containers ( MSDN had an example that created an iterator for favourites from IE, meaning they could then be manipulated by the STL algorithms ).
I'd definately recommend this book:
The STL Tutorial and Reference Guide: C++ Programming with the Standard Template Library
It's written by people who worked with Stepanov when he was writing it, and Stepanov himself provides the foreword. To date, everyone I have put onto this book has loved it and the STL.
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
One reason the warnings are generated is due to these templates producing names longer than 256 chars... gotta love templates.
|
|
|
|
|
You can always disable some specific warnings in your pre-compiled header file and never re-enable them. This could be the case for the warning about the length of identifiers.
Also you can uses #pragma include_alias (again from your pre-compiled header file) to include a wrapper file instead of the STL file and from your file, you do a pragma push and a pragma pop before and after including the original file (spelled differently so pragma include_alias won't causes a loop).
Personally I think that at level 4, many warnings are preferable that coding wiothout them. This is even the case for some warnings at level 3. For ex. I do think that a cast is worst that a warning about possible truncature.
However, I do thing that Microsoft should have added the pragma push and pop in the implementation they uses so that with correct code, we won't have any warning in STL files (in fact, warnings settings should not affect standard files when the warning do not depends on the client code).
Philippe Mori
|
|
|
|
|
newbie struggling to understand the difference..
the heap or free-store is unallocated, available memory?
the stack refers to the memory your application is using, constantly shifting as things go in and out of scope (i.e. like a 'stack' of blocks or something thing, you put new ones on top, you take one out at any point and the rest collapses to the new 'stack' of memory?)
Or not?
Many thanks.
|
|
|
|
|
I guess I'll try to take a stab at this, and people who know more than me (most of you) can build on it:
Imagine your computer's memory as a vertical list of memory addresses, ready to be used by whoever. Generally, the stack is just the name for a certain chunk of memory locations at the bottom of the memory, and the heap is everything else on top of it. So, certain actions allocate memory on the heap (the "new" operator) and certain actions use memory in the stack's section (arguments to functions, i think). But basically, it's just two different sections of memory, with the heap starting at the top and growing down, and the stack starting at the bottom and growing up, and programs know what parts they're allowed to use.
I hope this helps, and that I'm not too wrong, since I took a computer architecture course last semester and don't want my prof to kill me
Jake
|
|
|
|
|
Actually, on an intel it is the other way around.
i.e. The stack grows downwards (or backwards),
the heap grows upwards (or fowards) in memory.
The heap does not necessarily have to be below
the stack either - it is just a large block of
memory reserved by the heap manager
James.
|
|
|
|
|
Hi!
I'm writing a function in CMainFrame - and in that function I need to know if my program is minimized/maximized, how do I do that?
|
|
|
|
|
CMainFrame is derived ultimately from CWnd
So you can use CWnd::IsIconic() and IsZoomed.
|
|
|
|
|
Well .. I'm minimizing to the systray .. so I can't use IsZoomed and IsIconid ;(
Is there another way?
please guys, I'm desperate!
|
|
|
|
|
Therefore what i'd do is this:
Add member var to your dialog class:
BOOL m_bWindowState;
Handle OnSize in your dialog:
void CExperimentDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
m_bWindowState=nType;
if (nType == SIZE_MINIMIZED) {
ShowWindow ( SW_HIDE );
}
}
Then, you can programmatically assess the window state by looking at m_bWindowState. Compare it with SIZE_* defines to see whats happening.
|
|
|
|
|
|
I'm having a problem getting rid of the "x" button (close) in my program. I only want to have the "-" button (minimize). The right place for these changes are in BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs), the cs.style .. right?
Well, I hope you've got some answers for me
Lily
|
|
|
|
|
cs.lpszClass=AfxRegisterWndClass (CS_NOCLOSE);
maybe you need set some more parameters of AfxRegisterWndClass
|
|
|
|
|
Thanks alot! .. It worked
|
|
|
|
|
Helloooooo,
Ok sorry to be such a retarded newbie, but I used to be the bomb programmer on the Commodore 64 (ahaha - used to release tron-light cycle and tank games for the modem)..
I am very very very new to C++, and have only 2 books on the subject so far, so please forgive the next question -------- Is Visual C++ different from C++?? I only have a simple compiler so far - DevCpp+ or whatever.
So far I've only been able to make a DOS game where a little packman guy runs through a bunch of periods (aha) through a complete reprinting of its map every time a user types in a direction to run. As far as I know, I can't trap actual keystrokes from the keyboard with the regular cin lahdeedaa. Am I correct in assuming that 'libraries' and 'headers' are merely pre-done algorithms so I don't have to write them myself, and that I need to find a library or header file that will let me catch keystrokes (without waiting for enter) with a simple command? Also, once I find such a (insert definition here), how do I know how to interface/interact with it? Its clear that <iostream> requires me to use cout to put out text, and cin to get it in, but thats only because it was written in a book I read, and its a standard header file. I tried a few libraries/headers already that supposedly made graphics for me, or caught keyboard strokes, but came with almost no documentation so I am left helpless. What am I doing wrong? Is there a website that will explain all these sh*tty details? Another good book? Any collection of source code that will do more explaining than
// Yeah that was a function
?? Help help (cry cry).
Any advice will be greatly appreciated, as I am very excited about learning C++. You can contact me at ontheritz@yahoo.com
Thanks!!!!!
Mike
|
|
|
|
|
|
How to do it by using MFC message map ?
Please suggest me,thanks you.
|
|
|
|
|
|
COleDateTime::GetCurrentTime ()
time(NULL)
GetSystemTime(...)
|
|
|
|
|
Can you detail this code more ?
I dont understand it.
|
|
|
|
|
// example for COleDateTime::GetCurrentTime
COleDateTime dateTest;
// dateTest value = midnight 30 December 1899
dateTest = COleDateTime::GetCurrentTime();
// dateTest value = current date and time
// a second example for COleDateTime::GetCurrentTime
// Since GetCurrentTime() is a static member, you can use it in
// a constructor:
COleDateTime t1 = COleDateTime::GetCurrentTime();
COleDateTime t2(COleDateTime::GetCurrentTime());
// Or in a normal assignment operator
COleDateTime t3;
t3 = COleDateTime::GetCurrentTime();
// or even in an expression
if (COleDateTime::GetCurrentTime().GetDayOfWeek() == 6)
_tprintf(_T("Thank Goodness it is Friday!\n\n"));
Taken direct from the MSDN - if you don't have it you should check it out online - msdn.microsoft.com
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
I have gotten much further in my quest to print from a Dialog based app. The following code enables me to determine the height of the font I have selected. When I print text then move down by the height of the font the second line prints over the top of the lower part of lowercase charactersie. the dangly bit of the g.
LOGFONT* pLogFont = new LOGFONT;
pLogFont->lfHeight = -MulDiv (lfFontSize, dc.GetDeviceCaps (LOGPIXELSY), 72);
How can I determine the height including dangly bits of a given font.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Use positive lfHeight. This will instruct font mapper to interpret this value as 'cell height'. Cell height should include 'dangling bits' (called external leading in fontalese).
You'll find more details in Platform SDK LOGFONT docs.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz to the rescue yet again.
I actually tried this this afternoon as I couldn't see a good reason to have pFontLog->lfHeight as a negative value. As you mentioned the whole character was displayed but at a reduced size.
I printed some text out in Verdana 16 Bold and Verdana 10 Normal. When pFontLog->lfHeight was negative the printed size was the same as from Word 2000. When it was positive the size was considerably smaller.
Is this how it should be? Will I find the answers when I look into the LOGFONT documentation more fully. (I have look fairly extensively at this doco and it hasn't clicked yet).
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|