Author Topic: Info About CAdUiDockControlBar Class ?  (Read 6600 times)

0 Members and 1 Guest are viewing this topic.

LE

  • Guest
Info About CAdUiDockControlBar Class ?
« on: June 27, 2006, 07:26:47 PM »
Hello all;

Yes I know, I should be doing or using something else....

I have done, an explorer command using the CAdUiDockControlBar class and a TreeCtrl control for the first time, and would like to know if anyone have any information about this docking control, for example and it could be an MFC issues too:

- How to generate dynamically the tree items - (the way I did it is always has the same number)
- It is possible to have a the menu context for each item? - let say the user select an item an does a right-click on it.

Those two for now, need to think more....

Thanks!
« Last Edit: July 05, 2006, 09:53:00 AM by LE »

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Info About CAdUiDockControlBar Class ?
« Reply #1 on: June 27, 2006, 07:54:39 PM »
Hello all;

Yes I know, I should be doing or using something else....
No comment :)

Quote
- How to generate dynamically the tree items - (the way I did it is always has the same number)

You will need to get a vector/array/list of all the items and sub items to add so you can get the count of each to add nodes to the tree. Will need to see some code how you are adding them now but of course, anything can be done with code :)

Quote
- It is possible to have a the menu context for each item? - let say the user select an item an does a right-click on it.

Yes, again, we'll need to see some set up code as I don't have any to hand but I'm sure we can work it out once we get going.
I'll have to check my Ranson's as I think there was an example there....
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

LE

  • Guest
Re: Info About CAdUiDockControlBar Class ?
« Reply #2 on: June 28, 2006, 11:04:19 AM »
Thank you Mick;

I totally forgot about the ArxDbg sample and in there are several TreeCtrl samples....  :-)

LE

  • Guest
Re: Info About CAdUiDockControlBar Class ?
« Reply #3 on: July 05, 2006, 09:47:20 AM »
A curiosity... It is the only way to update a docking/modeless dialog (when switching from documents/dwgs) by using a DocManager Reactor?

Thanks!

LE

  • Guest
Re: Info About CAdUiDockControlBar Class ?
« Reply #4 on: July 05, 2006, 03:31:57 PM »
To the moderators:

Please remove the whole topic.... thanks!

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Info About CAdUiDockControlBar Class ?
« Reply #5 on: July 05, 2006, 06:24:24 PM »
Luis, if you want, you can remove it yourself, 'cause you were the original poster.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Bob Wahr

  • Guest
Re: Info About CAdUiDockControlBar Class ?
« Reply #6 on: July 05, 2006, 06:30:45 PM »
Nope.  I tried to do that earlier with a thread and normal people can't delete the first post of a thread.

LE

  • Guest
Re: Info About CAdUiDockControlBar Class ?
« Reply #7 on: July 05, 2006, 07:14:56 PM »
Thanks!

Reason = I have not place any code....  :|

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Info About CAdUiDockControlBar Class ?
« Reply #8 on: July 05, 2006, 08:47:07 PM »
OK, I stand corrected, the restriction must come into affect after someone replys.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Info About CAdUiDockControlBar Class ?
« Reply #9 on: July 05, 2006, 09:33:50 PM »
 :lmao:
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

LE

  • Guest
Re: Info About CAdUiDockControlBar Class ?
« Reply #10 on: July 05, 2006, 11:24:53 PM »
While are Pears or Apples.... I end up changing the dockable form for a custom palette, here is an image file.
« Last Edit: July 06, 2006, 01:18:21 PM by LE »

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Info About CAdUiDockControlBar Class ?
« Reply #11 on: July 06, 2006, 12:05:53 AM »
Very nice Luis!
The palette's do have a lot of features built right in which can save you a lot of work.
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

LE

  • Guest
Re: Info About CAdUiDockControlBar Class ?
« Reply #12 on: July 06, 2006, 10:03:25 AM »
Thanks Mick;

It is just a first try and looks easy, compared to CAdUiDockControlBar Class (indeed).

I will get into the tooltips & the contextmenu for the tree items.

Here is the portion of code to add a tree control, super basic and easy.

In your custom palette class derivation from CAdUiPalette, just add a public method to add & delete MFC controls and in the add method place the below code.

Also don't forget the pointer to your control like: CTreeCtrl *pTreeCtrl;
And in the delete method just add the call of: delete pTreeCtrl;

Included the image bitmap.

HTH.
Code: [Select]
///////////////////////////////////////////////////////////////////////////////////
// add the tree control
pTreeCtrl = new CTreeCtrl;
// resource override
////CAcModuleResourceOverride resOverride;
CRect rect;
GetClientRect(&rect);
rect.DeflateRect(2, 8, 2, 2);
// create the tree
if (!pTreeCtrl->Create(WS_CHILD | WS_VISIBLE |
TVS_HASLINES | TVS_HASBUTTONS |
TVS_LINESATROOT, rect,
this, ID_INSTANTBARTREECTRL))
{
acdbFail(_T("\nTree control fail!.\n"));
}
// tree style
pTreeCtrl->ModifyStyleEx(0, WS_EX_CLIENTEDGE);
// sample layers data
AcDbLayerTable* LayerTable = NULL;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(LayerTable, AcDb::kForRead);
AcDbLayerTableIterator* pLayerIterator;
LayerTable->newIterator(pLayerIterator);
AcDbLayerTableRecord* LayerTableRecord;
char *pLayerName;
CImageList pImageList;
CBitmap bitmap;
// tree images setup
pImageList.Create(16, 16, ILC_COLORDDB | ILC_MASK, 0, 0);
bitmap.LoadBitmap(IDB_TREECTRL);
pImageList.Add(&bitmap, RGB(255, 0, 255));
pTreeCtrl->SetImageList(&pImageList, TVSIL_STATE);
bitmap.DeleteObject();
pImageList.Detach();
// iterate all layers
for(pLayerIterator->start() ; !pLayerIterator->done() ; pLayerIterator->step())
{
pLayerIterator->getRecord(LayerTableRecord, AcDb::kForRead);
// layer name
LayerTableRecord->getName(pLayerName);
// insert the layer name as main node
HTREEITEM nodeLayer = pTreeCtrl->InsertItem(pLayerName);
// setup the state and the image
pTreeCtrl->SetItemState(nodeLayer,INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK);
// returns an AcCmColor object
// that contains the color value of the layer.
//AcCmColor colour = LayerTableRecord->color();

// returns true if and only if the layer is frozen.
// If the layer is thawed, then false is returned.
if (LayerTableRecord->isFrozen())
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Frozen"), nodeLayer);
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(3), TVIS_STATEIMAGEMASK);
}
else
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Thawed"), nodeLayer);
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(2), TVIS_STATEIMAGEMASK);
}

// returns true if and only if the layer is locked.
// If the layer is unlocked, then false is returned.
if (LayerTableRecord->isLocked())
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Locked"), nodeLayer);
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(6), TVIS_STATEIMAGEMASK);
}
else
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Unlocked"), nodeLayer);
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(7), TVIS_STATEIMAGEMASK);
}

// returns true if the layer is plottable.
// If the layer is not plottable, then false is returned.
if (LayerTableRecord->isPlottable())
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Plottable"), nodeLayer);
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(8), TVIS_STATEIMAGEMASK);
}
else
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Unplottable"), nodeLayer);
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(9), TVIS_STATEIMAGEMASK);
}

// returns true if the layer is off.
// If the layer is on, then false is returned.
if (LayerTableRecord->isOff())
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Off"), nodeLayer);
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(5), TVIS_STATEIMAGEMASK);
}
else
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("On"), nodeLayer);
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(4), TVIS_STATEIMAGEMASK);
}
LayerTableRecord->close();
acutDelString(pLayerName);
}
delete pLayerIterator;
LayerTable->close();
///////////////////////////////////////////////////////////////////////////////////
« Last Edit: July 08, 2006, 02:32:50 PM by LE »

LE

  • Guest
Re: Info About CAdUiDockControlBar Class ?
« Reply #13 on: July 08, 2006, 02:41:58 PM »
Quote
I will get into the tooltips & the contextmenu for the tree items.

I just finished this part, kind of difficult (as for me) doing this in C++/MFC/ARX... but it is working pretty nice, I end up using a docmanager reactor to update the tree data when switching documents.

I will try to extract the steps I did, and post a little sample here... I wonder how this is done in VB/A or C#.... ? ? ?, it is much easier?... can you go and have the tooltips for each item?.... how about the contextmenu... is that easy to have per each item too?

Just would like to know (no code is necessary)

Thanks.

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Info About CAdUiDockControlBar Class ?
« Reply #14 on: July 08, 2006, 09:01:22 PM »
I think code would be the best way to compare so here goes -

This first bit loads the treeview from a button event, it loads the nodes with info stored on my 'custom like' objects. Notice also that I have my own node object I derived from the TreeNode object, more in a sec on that -
Code: [Select]
private void button2_Click_1(object sender, System.EventArgs e)
{
Document doc =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
DocumentLock doclock = doc.LockDocument();
Database db =
HostApplicationServices.WorkingDatabase;
Transaction tr =
db.TransactionManager.StartTransaction();
Group group = null;
treeView1.Nodes.Clear();
TreeNode tn = new TreeNode(doc.Name);
treeView1.Nodes.Add(tn);
try
{
ArrayList groupIds = Utils.GetAllGroupsIds();
if (groupIds.Count == 0)
{
group = null;
return;
}
foreach (ObjectId grpid in groupIds) 
{
group = (Group) tr.GetObject(grpid, OpenMode.ForWrite);

DCSNode grpNode = new DCSNode(group.ObjectId);
grpNode.Text = "Group " + group.Name;
tn.Nodes.Add(grpNode);
ObjectId[] ids = group.GetAllEntityIds();
foreach(ObjectId id in ids)
{
Solid3d solid = tr.GetObject(id,OpenMode.ForWrite,false) as Solid3d;
if(solid != null)
{
DCS_Solid sol = new DCS_Solid(ref solid);
if(sol.HasData)
{
DCSNode n = new DCSNode(solid.ObjectId);
n.Text = "Item " + sol.ItemNumber;
grpNode.Nodes.Add(n);
}
}
}
}
tr.Commit();
}
finally
{
tr.Dispose();
doclock.Dispose();
}
}

Here's the code for my node object, this is pretty cool as you can store your own data types on each node which is very handy ;)
Code: [Select]
class DCSNode : TreeNode
{
public ObjectId ObjId;

public DCSNode(ObjectId id)
{
ObjId = id;
}
}
Pretty simple eh? You get all the good stuff that TreeNode already has and now you have more :).

Here's an example of a context menu for this control, you just add it to the form properties 'context menu' field. It uses the custom info I've stored on my TreeNode derived class -
Code: [Select]
private void menuItem1_Click(object sender, System.EventArgs e)
{
DCSNode n = (DCSNode)treeView1.SelectedNode;
string file = treeView1.Nodes[0].Text;
if(treeView1.SelectedNode.Index != 0)
{
MessageBox.Show("File name is " + file + "\nThe objectId of item picked is "
+ n.ObjId, "Context Menu sample!");
}
}
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

LE

  • Guest
Re: Info About CAdUiDockControlBar Class ?
« Reply #15 on: July 08, 2006, 09:44:30 PM »
As always Mick;

Thanks!

Here are some code of what I am doing/playing... it has been a lot of fun.  :-)

In the custom palette class derivation I put:

File = Cpalette.h
Code: [Select]
public:

// tree control
CTreeCtrl *pTreeCtrl;

// tooltips control
CToolTipCtrl m_tooltip;

// for the tooltips
void RelayEvent(UINT message, WPARAM wParam, LPARAM lParam);
BOOL PreTranslateMessage(MSG* pMsg);

afx_msg void OnContextMenu(CWnd*, CPoint point);

File = Cpalette.cpp

Code: [Select]
// map to hold all the tooltips strings
typedef CMap< HTREEITEM,HTREEITEM&,CString,CString& > TipMap;
extern TipMap tooltipMap;

In one function to add the controls I place:
Code: [Select]
tooltipMap.RemoveAll(); // removing first the previous tooltips

// add the tree control
pTreeCtrl = new CTreeCtrl;
CRect rect;
GetClientRect(&rect);
rect.DeflateRect(2, 8, 2, 2);
// create the tree
if (!pTreeCtrl->Create(WS_CHILD | WS_VISIBLE |
TVS_HASLINES | TVS_HASBUTTONS |
TVS_LINESATROOT, rect,
this, ID_INSTANTBARTREECTRL))
{
acdbFail(_T("\nTree control fail!.\n"));
}
// tree style
pTreeCtrl->ModifyStyleEx(0, WS_EX_CLIENTEDGE);
// sample layers data
AcDbLayerTable* LayerTable = NULL;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(LayerTable, AcDb::kForRead);
AcDbLayerTableIterator* pLayerIterator;
LayerTable->newIterator(pLayerIterator);
AcDbLayerTableRecord* LayerTableRecord;
char *pLayerName;
CImageList pImageList;
CBitmap bitmap;
// tree images setup
pImageList.Create(16, 16, ILC_COLORDDB | ILC_MASK, 0, 0);
bitmap.LoadBitmap(IDB_TREECTRL);
pImageList.Add(&bitmap, RGB(255, 0, 255));
pTreeCtrl->SetImageList(&pImageList, TVSIL_STATE);
bitmap.DeleteObject();
pImageList.Detach();
// iterate all layers
for(pLayerIterator->start() ; !pLayerIterator->done() ; pLayerIterator->step())
{
pLayerIterator->getRecord(LayerTableRecord, AcDb::kForRead);
// layer name
LayerTableRecord->getName(pLayerName);
// insert the layer name as main node
HTREEITEM nodeLayer = pTreeCtrl->InsertItem(pLayerName);
tooltipMap[nodeLayer] = pLayerName; // Set the tool tip text of the item.

// setup the state and the image
pTreeCtrl->SetItemState(nodeLayer,INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK);
// returns an AcCmColor object
// that contains the color value of the layer.
//AcCmColor colour = LayerTableRecord->color();

// returns true if and only if the layer is frozen.
// If the layer is thawed, then false is returned.
if (LayerTableRecord->isFrozen())
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Frozen"), nodeLayer);
tooltipMap[nodeChild] = "Frozen";
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(3), TVIS_STATEIMAGEMASK);
}
else
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Thawed"), nodeLayer);
tooltipMap[nodeChild] = "Thawed";
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(2), TVIS_STATEIMAGEMASK);
}

// returns true if and only if the layer is locked.
// If the layer is unlocked, then false is returned.
if (LayerTableRecord->isLocked())
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Locked"), nodeLayer);
tooltipMap[nodeChild] = "Locked";
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(6), TVIS_STATEIMAGEMASK);
}
else
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Unlocked"), nodeLayer);
tooltipMap[nodeChild] = "Unlocked";
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(7), TVIS_STATEIMAGEMASK);
}

// returns true if the layer is plottable.
// If the layer is not plottable, then false is returned.
if (LayerTableRecord->isPlottable())
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Plottable"), nodeLayer);
tooltipMap[nodeChild] = "Plottable";
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(8), TVIS_STATEIMAGEMASK);
}
else
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Unplottable"), nodeLayer);
tooltipMap[nodeChild] = "Unplottable";
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(9), TVIS_STATEIMAGEMASK);
}

// returns true if the layer is off.
// If the layer is on, then false is returned.
if (LayerTableRecord->isOff())
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("Off"), nodeLayer);
tooltipMap[nodeChild] = "Off";
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(5), TVIS_STATEIMAGEMASK);
}
else
{
HTREEITEM nodeChild = pTreeCtrl->InsertItem(_T("On"), nodeLayer);
tooltipMap[nodeChild] = "On";
pTreeCtrl->SetItemState(nodeChild, INDEXTOSTATEIMAGEMASK(4), TVIS_STATEIMAGEMASK);
}
LayerTableRecord->close();
acutDelString(pLayerName);
}
delete pLayerIterator;
LayerTable->close();

m_tooltip.Create(this);
m_tooltip.Activate(TRUE);
m_tooltip.AddTool(GetDlgItem(ID_INSTANTBARTREECTRL), "Layer Explorer"); // adding my tooltips!

Code: [Select]
BOOL CMyPalette::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_MOUSEMOVE && pMsg->hwnd == pTreeCtrl->m_hWnd)
{
CPoint point(LOWORD(pMsg->lParam), HIWORD(pMsg->lParam));
HTREEITEM hItem = pTreeCtrl->HitTest(point);
if(hItem != NULL)
{
CString text = tooltipMap[hItem];
m_tooltip.UpdateTipText(text, pTreeCtrl);
m_tooltip.RelayEvent(pMsg);
}
}
return FALSE;
}

Code: [Select]
void CMyPalette::OnContextMenu(CWnd* pWnd, CPoint point)
{
if (pWnd != pTreeCtrl)
{
CWnd::OnContextMenu(pWnd, point);
return;
}
CPoint CurPos;
UINT nFlags;
GetCursorPos(&CurPos);
ScreenToClient(&CurPos);
HTREEITEM hItemClk = pTreeCtrl->HitTest(CurPos, &nFlags);
pTreeCtrl->SelectItem(hItemClk);

CMenu menu;
CMenu* pContextMenu;
menu.LoadMenu(IDR_MENU1);
ASSERT(menu);
CString txt = "";

if ((hItemClk != NULL) && (TVHT_ONITEM & nFlags))
{
pTreeCtrl->Select(hItemClk, TVGN_CARET);
txt = pTreeCtrl->GetItemText(hItemClk);
}

pContextMenu = menu.GetSubMenu(0);
ASSERT(pContextMenu);

// delete previous items
// here I have to do the following since I did not found a better way
pContextMenu->DeleteMenu(0, MF_BYPOSITION);
pContextMenu->DeleteMenu(1, MF_BYPOSITION);
pContextMenu->DeleteMenu(0, MF_BYPOSITION);
pContextMenu->DeleteMenu(1, MF_BYPOSITION);
pContextMenu->DeleteMenu(0, MF_BYPOSITION);
// to here

pContextMenu->AppendMenu(MF_STRING, 0, (LPCTSTR)txt.GetString());
pContextMenu->AppendMenu(MF_SEPARATOR, 0, _T(""));

pContextMenu->AppendMenu(MF_STRING, 0, _T("Menu Property1"));
pContextMenu->AppendMenu(MF_STRING, 0, _T("Menu Property2"));
pContextMenu->AppendMenu(MF_STRING, 0, _T("Menu Property3"));
pContextMenu->AppendMenu(MF_STRING, 0, _T("Menu Property4"));
pContextMenu->AppendMenu(MF_STRING, 0, _T("Menu Property5"));

CMenu menuPopup;
menuPopup.CreatePopupMenu();
ASSERT(menuPopup);

menuPopup.AppendMenu(MF_STRING | MF_ENABLED, 0, _T("PopupMenu Item1"));
menuPopup.AppendMenu(MF_STRING | MF_ENABLED, 0, _T("PopupMenu Item2"));
menuPopup.AppendMenu(MF_STRING | MF_ENABLED, 0, _T("PopupMenu Item3"));
menuPopup.AppendMenu(MF_STRING | MF_ENABLED, 0, _T("PopupMenu Item4"));

pContextMenu->AppendMenu(MF_POPUP | MF_ENABLED, (UINT)menuPopup.Detach(), _T("&Open PopupMenu"));

pContextMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, point.x, point.y, this, 0);
pContextMenu->Detach();

menu.Detach();
}
« Last Edit: July 08, 2006, 09:51:47 PM by LE »

LE

  • Guest
Re: Info About CAdUiDockControlBar Class ?
« Reply #16 on: July 09, 2006, 07:01:43 PM »
Mick;

And what approach do you use to update the data (controls) for your palette? [OnSetActive ?] - when switching documents.

le

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Info About CAdUiDockControlBar Class ?
« Reply #17 on: July 09, 2006, 07:14:13 PM »
I haven't gone that far with it yet Luis, at the moment I'm only interested in what's in my master model drg. The button I use to load the form only works in the current active document which is all I need at the moment. This way I can get objects from the master model and import them into a different document.
There are many document event handlers to override though so I imagine it wouldn't be too hard.
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

LE

  • Guest
Re: Info About CAdUiDockControlBar Class ?
« Reply #18 on: July 09, 2006, 07:30:16 PM »
I am using a docmanager reactor . . .

Code: [Select]
class CDocReactor : public AcApDocManagerReactor
{
public:
virtual void  documentActivated(AcApDocument* pDoc);
};

Code: [Select]
template <class T> class AsdkDataManager : public AcApDocManagerReactor
{
public:
    AsdkDataManager()
    {
        acDocManager->addReactor(this);
    }
    ~AsdkDataManager()
    {
        acDocManager->removeReactor(this);
    }
    virtual void documentToBeDestroyed( AcApDocument *pDoc )
    {
        m_dataMap.erase(pDoc);
    }
   
    T& docData(AcApDocument* pDoc)
    {
        std::map<AcApDocument*, T>::iterator i;
        i = m_dataMap.find(pDoc);
        if (i==m_dataMap.end())
            return  m_dataMap[ pDoc ];
        else
            return (*i).second;
    }
    T& docData()
    {
        return docData(acDocManager->curDocument());
    }
   
private:
    std::map<AcApDocument*, T> m_dataMap;
};

Code: [Select]
static CDocReactor* gpDocReactor = NULL;

void CDocReactor::documentActivated(AcApDocument* pDoc)
{
// my update function for the tree control data
}

Code: [Select]
void InitApplication()
{
gpDocReactor = new CDocReactor();
acDocManager->addReactor(gpDocReactor);

. . .
}

Code: [Select]
void UnloadApplication()
{
if(gpDocReactor)
{
acDocManager->removeReactor(gpDocReactor);
delete gpDocReactor;
}

. . .
}

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Info About CAdUiDockControlBar Class ?
« Reply #19 on: July 09, 2006, 09:48:26 PM »
That'll do it :)
The .net equivalent for reference is Autodesk.AutoCAD.ApplicationServices.DocumentCollection events methods which wrap these reactors.
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”