• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 465
  • Last Modified:

Dynamic Form View Dialog

I am using the SDI Doc/View architecture (for the purposes of writing an OLE server) with my View class inheriting from CFormView.  Does anyone know how I can dynamically decide from multiple dialog resources to use with the initial view that is loaded at runtime?  I.e. depending on the hardware, I may want to use a dialog resource that is small, medium or large etc.

I don't really understand the doc/view architecture well enough to know what is going on... I can see that the default constructor created by AppWizard is CMyView::CMyView() : CFormView(CMyView::IDD) and that it will probably have to be changed to something like CMyView::CMyView(int nID) : CFormView(nID), but I'm not sure where in the doc/view creation process that the view is created so I can insert the ID of the dialog resource in the CMyView constructor.

Anyway, thanks in advance for the help
Garrett Headley
0
headley
Asked:
headley
1 Solution
 
piano_boxerCommented:
A good place to set the dialog resource ID to use would be in the virtual function Create() (NOT WM_CREATE !!!). Override the Create() function of your formview class and modify it as follows:

BOOL CMyFormView::Create(
    LPCTSTR lpszClassName, LPCTSTR lpszWindowName,
    DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
    UINT nID, CCreateContext* pContext)
{
    // Set resource ID to be used
    m_lpszTemplateName = MAKEINTRESOURCE(IDD_MY_DIALOG);

    // Do normal processing
    return CFormView::Create(lpszClassName, lpszWindowName,
        dwStyle, rect, pParentWnd, nID, pContext);
}

---
I will not go into internal MFC doc/view details here, but just suggest that you get a copy of the book 'MFC Internals' by Shepherd, Wingo (ISBN: 0-201-40721-3). This book tells you everything you need to know about MFC.
0
 
headleyAuthor Commented:
Works fine for me!!  

Thanks,
Garrett
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now