03.08.2007, 23:20 | #1 |
Участник
|
axaptapedia: Howto insert a menu reference into the MainMenu
Источник: http://www.axaptapedia.com/Howto_ins...o_the_MainMenu
============== Summary: I don't know how to do it via API (if you call AOTAdd it just inserts given menu itself). The only way I've foun is to export the MainMenu to XPO, change it, and import again. Here is example code: static void Edictum_InstallMainMenu(Args _args) { Menu m=new Menu('MainMenu'); TextBuffer b=new TextBuffer(); str tempFile=WinApi::getTempPath()+'tmp_main_menu.xpo'; int toInsert; /// find the last occurence of the string _s int findLast(str _s) { int ret; int pos = 1; while(b.find(_s, pos)) { ret = b.matchPos(); pos = b.matchPos() + b.matchLen(); } return ret; } /// import file by full path void import(str _fileName) { SysImportElements import=new SysImportElements(); boolean examinedFile=false; ; import.newFile(_fileName); import.parmAddToProject( false); import.parmDeleteSubNodes(true); import.parmImportWithIds(false); import.parmOverrideLocks( false); import.parmImportLabels(false); import.parmImportAot(true); import.import(); } ; // export main menu to the file in the temporary directory m.treeNodeExport(tempFile); b.fromFile(tempFile); // finding the last occurence of menu end toInsert = findLast('\n: *ENDMENU\n'); if (toInsert) { // insert reference code b.insert(@' MENUREFERENCE PROPERTIES Name #DOC_Main ENDPROPERTIES ENDMENUREFERENCE ', toInsert); // save the code back to the file b.toFile(tempFile); // import changed xpo import(tempFile); info('ok'); } else info('bad'); } Источник: http://www.axaptapedia.com/Howto_ins...o_the_MainMenu
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|