Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How touse OpenDocumentFile from MFC-dll?

How touse OpenDocumentFile from MFC-dll?

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PrafullaShirke27
    wrote on last edited by
    #1

    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 .

    CPalliniC 1 Reply Last reply
    0
    • P PrafullaShirke27

      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 .

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      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]

      In testa che avete, signor di Ceprano?

      P 1 Reply Last reply
      0
      • CPalliniC CPallini

        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]

        P Offline
        P Offline
        PrafullaShirke27
        wrote on last edited by
        #3

        .

        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;
        }

        C 1 Reply Last reply
        0
        • P PrafullaShirke27

          .

          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;
          }

          C Offline
          C Offline
          Covean
          wrote on last edited by
          #4

          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

          P 1 Reply Last reply
          0
          • C Covean

            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

            P Offline
            P Offline
            PrafullaShirke27
            wrote on last edited by
            #5

            This call is not from MainThread.

            C 1 Reply Last reply
            0
            • P PrafullaShirke27

              This call is not from MainThread.

              C Offline
              C Offline
              Covean
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups