Menu

FormView from DLL

Help
Erik Don
2021-01-18
2021-01-20
  • Erik Don

    Erik Don - 2021-01-18

    Hi, All
    Based on demo: Splitter I want add a Formview into the CTab, the Formview from a DLL.
    From DLL sample, it has a exported function named "ShowDialog" can make dialog popup, but CTab::AddTabPage(...) will handle all creation. How can I implement my idea? Or can you share your idea?

     

    Last edit: Erik Don 2021-01-18
  • Erik Don

    Erik Don - 2021-01-20

    Hello All,

    I think I have not descript my idea clearly:
    I want the DLL can exports a FormView to exe's CTab. that means the CTab may use AddtabPage or other functions to add a FormView page inside it.
    Because I saw some code in CTab:

    inline void CTab::ShowActiveView(CWnd* pView)
        {
            if (pView != m_pActiveView)
            {
                // Hide the old view
                if (GetActiveView() && (GetActiveView()->IsWindow()))
                    GetActiveView()->ShowWindow(SW_HIDE);
                // Assign the view window
                m_pActiveView = pView;
                if (m_pActiveView && *this)
                {
                    if (!m_pActiveView->IsWindow())
                    {
                        // The tab control is already created, so create the new view too
                        GetActiveView()->Create( GetParent() );
                    }
    
                    // Position the View over the tab control's display area
                    CRect rc = GetClientRect();
                    AdjustRect(FALSE, &rc);
                    MapWindowPoints(GetParent(), rc);
                    GetActiveView()->SetWindowPos(0, rc, SWP_SHOWWINDOW);
                    GetActiveView()->SetFocus();
                }
            }
        }
    

    The code above uses a lot of functions belong to view. That means I have to export the head of the view class? This makes me hard to rollout this idea to plugin like DLL and assign different SW parts to my partners. My original idea is to define a interface , and partners will inherit to implement different functions, these functions will have FormView to shown in exe's CTab.
    If you have any idea , would you please help share ?

     

    Last edit: Erik Don 2021-01-20
  • David

    David - 2021-01-20

    Hi Erik,

    I'm not sure that separate DLLs is the way to go here.

    CTab calls the virtual Create(HWND parent) function to create the view window for the tabs. I suppose you could have a DLL that exports a function that creates a view window (or dialog). The class for your view window could override Create and call the function exported by the DLL. You might also need to export other functions to interact with the view.

    Best regards,
    David

     

Log in to post a comment.