NX二次开发BlockUI删除对话框框架设置的撤销标记

在BlockUI中,往往希望点击关闭或取消后创建的操作不会撤销,通过执行performApply()可以达到此效果,此时相当于点击了应用会重构UI,此方法不适合复杂的UI重构,因为每执行一次就会重新加载一次UI。

另一个思路,做UI的时候取消对话框上的“确定”、“应用”按钮,只保留“关闭”,就可以实现关闭或取消后保留创建的操作!但是此时对话框框架设置的撤销标记还在,只是此时关闭不会再返回对话框的Undo Mark。

怎样在关闭后直接删除该对话框创建的撤销标记呢,如:

int Test_SCHEME_CONFIG::Show()
{
    try
    {
        theDialog->Show(BlockDialog::DialogModeEdit);
    }
    catch(exception& ex)
    {
        //---- Enter your exception handling code here -----
        Test_SCHEME_CONFIG::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    }
    return 0;
}

下图为打开对话框即创建一个方块,设置颜色为红色,关闭对话框后方块保留且所有的撤销标记已被删除!

西门子帮助文档关于BlockUI Using undo marks的说明:

In automation code, you can call NXOpen or UF APIs to undo actions.

A user can work only with the undo marks that are created using the automation code. It is expected that undo marks created in any callback must be deleted in the same callback or else the dialog framework automatically deletes that undo mark after the callback execution.

You can undo up to a mark in one of the following ways.

Explicit method

Use direct APIs which delete the undo mark such as Session.UndoToMark(). Attempts to delete the undo marks that are created by the dialog box framework result in an exception, and the dialog box remains open.

Implicit method

Some indirect APIs perform actions which result in the deletion of the undo mark.

When a user attempts to undo actions up to the undo mark created by the dialog box framework, an exception occurs, and the dialog box closes. You can use such APIs only in the OK and Apply callbacks and not in any other callbacks. For example, the UF_STD_import_stl_binary_file API imports a file and removes all undo marks that exist in the NX session.

Note

When a Block UI Styler application shows a second dialog box from the Update callback of the first dialog box, undo is unavailable. After you exit the second dialog box, there are no visible undo marks to undo operations completed in the second dialog box.

制作者 1,乐清*梅雷 部分内容参考百度QQ:1821117007 一共大概花了15个小时翻译以及制作。 2,彭辅军,网名:小白鼠,QQ:3243729373 二次开发QQ群:331643674 在梅雷基础上增加了内容,一共大概花了20个小时翻译以及制作。 本帮助文档可复制,可传播,但需要保留制作者信息,谢谢! 其中大部分内容测试比对过,部分没有进行测试比对效果。请以实际效果为准。本文只做参考。 注:由于BlockUI更新比较频繁,各版本之间会存在差异,有些版本的控件的属性名并没有那么多,或者此帮助文件并没有列进去,那么可以通过下面方法查看当前版本某控件的所有的属性名和类型: void get_block_ui_type_name(NXOpen::BlockStyler::UIBlock* BLOCK_UI_name) { Session*theSession=NXOpen::Session::GetSession(); ListingWindow*lw=theSession->ListingWindow(); lw->Open(); NXOpen::BlockStyler::PropertyList::ListMode mode1 = BLOCK_UI_name->GetProperties()->Mode(); if (mode1==BlockStyler::PropertyList::ListModeIndexed) { lw->WriteLine("ListMode:ListModeIndexed"); } else { lw->WriteLine("ListMode:ListModeNamed"); } int length = BLOCK_UI_name->GetProperties()->Length(); char info[100]; sprintf(info,"数量:%d",length); lw->WriteLine(info); std::vectorarray_nxstr = BLOCK_UI_name->GetProperties()->GetPropertyNames(); for (int i=0;iWriteLine(); BlockStyler::PropertyList::PropertyType type = BLOCK_UI_name->GetProperties()->GetPropertyType(array_nxstr[i]); if(type==0) lw->WriteLine("类型是:String 名称:"+array_nxstr[i]); else if(type==1) lw->WriteLine("类型是:Double 名称:"+array_nxstr[i]); else if(type==2) lw->WriteLine("类型是:Logical 名称:"+array_nxstr[i]); else if(type==3) lw->WriteLine("类型是:Integer 名称:"+array_nxstr[i]); else if(type==4) lw->WriteLine("类型是:Enum 名称:"+array_nxstr[i]); else if(type==5) lw->WriteLine("类型是:Strings 名称:"+array_nxstr[i]); else if(type==6) lw->WriteLine("类型是:UIBlock 名称:"+array_nxstr[i]); else if(type==7) lw->WriteLine("类型是:Point 名称:"+array_nxstr[i]); else if(type==8) lw->WriteLine("类型是:Vector 名称:"+array_nxstr[i]); else if(type==9) lw->WriteLine("类型是:Bits 名称:"+array_nxstr[i]); else if(type==10) lw->WriteLine("类型是:Tagged Object 名称:"+array_nxstr[i]); else if(type==11) lw->WriteLine("类型是:Array 名称:"+array_nxstr[i]); else if(type==12) lw->WriteLine("类型是:Integer 2d-Matrix 名称:"+array_nxstr[i]); else if(type==13) lw->WriteLine("类型是:Double 2d-Matrix 名称:"+array_nxstr[i]); else if(type==14) lw->WriteLine("类型是:Tagged Object 2d-Matrix 名称:"+array_nxstr[i]); else if(type==15) lw->WriteLine("类型是:Integer Vector 名称:"+array_nxstr[i]); else if(type==16) lw->WriteLine("类型是:Double Vector 名称:"+array_nxstr[i]); else if(type==17) lw->WriteLine("类型是:Tagged Object Vector 名称:"+array_nxstr[i]); else if(type==18) lw->WriteLine("类型是:File 名称:"+array_nxstr[i]); else if(type==19) lw->WriteLine("类型是:Selection Filter 名称:"+array_nxstr[i]); else if(type==20) lw->WriteLine("类型是:Undefined 名称:"+array_nxstr[i]); } } //下面是几个示例:控件的值的获取 。。。。。。。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值