How touse OpenDocumentFile from MFC-dll?
-
I want to open a document from the MFC dll. I am using the below function.
AfxGetApp()->OpenDocumentFile(szlstfile.GetBuffer(0));
; It is giving the assert message But its neither opening the File main application . szlstfile is the CString object holding the path of filename. Anybody has idea how to open a Document from any MFC dll .
-
I want to open a document from the MFC dll. I am using the below function.
AfxGetApp()->OpenDocumentFile(szlstfile.GetBuffer(0));
; It is giving the assert message But its neither opening the File main application . szlstfile is the CString object holding the path of filename. Anybody has idea how to open a Document from any MFC dll .
PrafullaShirke27 wrote:
It is giving the assert message
What says the 'assert message'? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
PrafullaShirke27 wrote:
It is giving the assert message
What says the 'assert message'? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles].
BOOL CMDIChildWnd::Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect, CMDIFrameWnd* pParentWnd,
CCreateContext* pContext)
{
if (pParentWnd == NULL)
{
CWinThread *pThread = AfxGetThread();
ASSERT(pThread);
CWnd* pMainWnd = pThread->m_pMainWnd;
ASSERT(pMainWnd != NULL);//I am getting Assert at this position.
ASSERT_KINDOF(CMDIFrameWnd, pMainWnd);
pParentWnd = (CMDIFrameWnd*)pMainWnd;
} -
.
BOOL CMDIChildWnd::Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect, CMDIFrameWnd* pParentWnd,
CCreateContext* pContext)
{
if (pParentWnd == NULL)
{
CWinThread *pThread = AfxGetThread();
ASSERT(pThread);
CWnd* pMainWnd = pThread->m_pMainWnd;
ASSERT(pMainWnd != NULL);//I am getting Assert at this position.
ASSERT_KINDOF(CMDIFrameWnd, pMainWnd);
pParentWnd = (CMDIFrameWnd*)pMainWnd;
} -
This assert just says that the thread, where you called the function OpenDoc..., has no main wnd. Is this a multi threaded app or is this your main thread?
Greetings Covean
This call is not from MainThread.
-
This call is not from MainThread.
Thats exactly your problem. The easiest way to solve this problem is, that you only call gui functions from within your thread that created the gui. In general calling gui functions from within a thread that didn't created the gui is not a good practice and often causes such problems. The are ways to do this, but its too long ago, that I developed C++. Maybe somebody can you explain how to do such calls.
Greetings Covean