atl

ATL COM Server - cretaing COM object defined in ATL Server from this server

Hello I have created the ATL COM Server C++ project using Visual Studio 2005 wizard. I added a new COM class using the ATL Simple Object wizard. Now when I try to create this COM class instance from my server (calling CoCreateInstance within the ATL server) I get CO_E_SERVER_EXEC_FAILURE error from CoCreateInstance. When I try to create...

Using ADO or OLEDB with ATL

I am writing an class using C++ (ATL).. I need to connect to a database. I am familiar with ADO but I see that all the functions are using IDispatch (late-binding/Automation). I am considering using OLEDB instead. What are the pros and cons of each? OLEDB seems like a lot of maintenance if the sql changes (tables, stored procs, etc). I d...

How does one return a local CComSafeArray to a LPSAFEARRAY output parameter?

I have a COM function that should return a SafeArray via a LPSAFEARRAY* out parameter. The function creates the SafeArray using ATL's CComSafeArray template class. My naive implementation uses CComSafeArray<T>::Detach() in order to move ownership from the local variable to the output parameter: void foo(LPSAFEARRAY* psa) { CComSafeA...

ATL Combobox-based control

I'm trying to create a simple ATL control based on a ComboBox under VS2008. So, I create a new ATL Project using the ATL Project Wizard, then add an ATL Control to the project using the ATL Control Wizard. I use all of the default settings except that I tell the wizard to base my control on ComboBox. The wizard does its thing and generat...

Does CAtlList::RemoveAt invalidate existing POSITIONS?

I'm looking at this, where m_Rows is a CAtlList: void CData::RemoveAll() { size_t cItems = m_Rows.GetCount(); POSITION Pos = m_Rows.GetHeadPosition(); while(Pos != 0) { CItem* pItem = m_Rows.GetAt(Pos); if (pItem != 0) delete pItem; POSITION RemoveablePos = Pos; pItem = m_Ro...

IContextMenu3 HandleMenuMsg2 is never called

Hi, I'm trying to implement a shell extension that extends IContextMenu3 and IShellExtInit, and i'm inserting menu items using the method described in section "HBMMENU_CALLBACK method" (http://www.nanoant.com/programming/themed-menus-icons-a-complete-vista-xp-solution) but in my project the method HandleMenuMsg2 or the HandleMenuMsg is...

'argument' : ambiguous conversions from 'Foo *const ' to 'IUnknown *'

I've got an ATL class: class Foo : public CComObjectRootEx<CComMultiThreadModel>, public CComCoClass<Foo, &CLSID_Foo>, public IPlugin, public IEventSubscriber { // ... }; I need to pass it to another object, like this: pOther->MethodTakingIUnknown(this); When I do this, I get the following error message: error ...

HOWTO add aggregate .NET COM Interop to an ATL EXE Server??

Hello, I would like to know how one can add a .NET C# COM object (created using the COM Interop facility of .NET) to a Visual Studio 2008 ATL EXE Server. Basically, I am trying to create an out of process Automation server to hold my C# COM object to allow it to act as a Singleton server for many clients. I think all I need to do is add...

InPlaceActivate on ATL control not called until mouse event

I have an ActiveX control written in C++ that I created with VS2008 and ATL. For the most part, it is a pretty standard (not modified much from the original template) control, except that instead of using IDispatchImpl, I have created my own IDispatchEx implementation. This control is only used in Internet Explorer, and I have been tes...

basic playback with programmatically created windows media player

I was trying to "just quickly integrate" the Windows Media Player via COM to play single files from the local file system or http sources - but due to the sparse documentation and online resources to its usage when not embedding into some kind of an Ole container, i couldn't get that supposedly trivial use-case to work. Initialization e...

How to create a DCOM server on a specific windows session?

Hello, My questions regards DCOM servers and windows sessions: I have a windows service, running in win 2008 platform. on some scenarios, this service has to show some UI (Open a window). Despite the ugly design , it is the service it self that has to trigger the window opening. In order to do so, i have a DCOM server that is created ...

ATL, COM, Arrays

Hello! There is the function GetLinksFromPage. She have created a links array, then I wanna pass that array to COM-object (only URLs), thus I have to convert CAtlArray< CComPtr< IDispatch> > to CComSafeArray< BSTR>. How I can do it ? HRESULT myclass::GetLinksFromPage( const CComPtr<IHTMLDocument2>& pDoc, CAtlArray<CComPtr<IDispatch> > &...

How do I get FinalRelease to be called when using GlobalInterfaceTable?

I am using Visual Studio 2008 and I have created an ATL Project. I have aded a ATL Simple Object to the project. I want to add my object to the Global Interface Table when the object is created, so I have the following code in my FinalConstruct call: HRESULT res; res = CoCreateInstance(GLSID_StdGlobalInterfaceTable, NULL, CLSCTX_INPRO...

Getting Coverage for Windows Explorer Context Menu Application!

I have an application which runs using the context menu of windows explorer. I create an ATL based DLL and register it to Windows Registry under HKCR\AllFileSystemObjects\ShellEx\ContextMenuHandlers. I am able to run my application. I want coverage for my code present in the DLL which is being registered in the registry. I am currently ...

Connection and event Sink implementation of Browser(ie, mozilla and google chrome)

how to implement event sink to enable the developed application to listen to event made by this three browsers: Internet explorer, mozilla firefox and google chrome? the application is a stand-alone application running in a network.. thanks!^^ ...

ComboBoxEx32 (CComboBoxEx) keyboard behaviour

I have a WTL application that uses an extended combobox control (the Win32 class ComboBoxEx32) with the CBS_DROPDOWNLIST style. It works well (I can have images against each item in the box) but the keyboard behaviour is different to a normal combobox - pressing a key will not jump to the first item in the combo that starts with that le...

How to best convert CString to BSTR to pass it as an "in" parameter into a COM method?

I need to convert a CString instance into a properly allocated BSTR and pass that BSTR into a COM method. To have code that compiles and works indentically for both ANSI and Unicode I use CString::AllocSysString() to convert whatever format CString to a Unicode BSTR. Since noone owns the returned BSTR I need to take care of it and relea...

Problem in using OnPosRectChange to set the size of a windowless ATL activeX control

I see this problem in follwing scnerio: The activex control is created with Extent 0,0(so it is not visible in IE). Then the user clicks on a html button which has the following pseudo code: Find the object; Object.display = “visibile”; In my corresponding put_display what executes is something like this: Rect rect = //New sized posi...

Why might trigger a breakpoint when I return TRUE from my OnCopyData?

I'm using Visual Studio to debug an ATL application. When I step over return TRUE in this code, the error occurs: BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) { // Code snipped from here - maybe this causes stack/heap corruption? // I have a breakpoint here, if I step over (F10), AFX trace message ...

Enumerate COM object (IDispatch) methods using ATL?

Using ATL (VS2008) how can I enumerate the available methods available on a given IDispatch interface (IDispatch*)? I need to search for a method with a specific name and, once I have the DISPID, invoke the method (I know the parameters the method takes.) Ideally I would like to do this using smart COM pointers (CComPtr<>). Is this po...