// MDI Activate Event Handler

  Requires(20161103);

  Assign("MDI-Locked","1");
  // ============================================================
  // Use this test to exit a custom handler in case another one
  // has been triggered (eg. before doing something time-consuming
  // like updating the menu)...
  ProcessMessages;
  // Another MDI Activate Event has been triggered?
  IfNum("%$('MDI-Locked');","0","=","Exit;");
  // ============================================================

  PushTagsandRegisters;

  // Select the right branch in the Options Interface
  SelectOptionsNode("%f",1,0);

  // Find all glossaries in TeX mode
  IfisMode('TeX','%!M',>
    !'Exe("%b\Exec\TeX\FindGlossaries.edt");',>
    !'Release("File-glo");');

  // Find the installer in NSIS mode
  IfisMode('NSIS','%!M',>
    !'Exe("%b\Exec\NSIS\NSISOutFile.edt");',>
    !'Release("NSIS-Installer");Release("NSIS-Source");');

//   // Treat current document as the main file
//   IfisMode(!'Main','%!m',!'Relax;',!'JMP(!"Reset");');
//
//   SetMainFile("%f");
//   JMP(!"Done");
//
// :Reset:: ========================================================
//
//   // Restore the main file (if previously set)
//   IfStr('%$(!"MAIN_FILE");',!'?',!'<>',>
//     !'SetMainFile(|%$(!"MAIN_FILE");|);');
//
// :Done:: =========================================================

  Relax; // OK

  PopTagsandRegisters;
  Assign("MDI-Locked","0");

End;
