|
If you change
CString myString;
myString.SetString(pMyDlg->ProcessLabel());
to
CString myString(pMyDlg->ProcessLabel());
or
CString myString;
myString = pMyDlg->ProcessLabel();
you should not get memory leaks.
Ant.
|
|
|
|
|
Thanks Antony,
I tried both of them, didn't stop the memory leak
The problem didn't not seem to be on myString, as long as pMyDlg->ProcessLabel() is called in the thread (without saving the return value to anywhere), the memory leak will occur.
|
|
|
|
|
What do you do in your ProcessLabel() function.
It isn't the return of the copied string that is the problem.
Ant.
|
|
|
|
|
I was actually narrowing the possibility by having ProcessString() to look like below:
<code>
CString CMyDlg::ProcessString()
{
CString resString;
resString += "";
return resString;
}
Commenting out resString += ""; will stop the memory leak. Now, I go further and try replace with the following:
resString = ""; <--- no memory leak
resString.SetString(""); <--- no memory leak
resString = " "; <--- memory leak
So, I think as soon as I start putting stuff in resString or when not putting stuff, but use += (resString += "" ), I get memory leak.
I am really confused And when this function is called normally (e.g. not in a thread), there is no problem whatsoever. That's why I think it's something related to the way the function is called in the thread as well.
|
|
|
|
|
Um, Here is a thought what if you changed your code thus
Add a member variable, and alter the return for ProcessString
virtual CString& ProcessString();
private:
CString m_resString;
Then alter the Process String to manipulate m_resString.
Ant.
|
|
|
|
|
Thanks again, Antony,
unfortunately, that didn't seem to work. HOWEVER, instead of using CString & , I tried LPCTSTR in conjuction with the member variable, and the following code
<code>m_resString += "";
no longer gives memory leak (unlike before or ur suggested CString & declaration here). But if I start assigning values into the CString, it still generates memory leak.
I am extremely confused now. Is there a resonable explanation here?
Thanks
|
|
|
|
|
hi
Could someone point me to some tutorials/articles about
creating Web-based user interface in C++ applications?
Something like f.ex. NSIS Menu from Nullsoft installer
package.
thanks
|
|
|
|
|
Hello there!
I have to draw 'straight' lines and I need to draw the line as soon as the user presses the left mouse button and then make the line follow the mouse movement until the user releases the mouse button.
When I implement the LineTo and MoveTo line-drawing functions in OnMouseMove while the Left mouse button is down, well, the line is not drawn.
Can somebody please tell me how I am supposed to implement this?
-Lostris.
|
|
|
|
|
I think the window may not refresh. Could you remember mouse's positions and call Invalidate() instead?
|
|
|
|
|
Oh yes, it works!
Thanks, dear. I guess I just needed some support to help me see this clearly.
Deadlines !
_Lostris.
|
|
|
|
|
I was wondering, is there a message or callback similar to WM_DEVICECHANGE that signals that the network is now connected?
I just tried a little application displaying all message I didn't process while connecting/disconnecting and didn't see any changes to my list of messages.
Is it possible to be informed that the computer is now connected to the network/internet with out doing a test every so often?
Cheers
Dave
|
|
|
|
|
It's not a message per se, but check out the ISensNetwork interface.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I need a method to find out All paths from a node( such as I) to another node (Such as J) in a digraph. the digraph is represented by adjacency matrix!
thanks!
|
|
|
|
|
you could do a google/yahoo search for boost::Graph or go to boost.org to find it - I'm sure it has algorithms for this sort of thing
'G'
|
|
|
|
|
Such an shortest-path algorithm was created by the late Professor Dijkstra.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi all,
Can anyone tell me how to access functions in an MDI application from a DLL?
|
|
|
|
|
Hi,
Same as othe DLLS. use header file..otherwise use GetProcAddress function.
There is nothing special for MDI for accessing DLL functions.
|
|
|
|
|
Hello,
I currently know 10 different programming languages. I have been working on a project for over a year in console C++ and just recently migrated the project over to C#. Just today I have migrated my project to VC++.net. While C# is very nice I have to admit that I feel much more at home in VC++.net. The code looks nearly identical to what I learned in a C++ structures course I took over a year ago.
Is there any standard advice you all can give me on what I should watch out for as I traverse through the MFC in VC++.net??
Thanks in advance.
demasoni.com
Elite
|
|
|
|
|
I need to have some sort of a property sheet whose pages will create some sort of a text file, Now I need to provide a preview of this text getting changed in a window ideally a readonly edit field.
How can I achieve this with CPropertySheet or is there any other way
|
|
|
|
|
something like teh font dialog in word 2000
|
|
|
|
|
Hi All,
I am currently a student and hopefully can get some help through this forum.
I have a project which needs me to create a monitoring software for a mechanical arm using Visual C++ 6.0. I need to capture the direction where the arm is moving and display the result in real time.
The requirement of the project is that i have to create a static lib and create a monitoring software that calls this lib. ( i dun understand but this is the requirement that was given to me )
But the problem is that i can't wait to receive and display the result at the same time.
I am a not an expert in Visual C programing so all suggestions and solutions are welcome.
|
|
|
|
|
how to set send & recv timeout for TCP?
|
|
|
|
|
select() function does this
TOXCCT >>> GEII power
|
|
|
|
|
In my program, I create a controlbar . If I double click on the controlbar, it can get the LButtonDblClk message. Then I create an rebar on that controlbar, but if I double click on the rebar, the controlbar can't get the LButtonDblClk message. And I find if I right click on the rebar, the controlbar still can get the right-click message. It is strange.How could I get the LButtonDblClk message in the controlbar when I doubld click on the rebar?
Thanks
Benben
|
|
|
|
|
are you sure it is the right control that is handling the message ? (be sure it is the child class tha is doing so)
TOXCCT >>> GEII power
|
|
|
|