Solved

Dynamic Form View Dialog

Posted on 1998-05-11
2
412 Views
Last Modified: 2013-11-20
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
Comment
Question by:headley
2 Comments
 
LVL 4

Accepted Solution

by:
piano_boxer earned 100 total points
ID: 1309641
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
 

Author Comment

by:headley
ID: 1309642
Works fine for me!!  

Thanks,
Garrett
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Named range not carried over 10 62
changeXy challenge 13 67
mapAB Challlenge 35 127
JQuery serialize and unserialize 8 51
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now