Tuesday, January 31, 2012

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();
}
 The above code will allow use to browse through google without opening the web page , becasue i added the html controls and the functionalites to the controls to search in google.

I have mapped the htmlActiveX control to my Com object and i am writing the html string to the comVariant. Open ActiveX control by .open() method.  Finally i am calling my comdispFunction object i.e webpreviewWrite.call(text) to open the content in the Activex. Then i closed my ActiveX control by using .close() method

No comments:

Post a Comment

Enable UAT database over OneBox DevTest environment using JIT

 Dear Friends, In this Article I will show you how to enable UAT database access for Development machine using just-in-time (JIT). Many time...