AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 30.04.2008, 16:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
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 was successful in creating the form butstrangely AX threw me an error when I ran the code. It was not supporting ‘write’ method for automatic interfaceof COM object of class “IWEBBrowser2’

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);
}
Drawback: The form caption stills remains the“KMKnowledgeAnalogMeter “form caption













Источник: http://DAX-Lessons.spaces.live.com/B...FCD1!150.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
dax-lessons: Graphical Indiactors in AX(Analogmeters) Blog bot DAX Blogs 0 27.08.2007 23:00
dax-lessons: Document Handling in AX - setup and Example Blog bot DAX Blogs 0 27.08.2007 23:00
dax-lessons: Active directory in Axapta Blog bot DAX Blogs 0 27.08.2007 23:00
Axapta Lessons: Trapping keystrokes in a Form Blog bot DAX Blogs 13 01.11.2006 18:16
Говорят вышел SP2 для Axapta 3. Кто нибуть что знает на эту тему? soin DAX: Прочие вопросы 10 13.10.2003 10:43

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 02:25.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.