How to skip the New Document dialog

-->

There is a simple way how to go round the dialog which appears when your app uses more than one document template and you click the 'new' button. You can open any document directly. Here is a small example of function which opens all documents from your document template at once.

void CMyApp::OnOpenAllTypesOfDocuments()
{
  POSITION pos = GetFirstDocTemplatePosition();
  CDocTemplate* pTemplate = GetNextDocTemplate(pos);
  pTemplate->OpenDocumentFile(NULL);  // creates the first document

  pTemplate = GetNextDocTemplate(pos);
  pTemplate->OpenDocumentFile(NULL);  // creates the second document

  // etc...
}



Comments

  • Very simple way to work around New... and Open...

    Posted by Legacy on 11/20/2003 12:00am

    Originally posted by: Coben Han

    When creating a new doc template, the corresponding
    resource ID should be specified as the first argument
    of a constructor.

    The resource ID needs to be verified in details.
    As the MSDN library specifies, there are three fields
    that are related to the New dialog and Open dialog.

    CDocTemplate::fileNewName
    CDocTemplate::filterName
    CDocTemplate::filterExt

    If we remove all the above three fields when constructing
    the every other resource IDs' string except the default template ID's string, we can make it work!

    Reply
  • Why do you need this?

    Posted by Legacy on 05/19/2000 12:00am

    Originally posted by: Oscar

    On Initinstance On the second third and etc.. template just don't use
    AddDocTemplate(pDocTemplate); use it only on first one.

    Because Doc manager is also deleting the template, then you have to do it by yourself.

    // FIRST ONE has ADDocTemplate
    CSingleDocTemplate* pDocTemplate;
    pDocTemplate = new CSingleDocTemplate(
    IDR_MAINFRAME,
    RUNTIME_CLASS(CUltraCaptureDoc),
    RUNTIME_CLASS(CMainFrame), // main SDI frame window
    RUNTIME_CLASS(CUltraCaptureView));
    AddDocTemplate(pDocTemplate);


    //SECOND template
    m_pInputViewTemplate = new CSingleDocTemplate(
    IDR_MAINFRAME,
    RUNTIME_CLASS(CUltraCaptureDoc),
    RUNTIME_CLASS(CMainFrame), // main SDI frame window
    RUNTIME_CLASS(CSetingsView));
    //***DON"t AddDocTemplate(pDocTemplate2);


    On destructor
    delete m_pInputViewTemplate;

    Reply
  • How to open a specific type of document

    Posted by Legacy on 03/02/1999 12:00am

    Originally posted by: YOGESH


    How to create a new file of specific document type ,if the application is a multidoc app,without the new file open dialog box ?

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

  • Live Event Date: December 18, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this upcoming webcast …

Most Popular Programming Stories

More for Developers

RSS Feeds