Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
ImanExt.OpenCmd and Delphi 6
mawny
I am having trouble implementing the ImanExt.OpenCmd from a Delphi application. I have used this command effortlessly and without problem in VB6.
I have the feeling the problem may lie in the contextitem 'SelectedNrtDocuments' and the way Delphi handles safe variant arrays.
The status of the command when I update it is always nrGrayedCommand as opposed to the expected nrActiveCommand.
My version of delphi is 6 ( Build 6.240)
Here is my function any pointers of where i might be going wrong ? Any delphi users managed to succesfully use this command?
procedure TForm1.OpenDmsDoc(pDoc : INRTDocument);
var pContextItems : IContextItems;
pSelectedDocs : oleVariant;
myOpenCmd : OpenCmd;
begin
pSelectedDocs := VarArrayCreate([0, 0], varVariant );
pSelectedDocs[0] := pDoc;
pContextItems := CreateComObject(CLASS_ContextItems) as IContextItems;
pContextItems.Add( 'ParentWindow', Application.Handle);
pContextItems.Add ('SelectedNRTDocuments',pSelectedDocs);
myOpenCmd := CreateComObject(CLASS_OpenCmd) as OpenCmd;
myOpenCmd.Initialize(pContextItems);
myOpenCmd.Update;
if myOpenCmd.status = nrActiveCommand then
myOpenCmd.execute;
end;
Find more posts tagged with
Comments
jny
Try this:
pSelectedDocs := varArrayCreate([1,1], varDispatch);
pSelectedDocs[1] := pDoc;
pContextItems.Add('SelectedNRTDocuments', pSelectedDocs);
Hope this helps.
mawny
Thanks
That works beautifully
Much obliged.
neilm
I am having a similar problem from C# and the search dialog. The body of the procedure of the windows forms application is given below:
<SNIP >
ContextItems contextItems = new ContextItemsClass();
NRTSearchParameters searchParameters;
IManDocuments documents;
IManSession[] sessions;
Int32 hWnd = this.Handle.ToInt32();
sessions = new IManSession[1];
sessions[0] = isession;
contextItems.Add("ParentWindow", hWnd);
contextItems.Add("SelectedNRTSessions", sessions);
contextItems.Add("NRTDMS", idms);
SearchCmd searchDlg = new SearchCmdClass();
searchDlg.Initialize(contextItems);
searchDlg.Update();
MessageBox.Show(searchDlg.Status.ToString() ); /* Always 1 */
//If command is active, then it can be executed
if ( true /* condition removed for debugging - */ )
{
searchDlg.Execute();
/* Generates the following error:
IManExt: Unable to obtain server information. This server might be unavailable.
IManExt
The parameter is incorrect. */
//Get return value
documents = (IManDocuments) contextItems.Item("SearchedNRTDocuments");
searchParameters = (NRTSearchParameters) contextItems.Item("SearchParameters");
//When finished using the ContextItems,
//remove them from the collection.
contextItems.Remove("SearchedNRTDocuments");
contextItems.Remove("SearchParameters");
}
<SNIP>
As with the earlier post I suspect the safe array context item and my lack of interop knowledge.
Just for info: an almost identical procedure which calls the Import dialog which does not require any array context items works fine so I am confident that the session is correctly established.
If anyone can make any suggestions I'd appreciate it.
Thanks in advance
Neil McLaughlin
Weiqun
Try to change the following code from IManSession[] to NRTSession[], and the rest of code should work fine. The reason is the SearchCmd is expecting an IDispatch interface array, which is not available yet for IManSession in 8.0.
NRTSession[] sessions;
NRTSession nrtSession = (NRTSession)isession;
...
sessions = new NRTSession[1];
sessions[0] = nrtSession;
...
Thanks,
Weiqun
neilm
Thanks for the suggestion - I had come to the same conclusion myself by experimantation after getting the VB example from the documentation to work in VB.NET then porting it to C#.
I didn't understand what the actual reason for the discrepancy was however.
Thanks again
Neil