|
Tools->Options->Environment->Keyboard
If you select the VC6 scheme, set focus to the Press shortcut keys edit control and click the F4 key, you'll see that in that scheme, it resolves to a the View Next Task command. Simply change it to whatever you want
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Hi,
I'm playing with an FTP client, and I'm trying to figure out how to download files from the server in PASSIVE mode. The problem is, I can't figure out how to tell when the client should stop trying to recv data from the data socket and close the socket. In normal mode, the server would close the socket, so I could simply recv until I got a CLOSE event on the socket, then just read the remaining queued data.
So, how do I tell when a transfer is finshed in PASV mode? I was originally thinking that I could wait for the 226 - Transfer OK on the control socket, and then stop when got that, but that seems to arrive before all of the data has arrived on the data socket, so it's not very reliable. Should I just count the number of bytes received and compare to the file size indicated by the server?
Thanks
|
|
|
|
|
I wrote a Pro*C application in VC++ on Windows 2000 and I built it and it runs fine on my machine, but when I try to execute it on the server running NT, it doesn't execute. Not sure if I'm building it wrong or anything like that. I've never had this problem before.
Does anyone have any ideas?
|
|
|
|
|
You might be using some features not availiable on NT4, there's plenty of stuff that works on Win2k that doesn't work on NT4...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi,
Is there any function that converts one string into a valid XML tag ? ( In my app the user types some names for some values, then I want to use that names as tag names but I would like to filter them to avoid having a bad formed XML file).
Thanks, Bye !
Braulio
|
|
|
|
|
If you are using IXMLDOMDocument, if I remember it correctly, it's all taken care of for you.
Are you maybe just looking for a general escape function?
|
|
|
|
|
Hi,
Yes, I´m using MsXml, but I think CreateElement throws one exception when you pass a wrong tag name, I don´t know if maybe there is one method there that converts from the string to a valid tag name
|
|
|
|
|
Yes, the tag names and attribute names are different. You are not allowed to use special characters there. In attribute values and text data however you can just pass in anything you like. Calling pXMLDoc->createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); will give a coding of your choice. (just tried it)
As for tag names and attribute names, I suspect yuo have to 'destroy' data to get where you want, i.e. replacing e.g. '>' and '<' and all other 'illegal' characters with '_'.
|
|
|
|
|
hrm.
i have about 8 different memory leaks, and i can't seem to track em down.. so i have some questions..
1) do memory leaks only occur when the 'new' keyword is used to create a pointer, and that pointer is never deleted (using 'delete' keyword)?
2) if my memory leaks say 'CObject' is there any way to tell what class it is?
i am using several classes i derived from CObject, and i use CObArray quite alot too.. i know that after im done with a CObArray that i have to loop through it and delete all the objects, and im doing this everywhere..
any help in general would be great.. i don't want to have any memory leaks..
thanks!
-dz
|
|
|
|
|
dazinith wrote:
do memory leaks only occur when the 'new' keyword is used to create a pointer
You can also get memory leaks when you create GDI objects such as pens and brushes and forget to unselect them out of the DC and delete them.
dazinith wrote:
i know that after im done with a CObArray that i have to loop through it and delete all the objects,
Perhaps you're forgetting to do a RemoveAll() after you delete the individual objects?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Actually, you do not need to remove items from an array once they've been deleted. I do it as a sanity check so that after the delete loop I can assert if any items remain in the array. However, once you've deleted the actual item in memory, the array simply points to an invalid item for which no memory is still allocated.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Ah. Looks like CObArray 's destructor cleans up after itself. Thanks for the tip!
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
No problem. I've actually spent so much time in the guts of MFC that I've often thought of writing a second edtion of the MFC Internals book. Do you think such a book would sell? I think it would. I think there are stil enough people new to MFC that would get a tremendous amount out of a book that explains how their apps are working internally. The thing that I would add to such a book, however, is a section at the end of each chapter that basically says "Ok. You know how this bit works internally. Here's where you can apply this knowledge". I think that would make the book more practical instead of coming off as just trivia. What do you think?+
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Tom, I for one would welcome (more) info on MFC's internals. And as you pointed out, real-world usage examples would come in *very* handy.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Sounds like a good idea.
There's a couple of people here (including me) who'd like to know more about MFC and how to apply it.
A problem I have is that I know what I want a program to do, but not how to achieve that in a windows environment. CP has helped a lot, but sometimes a book of 'typical' applications would help too
Paresh Solanki
There is no substitute for genuine lack of preparation.
|
|
|
|
|
dazinith wrote:
any help in general would be great.. i don't want to have any memory leaks..
Always a worthy goal
The way to track down memory leaks in an MFC application - short of spending hours and hours manually tracking down and tracing on every new and delete operation - is to use the CMemoryState class. There are actually several ways to use this class so instead of me enumerating them all, I'll just point you to the article entitled "Taking Memory Snapshots" in your MSDN online help.
Good luck! Everybody hates those *#*& things!
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Make sure you have no code that looks like
CObArray vec;
for (int i = 0; i < vec.GetSize(); i++)
{
delete vec[i];
vec.RemoveAt(i);
} where just every other element is deleted. This one I've seen lots of times.
|
|
|
|
|
my deleting of CObArray's looks like this
// delete all items in the text list
if (m_oaText->GetSize() > 0)
do
{
CTextPrintObject* pObj = (CTextPrintObject*)m_oaText->GetAt(0);
delete pObj;
m_oaText->RemoveAt(0);
} while (m_oaText->GetSize() > 0);
m_oaText->RemoveAll();
delete m_oaText;
does this look right?
-dz
|
|
|
|
|
Sure looks functional enough. (Even though quite inefficient calling RemoveAt(0), since the array has to do a copy of all remaining items for each turn in the loop. Maybe you should consider looping backwards.)
Does you CTextPrintObject allocate any memory, not deleted in it's destructor?
|
|
|
|
|
After having read Tom's post, I think I'd write this as:
for (long nIndex=0; (nIndex < m_oaText->GetSize()); nIndex++) {
CTextPrintObject* pObj = (CTextPrintObject*) m_oaText->GetAt(nIndex);
ASSERT (pObj != NULL);
delete pObj;
m_oaText->SetAt (nIndex, NULL);
}
delete m_oaText;
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
welp i think i found where the leak is.. but i don't know whats wrong with the code.. if i comment out this chunk of code i only get 1 memory leak.. if i dont comment it out i get 8.. anyone have any suggestions as to whats wrong with this? basicly im just setting dates for a couple date pickers..
//Setup the date picker
m_cdPeriodEnd.SetFormat(_T("MM/dd/yyyy")); // force short date format to MM/dd/yyyy
m_cdPeriodBegin.SetFormat(_T("MM/dd/yyyy"));
COleDateTime dtMin(2002,7,31,0,0,0); // set the minimum date which can be chosen
COleDateTime dtMax(2003,6,30,0,0,0); // set the maximum date which can be chosen
// verify the min and max dates are valid, then set the range for the date picker
if ((dtMin.GetStatus() == COleDateTime::valid) && (dtMax.GetStatus() == COleDateTime::valid))
{
m_cdPeriodEnd.SetRange(&dtMin,&dtMax);
m_cdPeriodBegin.SetRange(&dtMin,&dtMax);
}
else
{
if (dtMin.GetStatus() != COleDateTime::valid)
AfxMessageBox("This program has attempted to set an invalid minimum date for selection.");
if (dtMax.GetStatus() != COleDateTime::valid)
AfxMessageBox("This program has attempted to set an invalid maximum date for selection.");
CDialog::EndDialog(IDABORT);
}
-dz
|
|
|
|
|
hrm.. nevermind i don't think thats it.. i think i should be able to track it down, thanks for the advice, and thanks for letting me know about deleting brushes too!
thanks!
-dz
|
|
|
|
|
Try this console code, it demonstrates C Runtime Library on memory leak detection.
#include <iostreamᡊe9ac73-238b-46be-991d-0f050c37248d#include <crtdbg.hᡊe9ac73-238b-46be-991d-0f050c37248d
using namespace std;
void main()
{
_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
int* p = new int;
*p = 4;
p = 0;
delete p;
}
Maxwell Chen
No code is good code.
|
|
|
|
|
and if you defines #define _CRTDBG_MAP_ALLOC before any includes, you also get the line where you allocated the (not free'd) memory...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
But when I applied those functions
_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT); in MFC app projects, set the debug argument to redirect the report to some txt file like MemLkRpt.txt , nothing's reported in that file. How should I do, like: when should these _CrtSet???( ) functions be called, in the ctor of theApp, or some other where? Any additional steps must be taken? ... etc.
And by the way, I can not delete the generated MemLkRpt.txt file!
Thanks
Maxwell Chen
No code is good code.
|
|
|
|