Click here to Skip to main content
15,898,035 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralATL and javascript Pin
whizdom16-Feb-08 21:35
whizdom16-Feb-08 21:35 
GeneralRe: ATL and javascript Pin
Nathan Holt at EMOM18-Feb-08 11:48
Nathan Holt at EMOM18-Feb-08 11:48 
GeneralRe: ATL and javascript Pin
whizdom22-Feb-08 7:43
whizdom22-Feb-08 7:43 
QuestionPlease enlighten me on STL iterators and CriticalSection locking Pin
Kosta Cherry13-Feb-08 21:15
Kosta Cherry13-Feb-08 21:15 
GeneralRe: Please enlighten me on STL iterators and CriticalSection locking Pin
Andy Moore14-Feb-08 6:11
Andy Moore14-Feb-08 6:11 
GeneralRe: Please enlighten me on STL iterators and CriticalSection locking Pin
Kosta Cherry14-Feb-08 11:49
Kosta Cherry14-Feb-08 11:49 
GeneralUsing an activex control in an ATL project Pin
zon_cpp11-Feb-08 20:33
zon_cpp11-Feb-08 20:33 
GeneralRe: Using an activex control in an ATL project Pin
Stuart Dootson11-Feb-08 23:38
professionalStuart Dootson11-Feb-08 23:38 
If you're putting it in a dialog, use CAxDialogImpl to implement the dialog instead of CDialogImpl. Here's an example - it encapsulates a dialog that instantiates the Web browser ActiveX control as 'IDC_ABOUT':

#include <exdispid.h>  // browser event dispatch IDs

class CAboutDlg: public CAxDialogImpl<CAboutDlg>,
                 public IDispEventImpl<IDC_ABOUT, CAboutDlg, &DIID_DWebBrowserEvents2, &LIBID_SHDocVw, 1, 1>,
{

public:
   CAboutDlg();
   virtual ~CAboutDlg()
   {
      if (pWbAbout_)
      {
         BrowserDispEventImpl::DispEventUnadvise( pWbAbout_ );
      }
   }
   typedef IDispEventImpl<IDC_ABOUT, CAboutDlg, &DIID_DWebBrowserEvents2, &LIBID_SHDocVw, 1, 1> BrowserDispEventImpl;

   enum {IDD = IDD_ABOUTBOX};

   BEGIN_MSG_MAP(CAboutDlg)
      MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
   END_MSG_MAP()

   BEGIN_SINK_MAP(CAboutDlg)
      SINK_ENTRY_EX(IDC_ABOUT, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumentComplete)
   END_SINK_MAP()

private:
   LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
   {
      CenterWindow();
   
      aboutMessage_ = GetDlgItem(IDC_ABOUT);

      CComPtr<IAxWinAmbientDispatch> spHost;
      HRESULT hr = aboutMessage_.QueryHost(IID_IAxWinAmbientDispatch, (LPVOID*) &spHost);
      if(SUCCEEDED(hr))
      {
         spHost->put_AllowContextMenu(VARIANT_FALSE);
         spHost->put_DocHostFlags(DOCHOSTUIFLAG_DIALOG | DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_DISABLE_HELP_MENU);
      }
   
      if (SUCCEEDED(aboutMessage_.QueryControl(&pWbAbout_)) && pWbAbout_)
      {
         if (FAILED(BrowserDispEventImpl::DispEventAdvise ( pWbAbout_ )))
         {
            pWbAbout_ = 0;
         }
         else
         {
            pWbAbout_->put_RegisterAsBrowser(VARIANT_FALSE);
            pWbAbout_->put_RegisterAsDropTarget(VARIANT_FALSE);
            pWbAbout_->put_AddressBar(VARIANT_FALSE);
            pWbAbout_->put_Offline(VARIANT_TRUE);
            pWbAbout_->put_Resizable(VARIANT_FALSE);
            pWbAbout_->put_Silent(VARIANT_TRUE);
            pWbAbout_->put_MenuBar(VARIANT_FALSE);
            pWbAbout_->put_StatusBar(VARIANT_FALSE);
            pWbAbout_->put_ToolBar(VARIANT_FALSE);
            CComVariant v;
            pWbAbout_->Navigate(<default 'about' URL>, &v, &v, &v, &v);
         }
      }
      return 0;
   } // OnInitDialog
   void __stdcall OnDocumentComplete(IDispatch* pDisp, VARIANT * URL)
   {
      // Called when the default 'about' URL has been loaded
   }

   CAxWindow aboutMessage_;
   CComPtr<IWebBrowser2> pWbAbout_;
}; // class CAboutDlg
If you want your Active X control to be a window in a view, you just need to use CAxWindow, like so:

class CBrowserView : public CWindowImpl<CBrowserView, CAxWindow>
{
public:
   CBrowserView() {}
   virtual ~CBrowserView() {}
   DECLARE_WND_SUPERCLASS(NULL, CAxWindow::GetWndClassName())

   BEGIN_MSG_MAP_EX(CBrowserView)
      MESSAGE_HANDLER(WM_CREATE, OnCreate)
   END_MSG_MAP()

private:
   LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
   {
      DefWindowProc();
   
      CComPtr<IAxWinAmbientDispatch> spHost;
      if(FAILED(QueryHost(IID_IAxWinAmbientDispatch, (LPVOID*) &spHost)) || !spHost)
      {
         OutputDebugString("CBrowserView::OnCreate - QueryHost failed\n");
         return -1;
      }
      if (FAILED(QueryControl(&pWB2_)) || !pWB2_)
      {
         OutputDebugString("CBrowserView::OnCreate - QueryControl failed\n");
         return -1;
      }
   
      return 0;
   }

   CComPtr<IWebBrowser2> pWB2_;
};

The type of Active X control created is specified when you call the Create method for the window - the window name is the ProgID or CLSID - see this page[^].

HTH!



GeneralATL: IDispEvent*Impl for n instances [modified] Pin
wickdom8-Feb-08 3:59
wickdom8-Feb-08 3:59 
GeneralRe: ATL: IDispEvent*Impl for n instances Pin
Stuart Dootson8-Feb-08 8:52
professionalStuart Dootson8-Feb-08 8:52 
GeneralRe: ATL: IDispEvent*Impl for n instances Pin
wickdom8-Feb-08 12:03
wickdom8-Feb-08 12:03 
Generalefficiency copy vector into a second vector Pin
manustone4-Feb-08 2:20
manustone4-Feb-08 2:20 
GeneralRe: efficiency copy vector into a second vector Pin
Steve Echols4-Feb-08 18:03
Steve Echols4-Feb-08 18:03 
QuestionRe: efficiency copy vector into a second vector Pin
CPallini4-Feb-08 22:28
mveCPallini4-Feb-08 22:28 
GeneralRe: efficiency copy vector into a second vector Pin
manustone8-Feb-08 3:25
manustone8-Feb-08 3:25 
GeneralRe: efficiency copy vector into a second vector Pin
Andy Moore14-Feb-08 6:13
Andy Moore14-Feb-08 6:13 
QuestionTBSTYLE_EX_DRAWDDARROWS resize problem??? Pin
Rajesh_Yadav_8029-Jan-08 0:51
Rajesh_Yadav_8029-Jan-08 0:51 
Generalerror C2259: 'ATL::CComObject<base>' : cannot instantiate abstract class</base> Pin
zakkas248322-Jan-08 20:44
zakkas248322-Jan-08 20:44 
GeneralRe: error C2259: 'ATL::CComObject' : cannot instantiate abstract class Pin
Nathan Holt at EMOM23-Jan-08 5:18
Nathan Holt at EMOM23-Jan-08 5:18 
GeneralShell context menu Pin
nazovi11-Jan-08 3:48
nazovi11-Jan-08 3:48 
GeneralRe: Shell context menu Pin
led mike11-Jan-08 5:13
led mike11-Jan-08 5:13 
GeneralUnable to add variable for ATL Control Pin
KASR110-Jan-08 22:21
KASR110-Jan-08 22:21 
GeneralConvert CString to BSTR Pin
mandanani10-Jan-08 20:07
mandanani10-Jan-08 20:07 
QuestionRe: Convert CString to BSTR Pin
CPallini10-Jan-08 21:59
mveCPallini10-Jan-08 21:59 
GeneralRe: Convert CString to BSTR Pin
mandanani10-Jan-08 23:17
mandanani10-Jan-08 23:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.