|
hello!
in my mfc-program i need a two dimensional matrix. my problem is: the dimensions (Rows, Cols) are no constant integers, they are integers, only.
a few people in this forum tried to help me, but i still have errors and problems. i know, now (because of the feedback here), that i must do something with 'new' and 'pointer'.
who can help me more in detail?
MFC
|
|
|
|
|
i recomand u using vector of vectors its better that way,
see STL Type: std::vector
If u want to use pointers its something like this:
double ** ppDouble ;
for ( int iLines= 0 ;iLines<iNumberOfLines;iLines ++)
ppDouble = new (double*);
for ( int iColumns=0;iColumns<iNumberOfColumns ;iColumns++)
ppDouble [ iColumns ] = new double;
for ( int iLines= 0 ; iLines< iNumberOfLines ; iLines ++)
for ( int iColumns=0; iColumns<iNumberOfColumns ; iColumns++)
ppDouble [iLines][iColumns] = someValueUwantToaffectOrResultOfAfunction;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
great, thanks.....
only one small mistake:
u wrote:
for(int iColumns=0 ;
iColumns<iNumberOfColumns ;
iColumns++)
but i think you must write:
for(int iColumns=0;
iColumns<iNumberOfLines ;
iColumns++)
thanks for everything!
MFC
|
|
|
|
|
You could use this ready built class
http://www.codeproject.com/cpp/MatrixClass.asp[^]
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
consider the following code snip of code
#include <map>
using namespace std;
typedef map<float,float> XY_DATA;
XY_DATA m_mapLines;
..
..
for(int i=0;i<100;i++)
m_mapLines[i]=i;
well the following assignment for the map is done
and a relative increase in memory consumed is observed.
OK
now for my problem
when i try to release the memory allocated using
m_mapLines.empty()
or
clear()
eventhough when i try map.size() i get zero.
there is no memory reduction in the taskmamager
what should i do to reduce the memory consumed by the map after emptying all its contents???
|
|
|
|
|
What the task manager displays is the memory footprint of the program, which usually does not decrease automatically when deallocating memory. You shouln't actually worry much about it, except if the footprint grows continually and does not stabilize.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
yes so it seems
if i start alocating again say upto the next 100 points the footprint doesnt increase
but after that it starts again
so let me get this staright
1. u r saying everythings ok and there is no memory leak??
2. can i actually reduce the programs memory "footprint"??
3. could u suggest any tools i could use to effectively check memory consumptions/leaks etc..... shareware/freeware the better
4. first time hearing that word ..funky ne...."mem footprint"
thankx
fordge
|
|
|
|
|
For verifying memory leaks, BoundsChecker is the best tool I've used (though it does have it's own annoying quirks and isn't updated as much as I would like, it's also relatively expensive.) VC++ has built in memory leak detection, though it's lousy at actually pinpointing the offending objects. Refer to the documentation.
The current behavior is actually desireable. Were the C++ heap to reduce the memory used with every deallocation, your program would slow measurably.
If you plan on allocating large amounts of memory temporarily, you can use the GlobalAlloc functions (I believe in STL you can write your own allocators, but I'm not well enough acquainted with STL to tell you the details.)
Remember that in Win32, memory is virtualized. If unused, the memory will likely be swapped to disk and will be retrieved when accessed (you don't need to worry about it.) As was pointed out earlier, use perfmon to watch memory usage over time. Watch for continual increasing slopes (also avoid looking at the first few seconds of a program--I've had several programs where you needed to ignore the first five to ten minutes since they looked just like memory leaks.)
|
|
|
|
|
1. Probably: std::map behaves well, and you're not using any pointer stuff, so there's not much room for leaks.
2. Don't know. I guess it can be done, but usually there's no point in achieveing it. Footprint does not compromise the performance of your system.
3. For a start, have a look at _CrtMemCheckpoint and related functions.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
well actually i am using pointer variables in my map
which is actually a pointer of huge struct with project related info..
just didnt mention it in the snippet thinking it would just complicate the matter
i think u guys have sorted things a lot for me
thanx again
|
|
|
|
|
fordge wrote:
actually i am using pointer variables in my map
You need to call delete for every new !
So when you enter a new ed pointer into your map, you have to call delete on it before you dispose you only means of acces to it by erase() .
|
|
|
|
|
I have a modal dialog with a command bar control.
So, to enable / disable some buttons of the command bar control I use the
OnUpdate???(CCmdUI* pCmdUI) function.
So, after I found out that the OnUpdate???(CCmdUI* pCmdUI) function
will not be called automatic (in the idle loop), I added the line
m_pWndEmptyCB->OnUpdateCmdUI((CFrameWnd *)this, TRUE); each time in the
program where I change the command bar state.
It works fine, always the right buttons are enabled / disabled.
I have only one problem!
Sometimes the wrong button icons (disabled/enabled icons)
are painted on the buttons.
When I have a disabled button it could be, that it have a "enabled icon".
And when I have a enabled button, it could be that it have a "disabled icon".
When I click on the enabled button, the right icon (enabled icon) will be painted!
Any idea to fix that problem??? It looks like missing a (re)painting message of the
command bar!
(I am working with embedded Visual C++ 3.0)
--
Nice greets, Daniel.
|
|
|
|
|
Hi !
My question has nothing to do with C++, but well, maybe someone can help me anyway !
I'm launching a BAT file from my App, under Win2000. My problem is that in the .BAT file, 4 commands are executed, but not one after the other : Win2000 opens 4 DOS Windows, and the 4 apps are executed simultaneously.
I always thought that commands in a BAT file were executed one after the other ! Is it something new with Win2000, or with Windows ? Is there a way to make sure that the commands will be executed one after the other ?
Thank your for your help,
Jerome
|
|
|
|
|
Dont use a batch, try looking for system, WinExec, CreateProcess or even better:
http://www.codeproject.com/system/newbiespawn.asp
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
A batch file executed by cmd.exe is AFAIK processed sequentially and synchronously (e.i. pgm2 is executed only after pgm1 has terminated). Are you launching the batchfile using something like
system("%COMSPEC% /C batchfile.bat");
(you might have to do your own COMSPEC substitution)?
|
|
|
|
|
Are you sure the commands in the .BAT file are starting console applications, and not Windows applications. If you start a Windows application from a .BAT file (or a command prompt) it will detach immediately, and the next command in the batch file will be executed.
For example, the batch file:
notepad file1
notepad file2
notepad file3
will start three copies of notepad that will stay around even after the batch file completes.
On the other hand, the batch file:
ipconfig
netstat
nbtstat -a
will run the three programs in sequence, since they are all console applications.
You can achieve your desired behavior with windows applications by putting "start /wait " in front of the program name:
start /wait notepad file1
start /wait notepad file2
start /wait notepad file3
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
Thanks a lot !
This is exactly what I needed to know !
Jerome
|
|
|
|
|
I'm looking for a way to modify the main icon of an executable at run time. The required function, UpdateResource, is only supported in WinNT/2000/XP. Does any one know of a way of implementing something equivalent to UpdateResource in Win95/98/ME? One publicly available commercial library, Geeworks, is sold at the ridiculous price of $2999. Any help would be appreciated.
Henry P.
http://www.allersoft.com
|
|
|
|
|
|
Thanks a lot.
Henry P.
http://www.allersoft.com
|
|
|
|
|
Hi!
I am writing an application whose UI is nothing but a property sheet, with pages on it. How can I do this?
1. If i choose a dialog app in AppWizard, how can i convert this app so that the main dialog gets derived from CPropertyPage (and not CDialog).
Please help
|
|
|
|
|
richiehere wrote:
1. If i choose a dialog app in AppWizard, how can i convert this app so that the main dialog gets derived from CPropertyPage (and not CDialog).
Search & Replace: change all occurrences of CDialog in your class to CPropertyPage.
Shog9
------
And on the pedestal, these words appear:
"My name is Ozymandias, King of Kings,
Look on my Works, ye Mighty, and despair!"
Nothing beside remains.
|
|
|
|
|
hi!
thanks for your reply. are you sure this will work? I had tried something similar but it didnt!
|
|
|
|
|
Give it a try; I can't think of any problems off the top of my head, but if you run into any just ask here & we'll get them resolved.
Shog9
------
And on the pedestal, these words appear:
"My name is Ozymandias, King of Kings,
Look on my Works, ye Mighty, and despair!"
Nothing beside remains.
|
|
|
|
|
if the software appears in add/remove program then i can go to registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
and look for uninstallString key.
but what is the rest of procedure to uninstall a software programatically?
r00d0034@yahoo.com
|
|
|
|