30.04.2008, 16:05 | #1 |
Участник
|
dax-lessons: Problem when creating a dynamic form with ActiveX control & Solution :)
Источник: http://DAX-Lessons.spaces.live.com/B...FCD1!150.entry
============== The Requirement was to connect to the weband get the content of the web page and display it on the form .Well, I did not want to create aform in AOT to display the HTML content .So , I thought of dynamically creatinga form and adding the browser ActiveX Control using X++ code. Here is the code which I pasted in the job. X++: static void ActiveX_DynamicForm(Args _args) { COMDispFunction webpreviewWrite; COMVariant text = new COMVariant(); COM ctrl = new COM(); Form formBrowse; FormActivexControl activex; FormRun formRun; Args args; int handle; WinInet wi =new WinInet(); str htmlContent; ; handle= wi.internetOpenUrl('http://www.yahoo.com'); if(handle) { htmlContent = wi.internetReadFile(handle); } wi.internetCloseHandle(handle); formBrowse = new Form('ActiveX AX Form', true); formBrowse.design().width(500); formBrowse.design().height(500); formBrowse.design().addControl(FormControlType::ActiveX, 'Browser'); args =new Args(formBrowse.name()); args.name(formBrowse.name()); args.object(formBrowse); formRun = classFactory.formRunClass(args); formRun.init(); activex = formRun.design().controlName('Browser'); activex.className('{8856F961-340A-11D0-A96B-00C04FD705A2}'); activex.height(1,1); activex.width(1,1); formRun.run(); ctrl.attach(activex.interface()); webpreviewWrite = new COMDispFunction(ctrl, 'write',COMDispContext::Method); text.bStr(htmlContent); activex.open(""); webpreviewWrite.call(text); formRun.detach(); } I did not want to create a separate form addingan ActiveX control to achieve this. I looked for alternatives and found one interestingclass which served my purpose. Class Name: KMKnowledgeFunctionShow Method : static Object show(TextBuffer htmlText, Object _formRun = null) The show method will open the standard “KMKnowledgeAnalogMeter”form which has an ActiveX Control added to it. I got the content of the webpage and added itto the TextBuffer by using settext() method and passed the TextBuffer to theshow method. I did not pass the second parameter formrun. The idea behind this is to open the existingStandard form which has already Browser ActiveX in it. Here is the code X++: static void ActiveX_Alternate(Args _args) { str htmlContent; TextBuffer txtBuffer; int handle; WinInet wi = new WinInet(); ; handle= wi.internetOpenUrl('http://www.yahoo.com/'); if(handle) { htmlContent = wi.internetReadFile(handle); } txtBuffer = new TextBuffer(); txtBuffer.setText(htmlContent); KMKnowledgeFunctionShow::show(txtBuffer); } Источник: http://DAX-Lessons.spaces.live.com/B...FCD1!150.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|