Author Topic: Document reactors for modeless?  (Read 1629 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6964
  • AKA Daniel
Document reactors for modeless?
« on: September 08, 2010, 09:06:24 AM »
What's the best way to notify a child of a palette set that a new doc has been activated?

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6964
  • AKA Daniel
Re: Document reactors for modeless?
« Reply #1 on: September 08, 2010, 10:19:49 AM »
Here is what I came up with ... it works   :-o

Code: [Select]
class ExtDocReactor : public AcApDocManagerReactor
{
private:
  CPaletteBlockChildDlg *mpDlg;
public:
  ExtDocReactor (CPaletteBlockChildDlg *dlg):mpDlg(dlg){
    acDocManager->addReactor (this) ;
  }
  ~ExtDocReactor () {
    if ( acDocManager != NULL )
      acDocManager->removeReactor (this);
  }
  virtual void documentActivated(AcApDocument* pActivatedDoc) {
    if(mpDlg)
      mpDlg->OnDocumentActivated(pActivatedDoc);
  }
};

meanwhile in CPaletteBlockChildDlg this mojo is working

Code: [Select]
CPaletteBlockChildDlg::CPaletteBlockChildDlg (CWnd *pParent /*=NULL*/, HINSTANCE hInstance /*=NULL*/)
: CAcUiDialog (CPaletteBlockChildDlg::IDD, pParent, hInstance)
{
  //{{AFX_DATA_INIT(CPaletteBlockChildDlg)
  mExtDocReactor = new ExtDocReactor(this);
  m_locale = _get_current_locale();
  //}}AFX_DATA_INIT
}