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


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-05-06, 02:55 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】how to invoke a custom command

how to invoke a custom command
how to invoke a custom command
hello!
i would like to invoke a custom command from a dialog button.
following the example in drx sdk i try:
void cmydialog:nbnclickedbutton1()
{
// todo: add your control notification handler code here
// create the command context with an odedbaseio subclass, and an oddbdatabase.
oddbcommandcontextptr pcmdctx = oddbcommandcontext::createobject(pmyodedbaseio, pdatabase);
// retrieve the global command stack.
odedcommandstackptr pcommands = :: odedregcmds();
// execute the registered command with the global name "customcommand"
pcommands->executecommand("customcommand", pcmdctx);
}
questions:
1.how can i create the two pointers (pmyodedbaseio, pdatabase) which are arguments for oddbcommandcontext::createobject(..) function?
2.which header files i have to include and how this pointer declarations look like?
regards!
ioan
hi,
please see how to implement odedbaseio in the following example sources:
examples/win/odamfcapp/userioconsole.h|.cpp
extensions/exservices/exstringio.h|.cpp,
examples/win/odamfcapp/dwgviewer.h|.cpp
and how to use it in:
examples/win/odamfcapp/odamfcappdoc.cpp: codamfcappdoc::executecommand().
thank you for your answer dmitri, but i use only drxsdk_2.03 and drxsdk_2.04.. in these sdk there is no sources like you indicate:
examples/win/odamfcapp/userioconsole.h|.cpp
extensions/exservices/exstringio.h|.cpp,
examples/win/odamfcapp/dwgviewer.h|.cpp
examples/win/odamfcapp/odamfcappdoc.cpp....
it is possible to indicate some location or to attach these files?
kind regards!
ioan
do you want to override (implement your own) input inside from your dialog or just initiate regular user interaction via standard gui ?
p.s. to use cuserioconsole you need to declare appropriate dialog resource (idd_console_dlg) with 2 edit boxes (idc_prompt,idc_input):
attached files (2.9 kb, 8 views)
(1.4 kb, 7 views)

thank you for your extremely fast answer!!!
i just want to call a custom command not in a classic way, but when a user push a button in a cdialog ..
btw, it is possible to compile drxsdk_2.04 to support mfc user interface class like cdialog.. i can not do this, becose when i insert a cdialog resource, in drxsdk_2.04\projectfiles\win32\msvc6\examples\excu stobjs - sdk example, the excustobjs.rc is altered. after i try to remediate the resource file other errors appear and everything collapse..
i will try your example!
thank you again! ... very fast!!
ioan
i try to include the previous files attached in my project. everything works fine, but i got a compiler message error
e:\visual studio projects\visual studio projects\test_dll5\exstringio.h(55): error c2504: 'odedbaseio' : base class undefined..
i search and include all header files needed for odedbaseio like dbuserio.h, ed/eduserio.h, rxobject.h, and so on.. i got the same error message..
it is possible to attach the entire project, or to indicate some possible solution to avoid the error above?
kind regards!
ioan
forget that i suggested. it's wrong.
>>i just want to call a custom command not in a classic way, but when a user push a button in a cdialog ..
do you want to override response to command prompts or not ?
if not then you should find appropriate function in host application's api that sends command to execution.
1. when i said "a classic way" i was thinking to the usual mechanism which i have founded in drxsdk_2.04. what i ask is to invoke a custom function from a common mfc dialog derived from cdialog, not to override response to command prompts .
2. i try to find some documentation if i can work with cdialog directly from drx medium... unfortunately i can't find it. there is no reference to mfc resources (toolbars, dialogs, etc.) in drxsdk_2.04
3. host application work with his own command mechanism (derivated anyway from drx/oda library) or directly with drx mechanism. the results are the same..no difference.. host application can import drx application with no problem. all i try to find is a method to invoke from drx api a custom function, declared exactly like in excustobjs sdk example (_excreatesphere_func for example..), but when a user click a mouse button from a cdialog, not when it writes the command at the command prompt.
kind regards!
ioan
>>but when a user click a mouse button from a cdialog, not when it writes the command at the command prompt.
but then excreatesphere will prompt for the center and radius, how you assume user should enter them via standard host application api or via your dialog ?
for the 1st case you must obtain command context pointer from host app, and for the 2nd - you should implement your own context derived from oddbcommandcontext.
dmitry, in my host application, this cdialog from which the command is invoked is modelles.... after i push the button to create the sphere, (and this is a perfect example) i can access the host command line without no problem. all parameters for excreatesphere are introduced from the host command line, of course. like in a normal (or "classic") function invoke mechanism!
all the problem i have in this moment is that i can not create a valid odedcommandcontext* pcmdctx argument function for
void _excreatesphere_func(odedcommandcontext* pcmdctx)
i do not know how to do this. i really do not know which one is this pcmdctx (context pointer from host app , or own context derived from oddbcommandcontext)
all is working perfect but after the debugger enter in _excreatesphere_func core function (just to test the command mecanism), the program stops becose i'm not able to to indicate a value for pcmdctx, i just put a null pointer value..
i'm new to drx, sorry if i put stupid questions..
kind regards!
ioan
last edited by bioan; 9th august 2007 at 10:41 amfff">.
so you have to obtain this pointer from host application. try to find function in its api that returns (smart) pointer to odedcommandcontext or oddbcommandcontext (most likely it's a method of its document object). ask developers of host app how to obtain it if you will not find.
or maybe you just need to call an another host application's function that sends a command to execution (one in host application should not require command context parameter as it implements it).
now it's very clear!
just one more question: it is possible to work directly from drx api with cdialog? if it is possible, i can ignore all the host link, working exclusively with drx, becose of the native compatibility..
as i already say, i have tried but i can not do this, becose when i insert a cdialog resource, in drxsdk_2.04\projectfiles\win32\msvc6\examples\excu stobjs - sdk example, the excustobjs.rc is altered. after i try to remediate the resource file other errors appear and everything collapse..
if this possibility exist, can be attached a skeleton mfc project?
thank you very much for your time ! best wishes!
ioan
well, dwgdirect itself does not restrict using mfc but a host application could i guess.
general rules should be the same as using mfc inside from regular dlls.
i think, you can completely replace excustobjs.rc with your own version.
drx applications like arx applications in autocad are plug-ins implementing custom objects/entities and custom commands.
a custom command can be called from container application not only via command line but from menu or toolbar button. but in any case from drx side it looks like a command was activated.
if you implement a command even using mfc dialogs etc. and need to call subcommand you can pass to subcommand the same context you received at the moment the outer command was called.
also note that using application specific api will make your drx application non-portable - it will not work with other dwgdirect based applications.
sergey slezkin
thinking about the last two post (from dmitry and sergey) – especially at portability problem (thank you sergey – you are right), it seems even more logic from a drx developer point of view, to derive , construct and to work directly an only with mfc resources like my cdialog implemented from drx_sdk side .. as i said three times before i can not implement a specific command, like excreatemydrxdialog() as “the outer command” and to invoke _excreatesphere_func as a subcommand, pushing a button from mydialog above .. try it for yourself, i lost two days, without success, to create a cdialog directly in latest drx sdk:
operation system : windows xp professional (32 and 64 bits)
drxsdk version: 2.04
visual c++ version: visual studio .net 2003 service pack 1 (v 7.1)
first time i've got a resource error, second time an include error, and so on..
at last, after i've included and resolved all these incredible and difficult project structure (btw i have to admit that i do not understand the project example files structure)
of files in drxsdk_2.04\projectfiles\win32\msvc2003\examples\e xcustobjs example, i've got some deadly 3 link errors....
if someone can create a mfc dialog and invoke an existing function defined in project from some dialog button , please give me a sign!
kind regards!
ioan
last edited by bioan; 10th august 2007 at 01:19 pmfff">.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】custom objects yang686526 DirectDWG 0 2009-05-04 06:56 PM
【转帖】求那位高手来翻译下,行不! yang686526 数据库ObjectDBX 0 2009-04-28 03:13 PM
自动扶梯安装图自动绘制原程序 yang686526 ObjectARX(AutoLISP) 0 2009-04-27 11:59 AM
求那位高手来翻译下,行不! yang686526 ObjectARX(AutoLISP) 0 2009-04-27 10:45 AM
【转帖】custom properties yang686526 SolidWorks二次开发 0 2009-04-13 10:09 AM


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


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多