GUISUMOAbstractView*
TraCIServerAPI_GUI::getNamedView(const std::string& id) {
    GUIMainWindow* mw = static_cast<GUIMainWindow*>(getMainWindow());
    if (mw == 0) {
        return 0;
    }
    GUIGlChildWindow* c = static_cast<GUIGlChildWindow*>(mw->getViewByID(id));
    if (c == 0) {
        return 0;
    }
    return c->getView();
}
Ejemplo n.º 2
0
void WinDockPlugin::uninit()
{
    QWidget *main = getMainWindow();
    if (main && oldProc){
        appBarMessage(ABM_REMOVE);
        WNDPROC p;
        p = (WNDPROC)SetWindowLongW(main->winId(), GWL_WNDPROC, (LONG)oldProc);
        if (p == 0)
            p = (WNDPROC)SetWindowLongA(main->winId(), GWL_WNDPROC, (LONG)oldProc);
		oldProc = NULL;
    }
}
Ejemplo n.º 3
0
MShape* SourceGLCanvas::getShapeFromMappingId(uid mappingId) const
{
  if (mappingId == NULL_UID)
    return NULL;

  else
  {
    Mapping::ptr mapping = getMainWindow()->getMappingManager().getMappingById(mappingId);
    Q_CHECK_PTR(mapping);
    return mapping->getInputShape().get();
  }
}
Ejemplo n.º 4
0
void WinDockPlugin::uninit()
{
    QWidget *main = getMainWindow();
    if (main && oldProc){
        appBarMessage(ABM_REMOVE);
        if (IsWindowUnicode(pMain->winId())){
            SetWindowLongW(main->winId(), GWL_WNDPROC, (LONG)oldProc);
        }else{
            SetWindowLongA(main->winId(), GWL_WNDPROC, (LONG)oldProc);
        }
        oldProc = NULL;
    }
}
Ejemplo n.º 5
0
void SettingsJavaPluginForm::askRestart()
{
	QMessageBox box(QMessageBox::Warning, "FatRat", tr("For the changes to take effect, FatRat needs to be restarted."),
			QMessageBox::NoButton, getMainWindow());
	QPushButton* now = box.addButton(tr("Restart now"), QMessageBox::AcceptRole);
	box.addButton(tr("Restart later"), QMessageBox::RejectRole);
	box.exec();

	if (box.clickedButton() == now)
		restartApplication();
	else
		load();
}
Ejemplo n.º 6
0
//-----------------------------------------------------------------------------
void ImgChildWnd::mouseMoved(int X, int Y)
{
    bool bClearStatusbar = false;
    MainWindow *pWnd = getMainWindow();

    if (pWnd == 0 || m_pIplImage == 0)
        return;

    if (X >= m_pIplImage->width)
        bClearStatusbar = true;

    if (Y >= m_pIplImage->height)
        bClearStatusbar = true;

    if (bClearStatusbar)
    {
        pWnd->updateStatusbar(WM_STATUSBAR_MOUSEMOVE_MSG_CLEAR, 0, 0);
    }
    else
    {
        DWORD lParam = MAKEDWORD(X, Y);
        DWORD wParam = 0;

        switch (m_pIplImage->depth)
        {
        case IPL_DEPTH_8U:
            if (m_pIplImage->nChannels == 1)
            {
                BYTE *ptr = (BYTE *)(m_pIplImage->imageData + Y * m_pIplImage->widthStep);

                wParam = MAKEDWORD(MAKEWORD(0,0), MAKEWORD(0, ptr[X]));

                pWnd->updateStatusbar(WM_STATUSBAR_MOUSEMOVE_MSG_GRAY, lParam, wParam);
            }
            else if (m_pIplImage->nChannels == 3)
            {
                C24 *ptr = (C24 *)(m_pIplImage->imageData + Y * m_pIplImage->widthStep);
                C24 val = ptr[X];

                wParam = MAKEDWORD(MAKEWORD(0, val.c3), MAKEWORD(val.c2, val.c1));

                pWnd->updateStatusbar(WM_STATUSBAR_MOUSEMOVE_MSG_COLOR, lParam, wParam);
            }
            break;

        default:
            break;
        }
    }

}
Ejemplo n.º 7
0
void DockPlugin::init()
{
    if (dock)
        return;
    m_main = getMainWindow();
    if (m_main == NULL)
        return;
    m_main->installEventFilter(this);
    dock = new DockWnd(this, "inactive", I18N_NOOP("Inactive"));
    connect(dock, SIGNAL(showPopup(QPoint)), this, SLOT(showPopup(QPoint)));
    connect(dock, SIGNAL(toggleWin()), this, SLOT(toggleWin()));
    connect(dock, SIGNAL(doubleClicked()), this, SLOT(doubleClicked()));
    bQuit = false;
}
Ejemplo n.º 8
0
void WinDockPlugin::init()
{
    pMain = getMainWindow();
    if (pMain){
        if (IsWindowUnicode(pMain->winId())){
            oldProc = (WNDPROC)SetWindowLongW(pMain->winId(), GWL_WNDPROC, (LONG)dockWndProc);
            if (oldProc == 0)
                oldProc = (WNDPROC)SetWindowLongA(pMain->winId(), GWL_WNDPROC, (LONG)dockWndProc);
        }
        appBarMessage(ABM_NEW);
        m_bInit = true;
        setBarState();
    }
}
Ejemplo n.º 9
0
bool MapperGLCanvas::eventFilter(QObject *target, QEvent *event)
{
  if (event->type() == QEvent::KeyPress)
  {
    QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
    setActiveVertexIndex(getMainWindow()->getOutputWindow()->getCanvas()->getActiveVertexIndex());
    MapperGLCanvas::keyPressEvent(keyEvent);
    return true;
  }
  else
  {
    return QObject::eventFilter(target, event);
  }
}
Ejemplo n.º 10
0
TransparentPlugin::~TransparentPlugin()
{
#ifdef WIN32
    QWidget *main = getMainWindow();
    if (main)
        SetWindowLongW(main->winId(), GWL_EXSTYLE, GetWindowLongW(main->winId(), GWL_EXSTYLE) & (~WS_EX_LAYERED));
    if (timer)
        delete timer;
#else
    if (top)
        delete top;
#endif
    free_data(transparentData, &data);
}
Ejemplo n.º 11
0
/**
* returns paintViewPort
**/
nmc::DkPluginViewPort* DkNikonPlugin::getViewPort() {

	if (!viewport) {
		// >DIR: dummy viewport [4.7.2014 markus]
		viewport = new DkNikonViewPort();
	}

	if (!maidFacade) {
		QMainWindow* mainWindow = getMainWindow();

		maidFacade = new MaidFacade(mainWindow);

		if (maidFacade->init()) {
			
			
			if (!camControls) {

				// get last location
				QSettings settings;
				int dockLocation = settings.value("camControlsLocation", Qt::RightDockWidgetArea).toInt();

				camControls = new DkCamControls(maidFacade, tr("Camera Controls"));
			
				if (mainWindow)
					mainWindow->addDockWidget((Qt::DockWidgetArea)dockLocation, camControls);

				connect(camControls, SIGNAL(updateImage(QImage)), getViewPort(), SIGNAL(loadImage(QImage)));
				connect(camControls, SIGNAL(loadFile(QFileInfo)), getViewPort(), SIGNAL(loadFile(QFileInfo)));
				connect(camControls, SIGNAL(closeSignal()), getViewPort(), SIGNAL(closePlugin()));
			}

			camControls->setVisible(true);		

		} else {
			QMessageBox warningDialog(mainWindow);
			warningDialog.setWindowTitle(tr("MAID Library could not be opened"));
			warningDialog.setText(tr("The MAID library could not be opened. Camera controls will be disabled."));
			warningDialog.setIcon(QMessageBox::Warning);
			warningDialog.setStandardButtons(QMessageBox::Ok);
			warningDialog.setDefaultButton(QMessageBox::Ok);
			warningDialog.show();
			warningDialog.exec();

			return 0;
		}
	}

	return viewport;
}
Ejemplo n.º 12
0
void ShortcutsPlugin::init()
{
    if (m_bInit)
        return;
    QWidget *main = getMainWindow();
    if (main){
        if (IsWindowUnicode(main->winId())){
            oldProc = (WNDPROC)SetWindowLongW(main->winId(), GWL_WNDPROC, (LONG)keysWndProc);
        }else{
            oldProc = (WNDPROC)SetWindowLongA(main->winId(), GWL_WNDPROC, (LONG)keysWndProc);
        }
        m_bInit = true;
        applyKeys();
    }
}
Ejemplo n.º 13
0
ShortcutsPlugin::~ShortcutsPlugin()
{
#ifdef WIN32
    QWidget *main = getMainWindow();
    if (main && oldProc){
        if (IsWindowUnicode(main->winId())){
            SetWindowLongW(main->winId(), GWL_WNDPROC, (LONG)oldProc);
        }else{
            SetWindowLongA(main->winId(), GWL_WNDPROC, (LONG)oldProc);
        }
    }
#endif
    releaseKeys();
    free_data(shortcutsData, &data);
}
Ejemplo n.º 14
0
int QT4_GuiDialog::openDialog() {
  QT4_DialogBox *dialogBox;

  dialogBox=dynamic_cast<QT4_DialogBox*>(getMainWindow());
  if (dialogBox==NULL) {
    DBG_INFO(0, "Dialog's main widget is not derived from class FXDialogBox");
    return GWEN_ERROR_GENERIC;
  }

  /* show dialog */
  dialogBox->show();
  /* gui update */
  qApp->processEvents();

  return 0;
}
Ejemplo n.º 15
0
void TransparentPlugin::tickMouse()
{
#ifdef WIN32
    QPoint p = QCursor::pos();
    bool bMouse = false;
    QWidget *main = getMainWindow();
    if (main && main->isVisible()){
        if (main->frameGeometry().contains(p))
            bMouse = true;
    }
    if (bMouse != m_bHaveMouse){
        m_bHaveMouse = bMouse;
        setState();
    }
#endif
}
Ejemplo n.º 16
0
void OnTopPlugin::setState()
{
    QWidget *main = getMainWindow();
    if (main){
#ifdef WIN32
        Event eTop(EventOnTop, (void*)0);
        eTop.process();
        Event eTask(EventInTaskManager, (void*)getInTask());
        eTask.process();
#else
#ifdef USE_KDE
        if (getOnTop()){
            KWin::setState(main->winId(), NET::StaysOnTop);
        }else{
            KWin::clearState(main->winId(), NET::StaysOnTop);
        }
        if (getInTask()){
            KWin::clearState(main->winId(), NET::SkipTaskbar);
        }else{
            KWin::setState(main->winId(), NET::SkipTaskbar);
        }
#endif
#endif
    }
    QWidgetList  *list = QApplication::topLevelWidgets();
    QWidgetListIt it(*list);
    QWidget *w;
    while ((w = it.current()) != NULL){
        ++it;
        if (w->inherits("Container")){
#ifdef WIN32
            HWND hState = HWND_NOTOPMOST;
            if (getContainerOnTop()) hState = HWND_TOPMOST;
            SetWindowPos(w->winId(), hState, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
#else
#ifdef USE_KDE
            if (getContainerOnTop()){
                KWin::setState(w->winId(), NET::StaysOnTop);
            }else{
                KWin::clearState(w->winId(), NET::StaysOnTop);
            }
#endif
#endif
        }
    }
    delete list;
}
Ejemplo n.º 17
0
void WinDockPlugin::init()
{
    if (m_bInit)
        return;
    pMain = getMainWindow();
    if (pMain){
        if (IsWindowUnicode(pMain->winId())){
            oldProc = (WNDPROC)SetWindowLongW(pMain->winId(), GWL_WNDPROC, (LONG)dockWndProc);
        }else{
            oldProc = (WNDPROC)SetWindowLongA(pMain->winId(), GWL_WNDPROC, (LONG)dockWndProc);
        }
        appBarMessage(ABM_NEW);
        m_bInit = true;
        setBarState();
        pMain->installEventFilter(this);
    }
}
Ejemplo n.º 18
0
ShortcutsPlugin::~ShortcutsPlugin()
{
#ifdef WIN32
    QWidget *main = getMainWindow();
    if (main && oldProc) {
        if (IsWindowUnicode(main->winId())) {
            SetWindowLongW(main->winId(), GWL_WNDPROC, (LONG)oldProc);
        } else {
            SetWindowLongA(main->winId(), GWL_WNDPROC, (LONG)oldProc);
        }
    }
#else
#ifndef USE_KDE
    qt_set_x11_event_filter(oldFilter);
#endif
#endif
    releaseKeys();
    free_data(shortcutsData, &data);
}
Ejemplo n.º 19
0
AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent) {
    printf("%s\n", __func__);
    if (layout() != NULL)
        delete layout();

    QGridLayout* gridLayout= new QGridLayout();
    setLayout(gridLayout);

    thirdPartyCreditsButton = new QPushButton("Third-party credits", this);
    gridLayout->addWidget(thirdPartyCreditsButton, 1, 0);

    debugButton = new QPushButton("Debug info", this);
    gridLayout->addWidget(debugButton, 1, 1);

    okButton = new QPushButton("Close", this);
    gridLayout->addWidget(okButton, 2, 0, 1, 2);

    connect(debugButton, SIGNAL(clicked()), this, SLOT(showDebugWindow()));
    connect(thirdPartyCreditsButton, SIGNAL(clicked()), this, SLOT(showThirdPartiesWindow()));

#ifdef WithQt5Quick
    quickWidget = new QQuickWidget();
    quickWidget->setSource(QUrl("qrc:/AboutDialog.qml"));
    quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
    gridLayout->addWidget(quickWidget, 0, 0, 1, 2);
#else
    QString labelContent = "<h2><b>FreeGo " + QString(FREEGO_VERSION) + "</b></hr></h2><br/>Written with the excellent Qt and CMake.<br/>Gameplay entirely provided by GNU Go.<br/>License GNU GPLv3.<br/>Source code at: <a href=\"https://github.com/alecs1/home/tree/master/qt/qtgo/\">https://github.com/alecs1/home/tree/master/qt/qtgo/</a>";
    androidLabel = new QLabel(labelContent);
    androidLabel->setAlignment(Qt::AlignCenter);
    gridLayout->addWidget(androidLabel, 0, 0, 1, 2);
#endif
    connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));

    QMainWindow* mainWindow = getMainWindow();
    if (mainWindow != NULL) {
        resize(mainWindow->size());
    }
    else {
        printf("%s - error, could not find MainWindow\n", __func__);
    }
    printSizeInfo(__func__);
}
Ejemplo n.º 20
0
void TransparentPlugin::tick()
{
#ifdef WIN32
    QWidget *main = getMainWindow();
    if (main == NULL){
        timer->stop();
        return;
    }
    unsigned timeout = m_bActive ? SHOW_TIMEOUT : HIDE_TIMEOUT;
    unsigned time = GetTickCount() - startTime;
    if (time >= timeout){
        time = timeout;
        timer->stop();
    }
    if (m_bState)
        time = timeout - time;
    BYTE d = (BYTE)QMIN((100 - getTransparency() * time / timeout) * 256 / 100, 255);
    SetLayeredWindowAttributes(main->winId(), main->colorGroup().background().rgb(), d, LWA_ALPHA);
#endif
}
Ejemplo n.º 21
0
int QT4_GuiDialog::execute() {
  QT4_DialogBox *dialogBox;
  int rv;

  dialogBox=dynamic_cast<QT4_DialogBox*>(getMainWindow());
  if (dialogBox==NULL) {
    DBG_INFO(0, "Dialog's main widget is not derived from class FXDialogBox");
    return GWEN_ERROR_GENERIC;
  }

  /* execute dialog */
  rv=dialogBox->exec();
  GWEN_Dialog_EmitSignalToAll(_dialog, GWEN_DialogEvent_TypeFini, "");

  if (rv==QT4_DialogBox::Accepted) {
    /* accepted */
    return 1;
  }
  else
    return 0;
}
Ejemplo n.º 22
0
int QT4_GuiDialog::runDialog(bool untilEnd) {
  QT4_DialogBox *dialogBox;

  dialogBox=dynamic_cast<QT4_DialogBox*>(getMainWindow());
  if (dialogBox==NULL) {
    DBG_INFO(0, "Dialog's main widget is not derived from class FXDialogBox");
    return GWEN_ERROR_GENERIC;
  }

  if (untilEnd) {
    dialogBox->cont();
  }
  else {
    {
      /* gui update */
      qApp->processEvents();
    }
  }

  return 0;
}
Ejemplo n.º 23
0
int QT4_GuiDialog::closeDialog() {
  QT4_DialogBox *dialogBox;

  dialogBox=dynamic_cast<QT4_DialogBox*>(getMainWindow());
  if (dialogBox==NULL) {
    DBG_INFO(0, "Dialog's main widget is not derived from class FXDialogBox");
    return GWEN_ERROR_GENERIC;
  }

  /* let dialog write its settings */
  GWEN_Dialog_EmitSignalToAll(_dialog, GWEN_DialogEvent_TypeFini, "");

  /* hide dialog */
  dialogBox->hide();
  /* gui update */
  qApp->processEvents();

  delete _mainWidget;
  _mainWidget=NULL;

  return 0;
}
Ejemplo n.º 24
0
bool TransparentPlugin::eventFilter(QObject *o, QEvent *e)
{
#ifdef WIN32
    if (getIfInactive()){
        switch (e->type()){
        case QEvent::WindowActivate:
        case QEvent::WindowDeactivate:
            setState();
            break;
        case QEvent::Show:{
                QWidget *main = getMainWindow();
                if (main){
                    setState();
                }
                break;
            }
        default:
            break;
        }
    }
#endif
    return QObject::eventFilter(o, e);
}
Ejemplo n.º 25
0
void *UpdatePlugin::processEvent(Event *e)
{
    if (e->type() == EventFetchDone){
        fetchData *data = (fetchData*)(e->param());
        if (data->req_id != m_fetch_id)
            return NULL;
        string h = getHeader("Location", data->headers);
        if (h.empty()){
            time_t now;
            time(&now);
            setTime(now);
            Event e(EventSaveState);
            e.process();
        }else{
            QWidget *main = getMainWindow();
            if (main == NULL)
                return NULL;
            Command cmd;
            cmd->id		= CmdStatusBar;
            Event eWidget(EventCommandWidget, cmd);
            QWidget *statusWidget = (QWidget*)(eWidget.process());
            if (statusWidget == NULL)
                return NULL;
            m_url = h;
            QStringList l;
            l.append(i18n("Show details"));
            l.append(i18n("Remind later"));
            raiseWindow(main);
            BalloonMsg *msg = new BalloonMsg(NULL, i18n("New version SIM is released"), l, statusWidget);
            connect(msg, SIGNAL(action(int, void*)), this, SLOT(showDetails(int, void*)));
            connect(msg, SIGNAL(destroyed()), this, SLOT(msgDestroyed()));
            msg->show();
            return NULL;
        }
        m_fetch_id = 0;
    }
Ejemplo n.º 26
0
void *TransparentPlugin::processEvent(Event *e)
{
    if (e->type() == EventInit)
        setState();
#ifndef WIN32
    if (e->type() == EventPaintView){
        PaintView *pv = (PaintView*)(e->param());
        QPixmap pict = top->background(pv->win->colorGroup().background());
        if (!pict.isNull()){
            QPoint p = pv->pos;
            p = pv->win->mapToGlobal(p);
            p = pv->win->topLevelWidget()->mapFromGlobal(p);
            pv->p->drawPixmap(0, 0, pict, p.x(), p.y());
            pv->isStatic = true;
        }
    }
    if (e->type() == EventRaiseWindow){
        QWidget *w = (QWidget*)(e->param());
        if (w == getMainWindow())
            setState();
    }
#endif
    return NULL;
}
void TestMainWindow::init() {
	mw = getMainWindow();

}
Ejemplo n.º 28
0
void *DockPlugin::processEvent(Event *e)
{
    CommandDef *def;
    switch (e->type()){
    case EventInit:
        init();
        break;
    case EventQuit:
        if (dock){
            delete dock;
            dock = NULL;
        }
        break;
    case EventRaiseWindow:
        if (e->param() == getMainWindow()){
            if (dock == NULL)
                init();
            if (!getShowMain())
                return e->param();
        }
        break;
    case EventCommandCreate:
        def = (CommandDef*)(e->param());
        if (def->menu_id == MenuMain){
            CommandDef d = *def;
            if (def->flags & COMMAND_IMPORTANT){
                if (d.menu_grp == 0)
                    d.menu_grp = 0x1001;
            }else{
                d.menu_grp = 0;
            }
            d.menu_id = DockMenu;
            d.bar_id  = 0;
            Event e(EventCommandCreate, &d);
            e.process();
        }
        break;
    case EventCheckState:
        def = (CommandDef*)(e->param());
        if (def->id == CmdToggle){
            def->flags &= ~COMMAND_CHECKED;
            def->text = isMainShow() ?
                        I18N_NOOP("Hide main window") :
                        I18N_NOOP("Show main window");
            return e->param();
        }
        break;
    case EventCommandExec:
        CommandDef *def = (CommandDef*)(e->param());
        if (def->id == CmdToggle){
            QWidget *main = getMainWindow();
            if(!main) return NULL;
            if (isMainShow()){
                setShowMain(false);
                main->hide();
            }else{
                inactiveTime = 0;
                setShowMain(true);
                raiseWindow(main,getDesktop());
            }
            return e->param();
        }
        if (def->id == CmdCustomize){
            Event eCustomize(EventMenuCustomize, (void*)DockMenu);
            eCustomize.process();
            return e->param();
        }
        if (def->id == CmdQuit)
            bQuit = true;
        break;
    }
    return NULL;
}
Ejemplo n.º 29
0
T findMainWindowChildWithObjectName(QString objectName)
{
	QWidget *mainwindow = getMainWindow();
	T object = mainwindow->findChild<T>(objectName);
	return object;
}
Ejemplo n.º 30
0
//----------------------------------------------------------------------------
//  Init
HRESULT CAnchoRuntime::Init()
{
  ATLASSERT(m_spUnkSite);
  // get IServiceProvider to get IWebBrowser2 and IOleWindow
  CComQIPtr<IServiceProvider> pServiceProvider = m_spUnkSite;
  if (!pServiceProvider)
  {
    return E_FAIL;
  }

  // get IWebBrowser2
  pServiceProvider->QueryService(SID_SWebBrowserApp, IID_IWebBrowser2, (LPVOID*)&m_pWebBrowser.p);
  if (!m_pWebBrowser) {
    return E_FAIL;
  }

  AtlAdvise(m_pWebBrowser, (IUnknown *)(TWebBrowserEvents *) this, DIID_DWebBrowserEvents2, &m_WebBrowserEventsCookie);

  ATLTRACE(L"ANCHO: runtime initialization - CoCreateInstance(CLSID_AnchoAddonService)\n");
  // create addon service object
  IF_FAILED_RET(m_pAnchoService.CoCreateInstance(CLSID_AnchoAddonService));

  CComQIPtr<IAnchoServiceApi> serviceApi = m_pAnchoService;
  if (!serviceApi) {
    return E_NOINTERFACE;
  }

  {//Get TabManager
    CComQIPtr<IDispatch> dispatch;
    IF_FAILED_RET(serviceApi->get_tabManager(&dispatch));
    CComQIPtr<IAnchoTabManagerInternal> tabManager = dispatch;
    if (!tabManager) {
      return E_NOINTERFACE;
    }
    mTabManager = tabManager;
  }
  {//Get WindowManager
    CComQIPtr<IDispatch> dispatch;
    IF_FAILED_RET(serviceApi->get_windowManager(&dispatch));
    CComQIPtr<IAnchoWindowManagerInternal> windowManager = dispatch;
    if (!windowManager) {
      return E_NOINTERFACE;
    }
    mWindowManager = windowManager;
  }

  // Registering tab in service - obtains tab id and assigns it to the tab as property
  IF_FAILED_RET(mTabManager->registerRuntime((OLE_HANDLE)getFrameTabWindow(), this, m_HeartbeatSlave.id(), &m_TabID));
  HWND hwnd;
  m_pWebBrowser->get_HWND((SHANDLE_PTR*)&hwnd);
  ::SetProp(hwnd, s_AnchoTabIDPropertyName, (HANDLE)m_TabID);

  //Get WindowId
  IF_FAILED_RET(mWindowManager->getWindowIdFromHWND(reinterpret_cast<OLE_HANDLE>(getMainWindow()), &mWindowID));

  CComObject<CAnchoBrowserEvents>* pBrowserEventSource;
  IF_FAILED_RET(CComObject<CAnchoBrowserEvents>::CreateInstance(&pBrowserEventSource));

  m_pBrowserEventSource = pBrowserEventSource;

  AtlAdvise(m_pBrowserEventSource, (IUnknown*)(TAnchoBrowserEvents*) this, IID_DAnchoBrowserEvents,
    &m_AnchoBrowserEventsCookie);

  // Set the sink as property of the browser so it can be retrieved if someone wants to send
  // us events.
  IF_FAILED_RET(m_pWebBrowser->PutProperty(L"_anchoBrowserEvents", CComVariant(m_pBrowserEventSource)));
  ATLTRACE(L"ANCHO: runtime %d initialized\n", m_TabID);
  return S_OK;
}