Skip navigation
Currently Being Moderated

Prevent document close event/command

Jul 26, 2012 9:27 PM

Hi All,

 

I am trying to prevent document close event by using command interceptor mechanism but could not get succeed and document gets closed from layout window,

Is there exist a way so that document remains opened in layout window.?

I did followings

ICommandInterceptor::InterceptResult EDCmdInterceptor::InterceptProcessCommand(ICommand *cmd)

{

    InterceptResult result = kCmdNotHandled;

    do

    {

        ClassID classID = GetClass(cmd);

 

        if(classID == kCloseDocCmdBoss)

        {

            result = kCmdHandled;

        }

 

    } while (false);

    return result;

}

 

ICommandInterceptor::InterceptResult EDCmdInterceptor::InterceptScheduleCommand(ICommand *cmd)

{

    InterceptResult result = kCmdNotHandled;

    do

    {

        ClassID classID = GetClass(cmd);

        ICommand::CommandState state;

 

        if(classID == kCloseDocCmdBoss)

        {

            result = kCmdHandled;

        }

    } while (false);

    return result;

}

 

ICommandInterceptor::InterceptResult EDCmdInterceptor::InterceptExecuteImmediate(ICommand *cmd)

{

    InterceptResult result = kCmdNotHandled;

    do

    {

        ClassID classID = GetClass(cmd);

 

        if(classID == kCloseDocCmdBoss)

        {

            result = kCmdHandled;       

        }

 

    } while (false);

    return result;

}

 

ICommandInterceptor::InterceptResult EDCmdInterceptor::InterceptExecuteDynamic(ICommand *cmd)

{

    InterceptResult result = kCmdNotHandled;

    do

    {

        ClassID classID = GetClass(cmd);

 

        if(classID == kCloseDocCmdBoss)

        {

            result = kCmdHandled;

        }       

    } while (false);

    return result;

}

 
Replies
  • Currently Being Moderated
    Jul 31, 2012 2:04 AM   in reply to alam_84

    Instead of intercepting the kCloseDocCmdBoss, try to intercept the kClosePresentationCmdBoss.

    As when you close the layout window of the document the kClosePresentationCmdBoss is processed before scheduling of the kCloseDocCmdBoss.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 31, 2012 1:56 PM   in reply to alam_84

    Interfering with commands should be only used as last resort, there are many locations where the InDesign developers just assume commands always go through.

     

    Use forum search "IDocFileHandler" for an alternative.

     

    Dirk

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points