Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Disabling ShellOpen???

Posted on 1998-02-04
5
Medium Priority
?
213 Views
Last Modified: 2013-11-19
My MFC application accepts opening registered files by double-clicking on them. I need this behaviour, except when a flag is set (bNotAccept=TRUE). In this case no external DDE event should interfere with program execution. How can I handle this?
0
Comment
Question by:winmeister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1315545
In your Application::InitInstance() function, there's a section of code that looks like

      // Parse command line for standard shell commands, DDE, file open
      CCommandLineInfo cmdInfo;
      ParseCommandLine(cmdInfo);

      // Dispatch commands specified on the command line
      if (!ProcessShellCommand(cmdInfo))
            return FALSE;

This is the part that parses the DDE interface. If you replace it with

      int oldShellCommand = cmdInfo.m_nShellCommand;

      if (oldShellCommand == CCommandLineInfo::FileOpen && bNotAccept)
            cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;

      // Dispatch commands specified on the command line
      if (!ProcessShellCommand(cmdInfo))
            return FALSE;

Then that should do what you want.
0
 
LVL 1

Author Comment

by:winmeister
ID: 1315546
Thui,
your code is executed only during InitIntance. I need to change the behaviour during program execution: at certain point, if the flag goes up, the program should reject all DDE processing.
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1315547
You should then terminate all DDE conversations. There isn't anything in MFC that I know of that automatically responds to DDE commands for you. You need to change your existing DDE code.
0
 
LVL 1

Author Comment

by:winmeister
ID: 1315548
Actually I don't know which is my  "existing DDE code". I just have an EnableShellOpen() command in InitInstance, before file type registration.
0
 
LVL 23

Accepted Solution

by:
chensu earned 400 total points
ID: 1315549
There are three ways you may try (I haven't done it).

1. Override the CWinApp::OnDDECommand() function to see what the lpszCommand is when you want to disable it.

2. Call the CWinApp::UnregisterShellFileTypes() function although it is undocumented, enable  it again by calling the CWinApp::RegisterShellFileTypes() function.

3. Do the following code when you need to disable it, enable it again by calling the CWinApp::EnableShellOpen() function.

    ::GlobalDeleteAtom(m_atomApp);
    ::GlobalDeleteAtom(m_atomSystemTopic);
    m_atomApp = NULL;
    m_atomSystemTopic = NULL;

For your information, the following is the relevant MFC source code from appui2.cpp.

void CWinApp::EnableShellOpen()
{
      ASSERT(m_atomApp == NULL && m_atomSystemTopic == NULL); // do once

      m_atomApp = ::GlobalAddAtom(m_pszExeName);
      m_atomSystemTopic = ::GlobalAddAtom(szSystemTopic);
}

void CWinApp::RegisterShellFileTypes(BOOL bCompat)
{
      ASSERT(m_pDocManager != NULL);
      m_pDocManager->RegisterShellFileTypes(bCompat);
}

void CWinApp::RegisterShellFileTypesCompat()
{
      ASSERT(m_pDocManager != NULL);
      m_pDocManager->RegisterShellFileTypes(TRUE);
}

void CWinApp::UnregisterShellFileTypes()
{
      ASSERT(m_pDocManager != NULL);
      m_pDocManager->UnregisterShellFileTypes();
}

0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

704 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