atl

What is the correct way to cast when using ATL and IUnknownPtr?

During the modification of an existing ATL COM object I came across an article from the "The Old New Thing" blog called "The ways people mess up IUnknown::QueryInterface" and there was a discussion in the comments section that started when one of the respondents (Norman Diamond) pointed out that that in one of the article's examples that...

WM_POWERBROADCAST handler for CMainDlg in ATL app not invoked

I have an ATL app where I want to handle WM_POWERBROADCAST. I have a CMainDlg (CAxDialogImpl) in whose MSG_MAP I defined the handler. BEGIN_MSG_MAP(CMainDlg) ... MESSAGE_HANDLER(WM_POWERBROADCAST, OnPowerChange) ... END_MSG_MAP() However, the handler isn't invoked when I do things that should invoke it, for instance change...

Mouse Event BHO

I want my BHO to listen to onmousedown event of some element in a certain webpage. I have all the code that find the specific element, and in msdn its says that I need to use the get_onmousedown event. I came up with this code. CComQIPtr<IHTMLElement> someElement; VARIANT mouse_eve; someElement->get_onmousedown(&mouse_eve); The que...

How to work with a DATE type in a COM/ATL project

I've got an ATL method that takes a DATE type, which is really a double. I can't find the class/functions for this type. Does anyone know how to operate on this type? I just need to make it into something I can get into boost::gregorian::date (yyyy/mm/dd). Also, I would really like to know what this double represents. Thanks. ...

How to reliably replace a library-defined error handler with my own?

On certain error cases ATL invokes AtlThrow() which is implemented as ATL::AtlThrowImpl() which in turn throws CAtlException. The latter is not very good - CAtlException is not even derived from std::exception and also we use our own exceptions hierarchy and now we will have to catch CAtlException separately here and there which is lots ...

How do I create interface methods using .tlb types in VS C++?

Background: The .TLB file contains interfaces written in language 'X'. I don't have .h, .idl, .tlh, or any other header files - just the .TLB file. Language 'X' does not export compatible .h, .idl, etc. I use the VS wizard to add an ATL simple object to my ATL project. I want to add a method to the interface of my simple ATL object ...

Problem hosting WebBrowser control in an ATL app.

I have a legacy atl app that hosts a webbrowser control in an ATL window. I create an instance of the client to host the browser using the following sequence CComPtr<IOleObject> spOleObject; HRESULT hr = CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC, ID_IOleObject,(void**)&spOleObject); spOleObject->SetClientSite(this); GetCli...

ATL CString or_bstr_t?

In our COM project, we need to choose between best string class implementation so that BSTR (used for COM interfaces) and elegant string class like CString provides many string manipulation APIs. Are there any better way to handle the strings and string operations so that it can be BSTR complaints as well as we can have naive CString op...

How to use MFC with ATL

Hi, I'm trying to write a COM EXE using ATL. I also have a MFC application. Both these applications would be run in local machines. Therefore, I don't need to run these two processes (COM EXE and MFC) separately. Can I create a single application (process) by combining these two applications ? Is there any possibility that I can embed...

ATL OR C# for windows shell/namespace extenssion?

Hi, i have a question, after allot of hours in googling and reading articles, i understood that namespace extenssion in windows is quite tricky (In C++ at least), now i've also seen its possible to do so in C# , but microsft does'nt officaly confirms using .net for namespace extensions... though i have seen very nice commercial Namespa...

Who is responsible for calling CoInitialize and CoUninitialize if surrogate process or COM+

Who is responsible for calling CoInitialize and CoUninitialize if 1- I host a COM dll within a surrogate process (either by using dcomcnfg utility or COM+ wizard)? 2- I build a ISAPI DLL that contains COM objects? ...

passing interfaces as parameters in ATL

Hi, I have a native C++ dll and two classes: classA { void setNumber(int number); int getNumber(); } classB { void setclassA(classA*); classA* getclassA(); } I have an ATL dll that wraps the native C++ dll and two interfaces: InterfaceForClassA , InterfaceForClassB . InterfaceForClassA : STDMETHODIMP CInterfaceForClassA::createClass...

Embed WTL App in ATL ActiveX control

Is there a way to somehow Embed a WTL destop application in ATL ActiveX (ie extension)? What I'm trying to achieve is to create an ActiveX control with office files Viewer. As a base I have a desktop WTL application (written some time ago) which uses OOo v3 API to display documents. I have created an ActiveX project, linked necessar...

How to make ATL control persistence future proof?

I have a custom button control created using ATL. This control is used by some composite controls and lots of dialog boxes. I just added some new properties to the button control and found that I then had to update all the controls and dialogs that used it. This is a really poor situation so I wondered if I could be doing something be...

How can I reject a Windows "Service Stop" request in ATL 7?

I have a Windows service built upon ATL 7's CAtlServiceModuleT class. This service serves up COM objects that are used by various applications on the system, and these other applications naturally start getting errors if the service is stopped while they are still running. I know that ATL DLLs solve this problem by returning S_OK in Dl...

Need Advice on designing ATL inproc Server (dll) that serves as both a soure and a sink of events.

Hi, I need to design an ATL inproc server that besides exposing methods and properties, also can fire events (source) and serve as a sink for a third party COM control that fires events. I would assume that this is a fairly common requirement. I can also foresee several "gotchas" that I would like to read up on before commencing the ...

Is it possible to simultaneously debug VB6 and a C++ COM dll?

I have a VB6 dll that is loaded by a VB6 frontend. This VB6 dll calls a C++ ATL dll via its COM interface. So, I can run from code in VB6 and I can debug in C++ also, however I can't seem to step through the VB6 code and then get into the C++ code. I feel that this should be possible. Currently I am doing the following steps Start VB6 ...

WebBrowser Control in ATL window. How to free up memory on window unload? I'm stuck.

Hello there. I have a Win32 C++ Application. There is the _tWinMain(...) Method with GetMessage(...) in a while loop at the end. Before GetMessage(...) I create the main window with HWND m_MainHwnd = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_LAYERED, CAxWindow::GetWndClassName(), _TEXT("http://www.-website-.com"), WS_POPUP, 0, 0, 1024, ...

How To capture particular window instead of total desktop?

I have captured total desktop using CPP, COM and DirectShow. But how can I capture particular window only? ...

Using MFC classes inside ATL Project

Hi, I have created an ATL Project with all default options using VC++ 2008. I have added Simple ATL object (interface IDemo) and some interface moethos inside the simple object. I want to use MFC classes (e.g. CDatabase, CRecordset and lots more) inside my ATL project. How can I achieve this? Thanks. ...