|
Unless you've got a strong reason not to do it, you'll be much better off declaring your member variables as straight CString s (i.e. not pointers). Maintaining the integrity of your program when it comes to copying objects can be a real nightmare if you use pointers throughout. Besides, the overhead incurred by copying CString is negligible in most cases (and certainly it is if you don't expect to have more than 100 objects around.)
As for whether to store objects in the heap or in the stack, my advice is: declare everything in the stack unless you cannot (the reasons why you cannot should be obvious when you come to them.)
Another advice. Use extensively BBG_SECURITIES& (or even better const BBG_SECURITIES& ) as the parms of your functions whenever it is doable.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi:
Thanks for your reply.
I am sort of a newbie, and I am not sure what you mean by that, and what it actually does:
>Another advice. Use extensively BBG_SECURITIES& (or even better const >BBG_SECURITIES&) as the parms of your functions whenever it is doable.
Thanks
|
|
|
|
|
OK. Suppose you've got some function like this:
void PrintSecuritiesData(BBG_SECURITIES bbgs); Whenever you call this function, a temporary copy of the BBG_SECURITIES passed is made and pushed onto the stack. If the function happens not to change the object, you can safely replace it with:
void PrintSecuritiesData(const BBG_SECURITIES& bbgs); that does not trigger any copying at all. These are called references, and in may ways act like "hidden pointers". If you've got some C++ tutorial or book check references out to learn more about them.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I need to use owner draw methods in a tabctrl.
2 things:
-I don't know how to do it. I've set the TCS_OWNERDRAWFIXED style for it, but where should I now draw it? In the OnDraw method? But how? Does somebody have a sample?
-In fact I want to add some text in the tab itself. That is that I have listcontrols in the tab windows, and I want to show the selected item in the tab. Maybe there is another way to do that.
Please someone help me.
Thanx in advance.
|
|
|
|
|
This article* should be of help
http://www.codeproject.com/tabctrl/lbtab.asp
*Hey Nish, I spelt "article" right!
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Thanx.
What I don't understand is how you get to go through the DrawItem method?
It is a real mistery for me.
|
|
|
|
|
It works now!!
Thanks a lot!!
|
|
|
|
|
First I would like to thank all of you who have made suggestions about this problem you've been a big help. Second I apologize if reposting a topic is considered bad form, but its difficult to find a thread after a couple of days on this forum.
This problem is more bizarre than I had originally thought. As stated before, if the app is run in debug its fine. If the debug .EXE runs outside of debug the app memory usage appears to grow linearly with time. The release .EXE, which I have now built and tested, does the same thing.
Now I've found a new twist...
Following a suggestion from Mike Nordell, I was setting up PerfMon this morning to look at exactly how memory was being used. Unexpectedly while doing this the memory used by the app dropped from 27MB to 17MB. After watching PerfMon for several minutes and wondering about the memory drop I decided to minimize the app then restore it. The memory again dropped. This time to about the original starting value.
If this is a destructor issue how does a minimize/restore change things? Does debug perform some type of clean-up that the OS waits for user interaction to trigger? This isn't Java and I wrote the app to take care of itself, so what gives?
>>>-----> MikeO
|
|
|
|
|
You are looking at the working set size and not the real virtual memory size.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Wasn't sure what you meant at first.
Went back and looked at the overall memory usage and it is still high.
So, if it is objects not being released, why does the overall memory usage remain low when debugging remotely?
>>>-----> MikeO
|
|
|
|
|
There is always the chance that due to bugs in your software memory is getting freed in debug build and not in release. The usual cause of this is uninitialized variables in routines. Another cause if writing past the end of allocated memory.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Any known memory issues with maps in the MS STL library?
>>>-----> MikeO
|
|
|
|
|
I think so. Check the updates at Dinkumware. IIRC it's at
http://www.dinkumware.com/vc_fixes.html
Regarding the memory drop when minimizing: As already pointed out it's the working set that drops. The reason for this is that every time you minimize an application, Windows does what in effect is like calling SetProcessWorkingSetSize(GetCurrentProcess(), -1, -1); from within the app itself.
|
|
|
|
|
Easy question, this is.
I want to start a function after a CDialog appears on the screen, after the initialisation and paint functions that is. What message do I use, or which function do I deprecate?
It's a bit like the windowOpened(WindowEvent e) java-equivalent.
I've tried several functions and messages (like WM_SHOWWINDOW), but they all appeared before the dialog showed up.
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
Try to handle first occurence of WM_ENTERIDLE message. It should be sent after your dialog had been displayed.
Martin
|
|
|
|
|
How can I change the CDialog message filter to a message filter for Window? Because ENTERIDLE is a Window-message, not a CDialog-message.
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
Oeps, too hasty. Forgot the clw. Never mind.
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
I am sorry, I did not realise, WM_ENTRIDLE does not work in CDialog, and you cannot use. Instead of that, you can use WM_KICKIDLE:
1. Include #include <afxpriv.h> to your dialog cpp file.
2. add ON_MESSAGE(WM_KICKIDLE, OnKickIdle) to your message map
3. add function LRESULT OnKickIdle(WPARAM, LPARAM lCount); to your dialog.
It will work in the same way as WM_ENTRIDLE.
Martin
|
|
|
|
|
PostMessage(WM_USER+1) from OnInitDialog()
Now in the handler for WM_USER+1, you can do your stuff.
You'll have to add the message macros manually.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
I Need to get the file size of a file,
Anyone ho now???
\GoLa
|
|
|
|
|
|
Thanks but I need to use FindNextFile do you now how???
\GoLa
|
|
|
|
|
Like this?
int Size;
CFileFind finder;
CString FileType("*.TYP");
while (BOOL Found = finder.FindFile(FileType)) {
Found = finder.FindNextFile();
if (Found) Size = finder.GetLength();
}
>>>-----> MikeO
|
|
|
|
|
Is better in that mode:
int Size;
CFileFind finder;
CString FileType("*.TYP");
finder.FindFile(FileType)
while(Found)
{
Found = finder.FindNextFile();
Size = finder.GetLength();
}
Olways when you need to know any propiertie of a file that you found, you need to do FindNextFind
Best Regrds
Carlos Antollini.
www.wanakostudios.com
Sonork ID 100.10529 cantollini
|
|
|
|
|
Carlos Antollini wrote:
int Size;
CFileFind finder;
CString FileType("*.TYP");
finder.FindFile(FileType)
while(Found)
{
Found = finder.FindNextFile();
Size = finder.GetLength();
}
Hi Carlos,
Looking things over I think we both left some issues dangling. Let me try one more time:
BOOL Found;
CFileFind finder;
CString FileType("*.TYP");
Found = finder.FindFile(FileType)
while(Found)
{
Found = finder.FindNextFile();
Size = finder.GetLength();
}
When Found changes to false is finder still valid? I can never remember exactly how that works.
>>>-----> MikeO
|
|
|
|