|
Hello,
I see, I forgot to close a <code> tag... It should read: call delete on pEx. I've just read the documentation on CException and I read that you shouldn't call delete on the object...
You can use a memory leak detect[^] mechanism to detect the leak. There are several others here on CP
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Didn't help, it ASSERTS if you try to 'delete pEx' the ASSERT says to use pEx->Delete() and not the other... Anyway I have traced the problem down some what, the Flush() causes a exception and so does the Close().. I'm not sure how I can catch both exceptions.. I can see 2 exceptions in the debug window yet my trace shows that I am only catching one of the two.. When I put another try/catch around the Close I catch it yet an extra exception occurs (3), this is just odd.. And the memory leak is still there.. weird..
I tried using AfxIsValidAddress() for the CArchive and CSocketFile and this worked like a charm in Debug mode, Said that the address wasn't valid when the connection was lost, yet said it was valid when the connection was present.. but in Release mode it fails every time, connected or not.. ever had any experence in using AfxIsValidAddress?
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I use AfxIsValidAddress a lot, but I never experianced any problems with it.
I see that you catch exceptions, but I don't see you use the exceptions. You only delete them. What is the exception trying to tell you?
Besides that, if you application won't run for a long time and the memory leak isn't too big, I wouldn't worry about it.
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Just to simplify the code i didn't show what i do with the exception, actually I do a ...
char szError[4096];
pEx->GetErrorMessage(szError, sizeof(szError));
TRACE("sendObject Error: %s\n", szError);
pEx->Delete();
... For testing I sometimes used a AfxMessageBox..
anyway, the memory leak is super small, and actually the application will never get that far unless the super un-natural happens, but it still bothers me that I can't figure it out so I just wanted to see if anyone had any ideas..
Thanks for all your help!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Hello All,
It is well know that other systems in my LAN can connect to my machine by typing "\\User\d$" at the Start Menu->RUN... command and entering the password.
Q) Is there any way i could get the list of machine(Ip or Name) connected to mine. Does the sytem registry keep track of all the machines which have/are connected.
please get me some code if possible.
Regards,
Prax
|
|
|
|
|
From a command prompt you can type 'net sessions'..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
"NET VIEW" will give you a list of machines that can access yours.
WNetEnumResource is a win32 windows networking API that will let you iterate through the same list as with the above command.
Ray
|
|
|
|
|
Try NetSessionEnum(NULL, ...) .
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
hello,
I have two .exe, the main application (in mfc) and a directshow filter crossed by a video stream.
From the directshow filter code, when a certain value is detected I have to send it (to the main application) and to make start a method in the main application.
How can I realise such a thing ? Is Callback a possible solution ?
Thanks a lot for your help and have a nice day,
alain
There is no way to happiness, happiness is the way !
|
|
|
|
|
I don't believe callback is possible. Here are some high level suggestions you can research.
You can try the function FindWindow(..) to get a handle on your MFC window and then SendMessage() to send a message to this window. It's a win32 function.
Otherwise you may need to use some other method (interprocess communication). I suppose you can try network communication using sockets. Maybe send/receive on 127.0.0.1. Or I believe Windows should provide some functions to send/receive messages between processes.
There are tutorials on codeproject.
http://www.codeproject.com/threads/[^]
|
|
|
|
|
Thanks a lot for your answer.
I am triing to use the BEGIN_MESSAGE_MAP of MFC to realise what I need :
BEGIN_MESSAGE_MAP(CPatchingMPEG2Dlg, CDialog)
ON_MESSAGE(WM_USER+1, OnMyMessage)
END_MESSAGE_MAP()
I think it's the right direction, but now I get the difficult of paasing m_hwnd variable to my direcshow code. I am going to try your solution with 'FindWindow' which seems very good !
I wish you a nice day,
thanks, alain
There is no way to happiness, happiness is the way !
|
|
|
|
|
|
Hello,
I'm led to believe that one can use GetModuleHandle and GetProcAddress to get a function from another exe...
The thing you can do is export a function from your main application (the callback) and use GetProcAddress from the direct show filter code to call the callback...
Hope this helps
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Hello, thanks a lot for your answer.
I am triing to use the BEGIN_MESSAGE_MAP of MFC to realise what I need :
BEGIN_MESSAGE_MAP(CPatchingMPEG2Dlg, CDialog)
ON_MESSAGE(WM_USER+1, OnMyMessage)
END_MESSAGE_MAP()
I think it's the right direction, but now I get the difficult of passing m_hwnd variable to my direcshow code. I am going to try the solution with 'FindWindow' as suggested by Budric.
If I cannot go on with this I will try your solution.
I wish you a nice day and again thanks very much for your help !
alain
There is no way to happiness, happiness is the way !
|
|
|
|
|
Hi Friends,
I've a treectrl on a dialog based application which gets populated from
ms-access database containing some 2000 records in OnInItDialog. To fetch the
data, i am simply using the SQLFetch and inserting it using a while loop in treectrl using InsertItem, but it takes too much of time. Can anybody help me in speeding up my treectrl.
The fields in my database are "BookmarkName", "BookmarkType" where Bookmark
name is the bookmark name and BookmarkType is either "Folder" or "Bookmark" and Bookmarks are added as child in Folders.
Vikram Kashyap
"You will never fail, until u stop trying"
|
|
|
|
|
you should probably post a snippet of what your routine to insert the items into your tree control looks like. That'll make it easier for us to see where you might have any problems
Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store
My articles[^]
bdiamond
|
|
|
|
|
Hi,
the code snippet...
void CInsertBookmark::LoadTreeItems()
{
BeginWaitCursor();
m_pTree.SetRedraw(FALSE); //Works fine in case of lesser records
CString BookMarkType, BookMarkPath, BookMarkName;
BookMarkType.Empty();
BookMarkPath.Empty();
BookMarkName.Empty();
CString TempPath;
TempPath.Empty();
HSTMT hstmt;
SDWORD len = SQL_NTS;
RETCODE rc;
char m_BookMark_Node_Path[256];
char m_BookMark_Node_Name[256];
char m_BookMark_Type[256];
int nIndex = 0;
strTemp.Format("SELECT BookMark_Node_Path, "
"BookMark_Node_Name, "
"BookMark_Type "
"FROM BookMark "
"ORDER BY BookMark_Node_Path");
SQLAllocStmt(m_pdb->m_hdbc , &hstmt);
SQLBindCol(hstmt,1, SQL_C_CHAR, &m_BookMark_Node_Path , sizeof(m_BookMark_Node_Path), &len);
SQLBindCol(hstmt,2, SQL_C_CHAR, &m_BookMark_Node_Name , sizeof(m_BookMark_Node_Name), &len);
SQLBindCol(hstmt,3, SQL_C_CHAR, &m_BookMark_Type , sizeof(m_BookMark_Type) , &len);
if (SQLExecDirect(hstmt, (UCHAR*)(LPCTSTR)strTemp, SQL_NTS) == SQL_ERROR)
{
DisplayErrorMsg(&hstmt);
SQLFreeStmt (hstmt, SQL_DROP);
return ;
}
while(TRUE)
{
rc = SQLFetch(hstmt);
if(rc == SQL_ERROR)
{
DisplayErrorMsg(&hstmt);
SQLFreeStmt (hstmt, SQL_DROP);
return ;
}
else if(rc == SQL_NO_DATA_FOUND)
break;
BookMarkPath.Empty();
BookMarkPath.Format("%s",m_BookMark_Node_Path);
BookMarkType.Empty();
BookMarkType.Format("%s",m_BookMark_Type);
BookMarkName.Empty();
BookMarkName.Format("%s",m_BookMark_Node_Name);
if(BookMarkType.CompareNoCase("Folder") == 0)
{
m_pTree.Initialize(true);
HTREEITEM hItem = m_pTree.GetNext();
while (hItem != NULL)
{
m_pTree.SelectItem(hItem);
TempPath = GetPathFromItem(hItem) ;
if(TempPath.Compare(BookMarkPath) == 0)
{
//Inserting items into tree ctrl
m_pTree.InsertItem(_T(BookMarkName), ILI_CLSDFLD, ILI_OPENFLD, hItem, TVI_SORT);
BookMarkPath.Empty();
BookMarkType.Empty();
break;
}
else
hItem= m_pTree.GetNext();
}
}
if(BookMarkType.CompareNoCase("BookMark") == 0)
{
m_pTree.Initialize(true);
HTREEITEM hItem= m_pTree.GetNext();
while (hItem != NULL)
{
m_pTree.SelectItem(hItem);
TempPath = GetPathFromItem(hItem);
if( TempPath.Compare(BookMarkPath) == 0)
{
//Inserting items into tree ctrl
m_pTree.InsertItem(_T(BookMarkName), ILI_BOOKMARK, ILI_BOOKMARK, hItem, TVI_SORT);
BookMarkPath.Empty();
BookMarkType.Empty();
break;
}
else
hItem= m_pTree.GetNext();
}
}
}
SQLFreeStmt (hstmt, SQL_DROP);
m_pTree.SetRedraw(TRUE);
EndWaitCursor();
}
|
|
|
|
|
Well, the database fetching data could be slow. Another could be the tree control.
To get the tree to fill faster you can turn off the visual update of the control during the fill. Lookup SetRedraw or WM_SETREDRAW on MSDN or your help.
--
Joel Lucsy
|
|
|
|
|
hi,
i've been looking around on the internet for some flight navigation instrument on C++ (for free ) but i always ended up on GMS and their 400$ activex.
So i was wondering if any of ya knew where i could find some?
Thx in advance
the noob in C++
|
|
|
|
|
Dear All
I have a CListCtrl with a CImageList containing bitmaps. These bitmaps are displayed in LargeIcon View in the List Control.
I want that the user should be able to use the keys like left, right, up, down, pgup,pgdown, home, end etc. to move through the images contained in the List Control.
for e.g. if I am on the last item in the row, the right arrow key should take me to the first item of the next row...
How do I provide this kind of funtionality....
any help would be greatly appretiated...
Thanks in Advance...
Manoj Singh
|
|
|
|
|
I found a file in my archives named cstring.h dated 9/25/2002. This looks like a good replacement for the MFC CString with the same name. I just want to know who I should give credit to if I decide to use it. Does any one know who might have written it? There is one comment at the top of the file that reads: // CString class : exposes the equivalent of the MFC API, without the MFC
Ray
|
|
|
|
|
That isn't a lot to go on. Perhaps a link to the code would be better, if at all possible.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Since you only mention a header file, are all methods inline or is all of the implementation within the header file? This would seem extreme for a String class. You may need to search in your archives for more files before you actually get to use it. Without seeing the code, could it possibly be a copy of the MFC header file for the CString class?
Chris Meech
I am Canadian. [heard in a local bar]
..a scientist venturing into the fields of philosophy and metaphysics is like Tie Domi figure skating. It's not a pretty sight. [Toronto Star Article]
|
|
|
|
|
The implementation of class is within the definition and non are inline. It uses malloc and free and I am finding out that the Format function does not work if there was no data in the string before use. Whoever wrote this probably has already fixed it. Following is part of the class.
class CString
{
// Members
protected:
char *m_str;
// Constructor/Destructor
public:
CString()
{
m_str = NULL;
}
CString(char *szInputSource)
{
m_str = NULL;
if (szInputSource)
Copy(szInputSource);
}
CString(const CString &szInputSource)
{
m_str = NULL;
Copy(szInputSource.GetData());
}
~CString()
{
Empty();
}
// Methods
public:
void Empty()
{
if (m_str)
{
free( m_str );
m_str = NULL;
}
}
void Format(LPSTR pszFormat, ...) // do not use, m_str does not have the right buffer allocated
{ // missing here is a preliminary loop that sums the amount of bytes required to expand pszFormat according to argList %s, %d, ...
va_list argList;
va_start(argList, pszFormat);
vsprintf(m_str, pszFormat, argList );
va_end(argList);
}
Ray
|
|
|
|
|
Do a search for CString replacement here on codeproject I know I downloaded one awhile back from here.. I have to head off to work other wise I would do some searching for you.. I'm sure you will find it.
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|