|
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
|
|
|
|
|
Michael,
The code sample I sent before prints out multiple lines without overlapping of ascenders or descenders. Let me have a look at your code and I'll see what I can do to help.
Derek - Salamander Software Ltd.
|
|
|
|
|
When it was positive the size was considerably smaller. Is this how it should be?
Yes. Assume that you pass +20 as height, device and logical units are identical for simplicity. This will be the height of the character cell - actual letters have to be smaller to fit into 20 pixels.
Pass -20. Font mapper uses absolute value (20) as character height. Character height is only part of the character cell, so actual character cell is higher than 20 pix, say 24. Letters are larger when displayed/printed.
Word and other apps use MulDiv trick to get 'point size'. To make lines spaced correctly, you should call GetTextMetrics after selecting the font. Add tmHeight and tmExternalLeading to get the vertical space for single line of text.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
Is there any macro or some thing to avoid memory leak.I am finding problems with linked lists.
I have 10-12 lists and these are causing(actually my code )during relase.
It not only crashes the program but also the OS.
How to check where exactly is the problem without crashing the program and eventually windows itself.
thanks
|
|
|
|
|
Try using debugger walking your code step by step.
You could also try using BoundsChecker program to catch memory leaks.
Miroslav Rajcic
|
|
|
|