|
If you can set a breakpoint (that is reached) on the delete *pMySt[i] statement, and not see a "Detected memory leaks!" message in the Debug tab of the Output window, you have no memory leaks.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Thank you again for your reply.
No "Detected memory leaks!" message was observed anywhere!!
I believe, looking for values of certain pointers was not a good thing to do. I thought those pointers would show no values (sort of equivalent to NULL) which would then indicate they were NOT pointing to anything, and therefore indicating (memory of) the array had been properly deleted.
Thanks for your help. I appreciate it.
William
Fortes in fide et opere!
|
|
|
|
|
As an afterthought, I commented out the "delete" statement to which you refered, compiled and run the program over, and saw no message about any memory leak detected!!
Shouldn't I have seen a memory leak message (considering quite a number of those objects were created)?
Yes, I did run the debugger. (VC++ 6.0, using Win2K)
William
Fortes in fide et opere!
|
|
|
|
|
Well, not having everything in front of me, I may not be 100% accurate in reproducing this. I added the following to an existing project I was working on:
class CMyDialog : public CDialog
{
public:
CMyDialog();
~CMyDialog()
{
delete pMySt[0][0];
}
BOOL OnInitDialog()
{
CDialog::OnInitDialog();
pMySt[0][0] = new MyStruct();
return TRUE;
}
struct MyStruct
{
} *pMySt[10][10];
}; If the delete statement was commented out, a memory leak was indeed detected.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Any array value that you assign to needs to have delete called on it. If you need to use delete rather then using one of the various smart pointers out there, then I've found the following very helpful.
1. Always initialize all pointers to NULL.
2. Set the pointer to NULL after you call delete.
Note. it is always safe to call delete NULL, but smart pointers are much better.
BTW. it looks like you are only deleting the first 10 entries in a 121+ element array. You might just need to fix by changing your destructor loop to
for(int i=0; i
|
|
|
|
|
HI u all gurus on code project
i am a beginner in vc++ . i am trying to make a plugin like visualisation ..for wmp.I read info from msdn. but i need some more .
anybody done this kind of stuff.Can anybody give me some sample code.so that i can understand..
or suggest any link about this.
Reply me soon
rahul
|
|
|
|
|
|
I have a small dialog based code that proceeds through several dialogs to input data into a database. I have developed this on two separate machines and it works fine, when I copy the files to a third machine the code fails to open the second, or any subsequent, dialogs. I am using peekmessage to handle WM_DESTROY.
Many Thanks for any suggestions
|
|
|
|
|
This could be due to a number of reasons. Anything from invalid database connection, to differences in Operating Systems.
A little more information is needed to trace this problem down.
I Dream of Absolute Zero
|
|
|
|
|
Here is the code that causes problem, CIOC_Login is a CDialog based class:
<br />
while (control.Login == FALSE)<br />
{<br />
dlg0 = new CIOC_Login();<br />
m_pMainWnd = dlg0;<br />
nResponse0 = dlg0->DoModal();<br />
::PeekMessage(&msg,NULL,WM_QUIT,WM_QUIT,PM_REMOVE);<br />
...........<br />
...........<br />
delete dlg0;<br />
}<br />
....<br />
....<br />
while (nControl !=2) <br />
{<br />
int nResponse1;<br />
nResponse0 = dlg1.DoModal(); <-- Doesn't open!<br />
::PeekMessage(&msg,NULL,WM_QUIT,WM_QUIT,PM_REMOVE);<br />
|
|
|
|
|
MSDN articles Q138681 and Q253130 might be of interest to you.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Thanks, deleting the reference to m_pMainWnd solved the problem.
AndyB
|
|
|
|
|
Hello,
I have a MDI type application with 2 different views. I create the CDialogBar in my CChildFrame class so the DialogBar is viewed with in the child frame. I want to catch WM_LBUTTONDOWN messages for the dialog bar but can't. I have tried to catch this msg in CChildFrm::WindowProc and other obvious areas but never see the message.. I used spy++ and can see a WM_SETCURSOR msg being sent to the ChildFrame with a WM_LBUTTONDOWN as part of the WM_SETCURSOR message (kinda confusing).. Any ideas?
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Never mind, I figured it out.
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Ok, so I'm writing a multi-user database app. The downside is that I am interfacing with Access databases. Now it's not like hundreds of users, but maybe tens of users, so here is my design dilemma...
Should I:
A. Create a connection to the database and keep that connection open during the application lifetime.
B. Create a connection to the database, buffer the data, close the connection, and then only reconnect to commit changes.
C. Open and close the connection each time data is updated WITHOUT buffering the data.
D. Some other idea?
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
I guess the methods of keeping your "connetion pool" will differ, depending on your software circumstances.
I would never by default consider C., because it can eat up considerable amount of time each time you connect. But this may be necessary on a stateless Client/Server program.
Personnally, I tend to keep a db connection, disconnecting after a specified amount of inactivity, then reconnect when required.
I Dream of Absolute Zero
|
|
|
|
|
The answer really depends upon the frequency that the user will hit the database. Remember, connecting to a database is very expensive, so if the users will be accessing the database more than every couple of minutes, it makes sense to connect and keep the connection open.
onwards and upwards...
|
|
|
|
|
I have some problem. I'm not sure how to do a program that synchronize the time for five computers.
One computer will be a Master and get the time with ntp. And then sent a signal to the other four computer for example every 10 second.
Is there someone that can help me get started and give me some hints how I should do?
/stefan
|
|
|
|
|
Rather than implement a push design, why not go for a pull design? You could create a scheduled task on each of the computers that periodically started a .BAT file that contained the appropriate net time command.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hi guys,
I have stumped through something that I think should be easy to do, but yet to make it work. Basically, I have a plan edit control (CEdit) which I want to make it un-editable, no text, space etc can be put it. The content will only be changeable by the app internally, using SetWindowText().
I can't make it Read-Only as it will grey out the content area, I still want the text inside the edit control selectable. Disabling the control greys out the whole box too. I had a thought to override OnKeyDown and OnKeyUp messages for this particular control but maybe I had them written wrong.
in the class declaration, .h file,
afx_msg void OnKeyDownEdit1();
in the .cpp file
BEGIN_MESSAGE_MAP(MyMainDlg, CDialog)<br />
ON_WM_KEYDOWN(IDC_EDIT1, OnKeyDownEdit1)<br />
END_MESSAGE_MAP()
void MyMainDlg::OnKeyDownEdit1<br />
{<br />
}
It'd be great if someone could point me out where I did wrong here. Or if completely wrong, what shoudl I do instead.
Thanks alot
|
|
|
|
|
you need to derive your own edit class from CEdit , and in which you handle the keystrokes.
or if it's always a read-only control, maybe a CStatic derived class can be used.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
CEdit includes a SetReadOnly( )[^] function.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
J.B. wrote:
I have stumped through something that I think should be easy to do, but yet to make it work. Basically, I have a plan edit control (CEdit) which I want to make it un-editable, no text, space etc can be put it. The content will only be changeable by the app internally, using SetWindowText().
Then why not just use a static control? It satisfies all of your requirements.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Mr.Crow if you dont me mind saying that you shuold give a proper ans or nothing at all. Do you know that you cant have scrolling effect with the static control, Or horizontal scrolling with the static control. What if he just wants to display some long text that can only be viewed and not edited?? Did you consider this? or were you giving with some unwanted suggestion?
Any ways the solution to the problem is checking the Read-only in Styles of the edit box.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
Goodness gracious, someone woke up on the wrong side of the bed this morning! Are you always so tactfulless on Thursdays?
Did you know that using the ES_READONLY style also has the side effect of graying the edit control? I suppose that's just as incorrect as my answer. Yes?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|