c# 显示进度条的原代码
www.dimcax.com
c# 显示进度条的原代码
using autodesk.autocad.runtime; using system.runtime.interopservices; using system.windows.forms; namespace progressmetertest { public class cmds { [dllimport( "acad.exe", charset = charset.auto, callingconvention = callingconvention.cdecl, entrypoint = "?acedsetstatusbarprogressmeter@@yahpb_whh@z" //this should work for autocad private static extern int acedsetstatusbarprogressmeter( string label, int minpos, int maxpos ); [dllimport( "acad.exe", charset = charset.auto, callingconvention = callingconvention.cdecl, entrypoint = "?acedsetstatusbarprogressmeterpos@@yahh@z" )] private static extern int acedsetstatusbarprogressmeterpos(int pos); [dllimport( "acad.exe", charset = charset.auto, callingconvention = callingconvention.cdecl, entrypoint = "?acedrestorestatusbar@@yaxxz" )] private static extern int acedrestorestatusbar(); [commandmethod("pb")] public void progressbar() { acedsetstatusbarprogressmeter("testing progress bar", 0, 100); for (int i = 0; i <= 100; i++) { for (int j = 0; j <= 10; j++) { system.threading.thread.sleep(1); acedsetstatusbarprogressmeterpos(i); // this allows autocad to repaint application.doevents(); } } acedrestorestatusbar(); } } }
dllimport( "acad.exe", charset = charset.auto, callingconvention = callingconvention.cdecl, entrypoint = "?acedsetstatusbarprogressmeterpos@@yahh@z" 这一句 什么意思是调用 dll 文件吗? 知道的告诉我
从老外论坛上摘的吧?dllimport肯定是调用dll了,关键是调用哪个dll,entrypoint又是什么,只有天知道,也不知道老外是怎么知道的了。
...........
entrypoint 是dll中被调用的函数名称。
07以上的版本不需要这么麻烦的,程序如下: using autodesk.autocad.runtime; using system.runtime.interopservices; using system.windows.forms; namespace progressmetertest { public class cmds { [commandmethod("pb")] public void progressbarmanaged() { progressmeter pm = new progressmeter(); pm.start("testing progress bar"); pm.setlimit(100); // now our lengthy operation for (int i = 0; i <= 100; i++) { system.threading.thread.sleep(5); // increment progress meter... pm.meterprogress(); // this allows autocad to repaint application.doevents(); } pm.stop(); } } }
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。
原帖由 月儿 于 dllimport( "acad.exe", charset = charset.auto, callingconvention = callingconvention.cdecl, entrypoint = "?acedsetstatusbarprogressmeterpos@@yahh@z" 这一句 什么意思 ...
这个很复杂的,你的程序是老外的blog上看到的吧,他的blog上有这方面的内容介绍,你以p/invoke关键字查询就能查到有关的文章了。
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。
才鸟:您的那段,当i的值比较大时,特别慢,把system.threading.thread.sleep(5);调到循环体的外部比较好。