15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Documents opening on a double click

Iain Fyfe -- MFC-L@scet.org.uk
Monday, March 24, 1997

Environment:  VC++ 4.0, Windows 95
We have an application that has 14 document types, we want them to
start up the application and open on a double-click on the file icon.
This works fine when the application is running but if the application
is not running it doesn't work. The application is launched then a
dialogue  stating "Can not find the file (or
one of its components)..." is shown.
If you drag the document onto the application icon it opens fine as
well. If you drag the document onto a printer it fails with the same
message.
After investigation with DDESpy we think the DDE message to open the
file is not getting sent to the application. 
We originally created the app using AppWizard with OLE full server
capabilities but have added to it. 
Are we not initialising something properly?
Has anyone had similar problems or any ideas on how to fix this? 


Thanks in advance 

Iain Fyfe
Software developer 
SCET



Regis NICOLAS -- regis.nicolas@smartcode.fr
Wednesday, March 26, 1997

[Mini-digest: 2 responses]

At 09:58 AM 3/24/97 -0000, you wrote:
>Environment:  VC++ 4.0, Windows 95
>We have an application that has 14 document types, we want them to
>start up the application and open on a double-click on the file icon.
>This works fine when the application is running but if the application
>is not running it doesn't work. The application is launched then a
>dialogue  stating "Can not find the file (or
>one of its components)..." is shown.
>If you drag the document onto the application icon it opens fine as
>well. If you drag the document onto a printer it fails with the same
>message.
>After investigation with DDESpy we think the DDE message to open the
>file is not getting sent to the application.=20
>We originally created the app using AppWizard with OLE full server
>capabilities but have added to it.=20
>Are we not initialising something properly?
>Has anyone had similar problems or any ideas on how to fix this?=20
>
>
>Thanks in advance=20
>
>Iain Fyfe
>Software developer=20
>SCET
>
>
Hope this helps,
Regis


void CWinApp::EnableShellOpen( );
 =20
Remarks
Call this function, typically from your InitInstance override, to enable
your application=92s users to open data files when they double-click the
files from within the Windows File Manager. Call the RegisterShellFileTyp=
es
member function in conjunction with this function, or provide a .REG file
with your application for manual registration of document types.
Example
 =20
BOOL CMyApp::InitInstance()
{
   // ...

   CMultiDocTemplate* pDocTemplate;
   pDocTemplate =3D 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 =3D 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 =3D 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();
 =20
 =20

   // ...
}


------------------------------
Regis NICOLAS -    R&D Windows
Smartcode Technologie

mailto:nicolas@smartcode.fr
http://www.smartcode.fr/
http://www.smartcodesoft.com/
Tel.: (33) (0)4 67 59 30 16

-----From: i.fyfe@scet.org.uk (Iain Fyfe)

regis.nicolas@smartcode.fr,Internet writes:
>void CWinApp::EnableShellOpen( );
>  
>Remarks
>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. Call the
>RegisterShellFileTypes
>member function in conjunction with this function, or provide a .REG
>file
>with your application for manual registration of document types.
>Example
>  
>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();
>  
>  

>   // ...
>}

Thanks for your reply. But we already tryed this and it didn't work. We
have now got round the problem by not using DDE atall and puting %1 in
the command registry entry and deleting the ddeexec item then parsing
the filename ourselves. This seems to work on all the machines now.


Iain Fyfe
Software developer 
SCET




Become an MFC-L member | Вернуться в корень Архива |