几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   ObjectARX(C++) (http://www.dimcax.com/hust/forumdisplay.php?f=34)
-   -   【转帖】objectarx&dummies习题(二)—— using a mfc dialog (http://www.dimcax.com/hust/showthread.php?t=6310)

yang686526 2009-04-16 10:34 AM

【转帖】objectarx&dummies习题(二)—— using a mfc dialog
 
objectarx&dummies习题(二)—— using a mfc dialog
objectarx&dummies习题(二)—— using a mfc dialog
lab 2 - using a mfc dialog
hello,
our second lab will cover mfc contents and some interaction with autocad. the main idea is to keep this lab simple to consolidate mfc and user interaction knowledge.
requirements:
* class 1 to 10;
* autocad 4/5/6 or compatible vertical installed;
* visual studio .net 2 installed;
* objectarx wizard installed.
objectives:
create a simple objectarx module with 1 commands: dlgcolor. this command will create a simple mfc dialog with a color combo box and one selection button. as the user clicks on this button it will prompt user to select one or more existing entities. after click apply it will change the color of all selected entity.
instructions:
- create a project called arxlab2 using objectarx wizard;
- enable using mfc option with autocad mfc extensions;
- click on the a> icon at arxwizard's toolbar to open command dialog;
- right click on the above portion and select new;
- change the global an local name for dlgcolor and select modal as command mode;
- open the visual studio editor and add a new dialog layout. add a combo box control and a button control;
- open the autodesk class explorer, right click on the root and select add mfc ext. class. select cacuidialog as the base class;
- in the dialog layout, right click on the combo box and select add variable. choose cacuitruecolorcombobox as its class and name it as m_color. right click on the combo again and select properties. set has strings = true, owner draw = fixed;
- now, right click the button and select add variable. choose cacuiselectbutton as its class and name it as m_select. right click once more, select properties. set owner draw = true.
- add the virtual bool oninitdialog() method. inside its implementation add the following:
cacuidialog::oninitdialog();
setwindowtext("objectarx for dummies - lab 2");
m_select.autoload();
return true;
- map a click event to selection button. right click on it, select add event handler. select bn_clicked event. inside the event function, we will need to hide the dialog and switch to autocad screen. as we have derived from cacuidialog it already has a couple of functions to do that. so we will need to hide the dialog, select the desired entities and then show the dialog back. your function outline will be something like this:
begineditorcommand();
// perform here the user interaction (allow user to select entities)
completeeditorcommand();
- don't forget to switch the resources to your application before open the dialog:
cacmoduleresourceoverride res;
cdlgcolor dlg;
dlg.domodal();
tips:
- don't forget to call close() for all selected entities (use a transaction if you prefer);
- explore the code to understand what arx wizard has created for you;
- pay attention to code syntax;
- use the objectarx documentation when necessary;
support:
if you have any questions please post your issue on this article to share with others.
expected time:
- i will give you 3 days to accomplish this lab;
- after this period, i will post my suggested solution for this.


所有的时间均为北京时间。 现在的时间是 06:47 AM.