Friday, July 3, 2015

ActiveX in Axapta

The Microsoft Axapta Object Server supports Microsoft’s COM (Common Object Model), DCOM (Distributed Common Object Model) and ActiveX controls. This enables Microsoft Axapta to use the advanced flexible COM technology either directly or indirectly using third party applications.
 
In AX, each ActiveX control will be having a classId. This entry will exaplain you how to use html document ActiveX control in Axapta.
 
How to add ActiveX control to your form 
  • create form by Name MyActiveXExample
  • MyActiveXExample– > design – > New control -> ActiveX
  • Select html document ActiveX control from the list of activex’s displayed by Ax and name the newActiveX control as HtmlActiveX.
  • Make the Autodeclaration property of the newly created ActiveX control to Yes
  • After that , if you want to display html content in that Activex Control,
  • Add the below code in the init() method of your MyActiveXExample form

public void init()
{
str htmlSource;
COMDispFunction webpreviewWrite;
COMVariant text = new COMVariant();
COM ctrl = new COM();
;

super();
htmlSource = @’ <html><pre><hr color="#99CCFF">
<center>
Search in Google
<FORM method=GET action="
http://www.google.com/search">
<TABLE bgcolor="#FFFFFF"><tr><td>
<A HREF="
http://www.google.com/">
<IMG SRC="
http://www.google.com/logos/Logo_40wht.gif" <br></A>
<INPUT TYPE=text name=q size=31 maxlength=255 value="">
<INPUT TYPE=hidden name=hl value="en">
<INPUT type=submit name=btnG VALUE="Google Search">
</td></tr></TABLE>
</FORM>
</center></pre>
<hr color="#99CCFF"></html>';

ctrl.attach(HtmlActiveX.interface());
webpreviewWrite = new COMDispFunction(ctrl, ‘write’, COMDispContext::METHOD);
text.bStr(htmlSource);
HtmlActiveX.open("");
webpreviewWrite.call(text);

HtmlActiveX.close();
}

No comments:

Post a Comment