July 27, 2001 Tools

Simple Object II ATL ObjectWizard Extension

July 27, 2001

The Simple Object II ATL ObjectWizard Extension (whew — I’ve got to come up with a shorter name…) provides the following features:

  • Support for [oleautomation] interfaces.
  • Support for the Neutral-threaded apartment.
  • Support for IDispatch-based interfaces other than duals.
  • Better support for disabling features that do not make sense together, e.g. FTM + ThreadingModel=Apartment.
  • Updated pop-up help.

Originally, SimpleObject2 was built to do away with the one benefit of IDispatchImpl over IDelegatingDispImpl — wizard support. As do most things developed under the greedy eye of my colleagues, it grew to support a few more features than that. It’s available for download. Enjoy. 

July 26, 2001 Tools

CComVector: A SAFEARRAY Wrapper

July 26, 2001

I got tired of not having a smart type for SAFEARRAYs, so I built one. It’s limited to one dimension (does anyone use multi-dimentional SAFEARRAYs?) and provides one class for the SAFEARRAY and another for the data itself (the lock is a resource, too), but the usage is pretty nifty. See comvector.h for the what and the how.

Also, Ron Jacobs sent me an ATL port of COleSafeArray called CComSafeArray that I’ve made available here.

July 25, 2001 Tools

CComDate

July 25, 2001

This zip provides two classes for use with dates and times under Windows:

  • CComDATE: Wraps the COM DATE type, providing conversions from VARIANT, DATE, ANSI string, UNICODE string, time_t, SYSTEMTIME, FILETIME, DOS time and DBTIMESTAMP data types.
  • CComSpan: Represents the result of subtracting one CComDATE from another. Useful for time/date math.
July 24, 2001 Tools

Exposing Multiple IDispatch Interfaces

If you’d like to know about how to expose multiple IDispatch implementations from a single COM object, check out this extensive treatment of that very topic.

July 23, 2001 Tools

MDI Applications in ATL

July 23, 2001

At atlmdi.zip, please find Charles Petzold’s famous raw Win32 MDI application, MDIDemo, ported to ATL. See atlmdi.h for a set of base classes for building MDI applications in ATL and mdidemo.cpp for an example of their use.

July 22, 2001 Tools

Fixing the External Dispatch in ATL + IE5

July 22, 2001

Are you getting this: “Error: object doesn’t support this property or method” when you try to call a method on your ATL HTML Control exposed external dispatch (accessed via window.external in the HTML of the control)? Did it used to work with IE4 and now it doesn’t with IE5? That’s because the ATL boys played fast and loose with the identity laws of COM and, while it took the COM police a while to catch up with them, catch up with them they did.

Download WrapperDispatch.h for an explanation of the problem and my solution to it.

July 21, 2001 Tools

TraceHook

July 21, 2001

TraceHook is a member function call tracing delegator hook based on Keith Brown’s most excellent universal delegator. It allows you to write:

    // Get a COM object to wrap
    CComPtr<ICalc>  spCalc;
    spCalc.CoCreateInstance(CLSID_Calc);

    // Wrap it (when _DEBUG is defined only)
    TRACEHOOK(OLESTR("MyCalc"), &spCalc.p);

    // Use it
    spCalc->put_Sum(0);
    spCalc->Add(2);
    spCalc->Add(2);
    long nSum;
    spCalc->get_Sum(&nSum);

and see the following in the debug output (with no changes to the object’s source) :

    MyCalc, ICalc::put_Sum(0)
    MyCalc, ICalc::Add(2)
    MyCalc, ICalc::Add(2)
    MyCalc, ICalc::get_Sum()

Notice that the call stack is now dumped (for duals, either directly or via IDispatch, or any method with automation-compliant data types, thanks to features added by the most excellent Simon Fell! He also added the ability to hook objects created in scripting environments (or VB or Java, too), e.g.

    ' WSH Test script for CalcSvr / TraceHook

    ' Create the implementation of ITraceHookFactory
    set th = CreateObject("UDTraceHookSvr.TraceHook")

    ' Create an object (an <object> tag in HTML would be fine, too)
    set calc = CreateObject("CalcSvr.Calc")

    ' Trace all further calls on calc
    th.ComTrace "MyCalc", calc

    calc.sum = 0
    calc.add 2
    calc.add 2
    msgbox "2+2= " & calc.sum

would yield the following debug output:

    MyCalc, IDispatch::(Invoke) sum(0)
    MyCalc, IDispatch::(Invoke) add(2)
    MyCalc, IDispatch::(Invoke) add(2)
    MyCalc, IDispatch::(Invoke) sum() returned 4

The source, pre-built binaries and client-side headers are available. The pre-built binaries include Keith’s delegator as well.

July 20, 2001 Tools

CAspPtr

If you’ve ever had to write the code to pull the ASP intrinsic objects from the MTS context, you might appreciate CAspPtr, which allows the following:

STDMETHODIMP CJon::DoIt() {
  CAspPtr<IResponse> spResponse;
  if( spResponse ) {
    spResponse->Write(CComVariant(OLESTR("Baby got <b><i>Response</i></b>.")));
  }  
  return S_OK;
}

CAspPtr is available and was inspired by Jon Flanders. Thanks, Jon!


← Newer Entries Older Entries →