Export (0) Print
Expand All
MFC
Expand Minimize

CWinApp::EnableShellOpen 

Call this function, typically from your InitInstance override, to enable your application's users to open data files when they double-click the files from within the Windows File Manager.


void EnableShellOpen( );

Call the RegisterShellFileTypes member function in conjunction with this function, or provide a .REG file with your application for manual registration of document types.

BOOL CMyApp::InitInstance()
{
   // ...

   CMultiDocTemplate* pDocTemplate;
   pDocTemplate = new CMultiDocTemplate(
      IDR_MYTYPE,
      RUNTIME_CLASS(CMyDoc),
      RUNTIME_CLASS(CMDIChildWnd),        // standard MDI child frame
      RUNTIME_CLASS(CMyView));
   AddDocTemplate(pDocTemplate);

   // Create main MDI Frame window.
   CMainFrame* pMainFrame = new CMainFrame;
   if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
      return FALSE;
   // Save the pointer to the main frame window.  This is the
   // only way the framework will have knowledge of what the
   // main frame window is.
   m_pMainWnd = pMainFrame;

   // enable file manager drag/drop and DDE Execute open
   EnableShellOpen();
   RegisterShellFileTypes();
   // ...

   // Show the   main window using the nCmdShow parameter
   // passed to the application when it was first launched.
   pMainFrame->ShowWindow(m_nCmdShow);
   pMainFrame->UpdateWindow();
  
   // ...
}

Community Additions

ADD
Show:
© 2015 Microsoft