From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

File Menu Entry Point from VC

Hi,

 

I am trying to execute a File Menu entrypoint from VC++ code.

can anyone please suggest how to do the same.

I have used below piece of code in my project to execyte the entrypoint.

Here, "Select Model" is one of the File menu item from my process model.

i wanted to execute "Select Model" menu item from VC++ code. but the below piece of code is executing operation failed message

I have doubt at my seqFile ptr. can you please suggest how to give process model seq file reference to seqFile ptr here.

{

        ExecutionPtr            newExecution = NULL;
        TS::SequenceFilePtr        seqFile =GetSequenceFile()    ;
        TS::SequenceFilePtr        processModel =     NULL;
        TS::EditArgsPtr            editArgs = NULL;
        TS::EditArgsPtr            seqArgs = NULL;
        _bstr_t                    entryPointName ="Select Model";
        
        TS::IEnginePtr engine = mApplicationMgr->GetEngine();
        processModel = engine->GetStationModelSequenceFile(NULL);
        editArgs = engine->NewEditArgs();
        editArgs->SetSelectedSequenceFile(seqFile);
        TS::PropertyObjectPtr container = engine->NewPropertyObject(PropValType_Container, FALSE, "", 0);
        container->SetValString("sequence", 0x1, "MainSequence");

        _variant_t vtEditArguments((LPDISPATCH)editArgs, TRUE);
        _variant_t vtSeqArguments((LPDISPATCH)container, TRUE);
               
        newExecution = engine->NewExecution(seqFile, entryPointName, processModel, 0,
                                            TS::ExecTypeMask_InitiallyHidden, vtSeqArguments, vtEditArguments, vtMissing);
        
        engine = NULL;

}

SequenceFilePtr CTestExecDlg::GetSequenceFile(void)
{
    RuntimeTrace(" TRACE---------CTestExecDlg::GetSequenceFile(void)        \n");//trace
    return mFile;
}

 

0 Kudos
Message 1 of 2
(3,081 Views)

I'm assuming you have a process model configuration entry point placed in the File menu via a menu hint and that it works fine from the File menu. If so, the following code will execute it:

 

    long numInserted;
    TSUI::CommandsPtr commands = mApplicationMgr->NewCommands();
    commands->InsertKind(CommandKind_ConfigurationEntryPoints_Set, mSequenceFileViewMgr, -1, "File", "File, Edit, Execute, Debug, Configure, Tools, Help", &numInserted);
    commands->GetItem(0)->Execute(VARIANT_TRUE);

0 Kudos
Message 2 of 2
(3,005 Views)