below code i used. My problem is more then 5 times i call this function. It shows 'debug assertion error'
finally debug goes here
// all other messages route through message map
CWnd* pWnd = CWnd::FromHandlePermanent(hWnd);
Here My Code
TCHAR szFilters= _T("MyType Files (*.my)|*.my|All Files (*.*)|*.*||");
// Create an Open dialog; the default file name extension is ".my".
CFileDialog fileDlg(TRUE, _T("my"), _T("*.my"),
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilters);
// Display the file dialog. When user clicks OK, fileDlg.DoModal()// returns IDOK.if(fileDlg.DoModal() == IDOK)
CString pathName = fileDlg.GetPathName();
// Implement opening and reading file in here.//Change the window's title to the opened file's title.
CString fileName = fileDlg.GetFileTitle();
You did not show the line that asserts so I can only guess that it checks if pWnd is NULL (I have no VS2008 here but it seems that the code snippet is from the AfxWndProc function).
From that line debug backwards to identify the invalid window handle that finally leads to the assertion.
Because your code snippet using the CFileDialog is just a copy of the MSDN example code I guess that the assertion is not related to the file dialog but to some other window or you did not showed the used code.
In the latter case you might try to pass also the pParentWnd to the file dialog.
We have a console application to represent a process plant model. This application has several functions for doing plant calculations. We have defined a structure and a global object for maintaining the data and doing calculations, which is initialized in one of the function. We assign and calculate values for the members of the object by using it in all the corresponding functions.
We have defined a number of functions as shown above which changes the value of each of the members of ETest. Now our requirement is to identify and separate the functions to create a library to abstract it from users of the application.
Now, when I create a static library application and add the files with all the functions, and add the lib in my original application to use the functions, the functions still need to use the same object ETest, which is used in the main application as well. Is there any way to share the structure between the main application and the static library. Can I use the createfilemapping for creating a shared memory to assign values in the main app as well as the static library?
a DLL with it's own copy of the CRT could be using a different version of the CRT than the main app uses. and that will lead to problems if you try to delete/free memory in one place that was allocated in the other.