禁用 COPY,PASTE 命令
Disabling copy, paste functionality问题:
You can do this by placing the entities on a locked layer. The same can be achieved
with API as follows. Make sure that you have layer named "Layer1" which is locked
(or modify the code to your needs). When you execute the attached code you are
prompted to select the entity. You can extend the same for a set of entities
by using acedSSGet().
解答:
Since there is a possibility that user might change the layer settings by invoking
'LAYER' command, You can restrict user not to unlock the layer by implementing
'AcEditorReactor'.
Please look at the attached code for (locklayer.cpp) implementation. Assume
user will invoke
Format-->Layer and unlocks the layers named 'Layer1' and clicks on OK. As soon
as layer dialog is closed following code snippet will be executed.
void CEdReactor::commandEnded(const char *cmd)
{
acutPrintf ("Command Ended %s\n", cmd);
//check if the latest command invoked is LAYER ??
if ((_tcsicmp("layer", cmd) == 0)||(_tcscmp("-LAYER", cmd) == 0))
{
//The following piece of code makes 'layer1' always in locked mode
Acad::ErrorStatus es;
AcDbLayerTable* pLayerTable = NULL;
AcDbLayerTableRecord*pLayerTableRecord = NULL;
if ((es = acdbHostApplicationServices()->workingDatabase()->getLayerTable(pLayerTable,
AcDb::kForRead))!= Acad::eOk)
{
acutPrintf ("Layer table open has failed\n");
pLayerTable->close();
return;
}
const char* kchLayerName = "Layer1"; /* assume this is what you want to be locked*/
AcDbObjectId recordId;
AcDbEntity* pEnt = NULL;
if (NULL != pLayerTable)
{
if ((es = pLayerTable->getAt(kchLayerName,pLayerTableRecord,AcDb::kForWrite))==
Acad::eOk)
{
//layer name 'Layer1' has been found. Check if it is locked ??
if (pLayerTableRecord->isLocked() != true)
{
//if not locked lock the the same
pLayerTableRecord->setIsLocked(true);
}
}
}
pLayerTableRecord->close();
pLayerTable->close();
}
}
The one drawback of this implementation is that even for first time if you invoke
the layer dialog to create the 'Layer1' it locks for you.
You need to decide the appropriate time when you want to load this application
(need more customization which suits to your requirements
谢谢分享!!!! 谢谢分享!!!!
页:
[1]