]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/mediactrl.cpp
Fix accelerstors with down and left
[wxWidgets.git] / src / msw / mediactrl.cpp
index 5132ce2bc09604182b26afd3ca451a6d871de247..4931215a5f1c8d57443aff88ebcc481705c7c50f 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        msw/mediactrl.cpp
+// Name:        src/msw/mediactrl.cpp
 // Purpose:     Built-in Media Backends for Windows
 // Author:      Ryan Norton <wxprojects@comcast.net>
 // Modified by:
@@ -9,6 +9,12 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
+// FIXME FIXME FIXME:
+// extract different backends in different files (better yet, make backends
+// dynamically loadable...), they have nothing to do with each other and this
+// file is huge and also separate the standard contents from our code itself
+
+
 //===========================================================================
 //  DECLARATIONS
 //===========================================================================
 // Pre-compiled header stuff
 //---------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "mediactrl.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 //---------------------------------------------------------------------------
 // WX Includes
 //---------------------------------------------------------------------------
-#include "wx/log.h"         //wxLogDebug
-#include "wx/math.h"        //log10 & pow
-#include "wx/msw/private.h" //user info and wndproc setting/getting
+#include "wx/log.h"         // wxLogDebug
+#include "wx/math.h"        // log10 & pow
+#include "wx/msw/private.h" // user info and wndproc setting/getting
 #include "wx/dcclient.h"
 #include "wx/timer.h"
+#include "wx/dynlib.h"
 
 //---------------------------------------------------------------------------
 // Externals (somewhere in src/msw/app.cpp and src/msw/window.cpp)
@@ -60,63 +63,30 @@ extern WXDLLIMPEXP_CORE const wxChar *wxCanvasClassName;
 LRESULT WXDLLIMPEXP_CORE APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
                                    WPARAM wParam, LPARAM lParam);
 
-//===========================================================================
-//  BACKEND DECLARATIONS
-//===========================================================================
-
-//---------------------------------------------------------------------------
-//
-//  wxAMMediaBackend
-//
-//---------------------------------------------------------------------------
-
 //---------------------------------------------------------------------------
-//  COM includes
+// Killed MSVC warnings
 //---------------------------------------------------------------------------
-#include "wx/msw/ole/oleutils.h" //wxBasicString, IID etc.
-#include "wx/msw/ole/uuid.h" //IID etc..
-#include <oleidl.h>
-#include <olectl.h>
-#include <exdisp.h>
-#include <docobj.h>
-
-//
-//  These defines are from another ole header - but its not in the
-//  latest sdk.  Also the ifndef DISPID_READYSTATE is here because at
-//  least on my machine with the latest sdk olectl.h defines these 3
-//
-#ifndef DISPID_READYSTATE
-    #define DISPID_READYSTATE                               -525
-    #define DISPID_READYSTATECHANGE                         -609
-    #define DISPID_AMBIENT_TRANSFERPRIORITY                 -728
+//disable "cast truncates constant value" for VARIANT_BOOL values
+//passed as parameters in VC5 and up
+#ifdef _MSC_VER
+#pragma warning (disable:4310)
 #endif
 
-#define DISPID_AMBIENT_OFFLINEIFNOTCONNECTED            -5501
-#define DISPID_AMBIENT_SILENT                           -5502
+//===========================================================================
+// BACKEND DECLARATIONS
+//===========================================================================
 
-#ifndef DISPID_AMBIENT_CODEPAGE
-#   define DISPID_AMBIENT_CODEPAGE                         -725
-#   define DISPID_AMBIENT_CHARSET                          -727
-#endif
+//---------------------------------------------------------------------------
+// wxAMMediaBackend
+//---------------------------------------------------------------------------
 
 //---------------------------------------------------------------------------
-//  COM compatability definitions
+// wxActiveXContainer - includes all the COM-specific stuff we need
 //---------------------------------------------------------------------------
-#ifndef STDMETHODCALLTYPE
-#define STDMETHODCALLTYPE __stdcall
-#endif
-#ifndef STDMETHOD
-#define STDMETHOD(funcname)  virtual HRESULT STDMETHODCALLTYPE funcname
-#endif
-#ifndef PURE
-#define PURE = 0
-#endif
-#ifndef __RPC_FAR
-#define __RPC_FAR FAR
-#endif
+#include "wx/msw/ole/activex.h"
 
 //---------------------------------------------------------------------------
-//  IIDS - used by CoCreateInstance and IUnknown::QueryInterface
+// IIDS - used by CoCreateInstance and IUnknown::QueryInterface
 //
 //  [idl name]          [idl decription]
 //  amcompat.idl        Microsoft Active Movie Control (Ver 2.0)
@@ -124,22 +94,25 @@ LRESULT WXDLLIMPEXP_CORE APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
 //  msdxm.idl           Windows Media Player (Ver 1.0)
 //  quartz.idl
 //
-//  First, when I say I "from XXX.idl", I mean I go into the COM Browser
-//  ($Microsoft Visual Studio$/Common/Tools/OLEVIEW.EXE), open
-//  "type libraries", open a specific type library (for quartz for example its
-//  "ActiveMovie control type library (V1.0)"), save it as an .idl, compile the
-//  idl using the midl compiler that comes with visual studio
-//  ($Microsoft Visual Studio$/VC98/bin/midl.exe on VC6) with the /h argument
-//  to make it generate stubs (a .h & .c file), then clean up the generated
-//  interfaces I want with the STDMETHOD wrappers and then put them into
-//  mediactrl.cpp.
+// First, when I say I "from XXX.idl", I mean I go into the COM Browser
+// ($Microsoft Visual Studio$/Common/Tools/OLEVIEW.EXE), open
+// "type libraries", open a specific type library (for quartz for example its
+// "ActiveMovie control type library (V1.0)"), save it as an .idl, compile the
+// idl using the midl compiler that comes with visual studio
+// ($Microsoft Visual Studio$/VC98/bin/midl.exe on VC6) with the /h argument
+// to make it generate stubs (a .h & .c file), then clean up the generated
+// interfaces I want with the STDMETHOD wrappers and then put them into
+// mediactrl.cpp.
 //
-//  According to the MSDN docs, IMediaPlayer requires Windows 98 SE
-//  or greater.  NetShow is available on Windows 3.1 and I'm guessing
-//  IActiveMovie is too.  IMediaPlayer is essentially the Windows Media
-//  Player 6.4 SDK.
+// According to the MSDN docs, IMediaPlayer requires Windows 98 SE
+// or greater. NetShow is available on Windows 3.1 and I'm guessing
+// IActiveMovie is too. IMediaPlayer is essentially the Windows Media
+// Player 6.4 SDK.
 //
-//  Some of these are not used but are kept here for future reference anyway
+// IWMP is from PlayerOCX.idl on PocketPC 2000, which uses CLSID_MediaPlayer
+// as well as the main windows line.
+//
+// Some of these are not used but are kept here for future reference anyway
 //---------------------------------------------------------------------------
 const IID IID_IActiveMovie          = {0x05589FA2,0xC356,0x11CE,{0xBF,0x01,0x00,0xAA,0x00,0x55,0x59,0x5A}};
 const IID IID_IActiveMovie2         = {0xB6CD6554,0xE9CB,0x11D0,{0x82,0x1F,0x00,0xA0,0xC9,0x1F,0x9C,0xA0}};
@@ -152,6 +125,8 @@ const IID IID_INSPlay1              = {0x265EC141,0xAE62,0x11D1,{0x85,0x00,0x00,
 const IID IID_IMediaPlayer          = {0x22D6F311,0xB0F6,0x11D0,{0x94,0xAB,0x00,0x80,0xC7,0x4C,0x7E,0x95}};
 const IID IID_IMediaPlayer2         = {0x20D4F5E0,0x5475,0x11D2,{0x97,0x74,0x00,0x00,0xF8,0x08,0x55,0xE6}};
 
+const IID IID_IWMP                  = {0x136B66EC,0xF30D,0x46A8,{0x88,0xDD,0xF2,0xD0,0x55,0x16,0x3E,0x49}};
+
 const CLSID CLSID_ActiveMovie       = {0x05589FA1,0xC356,0x11CE,{0xBF,0x01,0x00,0xAA,0x00,0x55,0x59,0x5A}};
 const CLSID CLSID_MediaPlayer       = {0x22D6F312,0xB0F6,0x11D0,{0x94,0xAB,0x00,0x80,0xC7,0x4C,0x7E,0x95}};
 const CLSID CLSID_NSPlay            = {0x2179C5D3,0xEBFF,0x11CF,{0xB6,0xFD,0x00,0xAA,0x00,0xB4,0xE2,0x20}};
@@ -191,28 +166,28 @@ struct IMediaEvent : public IDispatch
 };
 
 //---------------------------------------------------------------------------
-//  ACTIVEMOVIE COM INTERFACES (dumped from amcompat.idl from MSVC COM Browser)
+// ACTIVEMOVIE COM INTERFACES (dumped from amcompat.idl from MSVC COM Browser)
 //---------------------------------------------------------------------------
 
 enum ReadyStateConstants
 {
-    amvUninitialized    = 0,
-    amvLoading    = 1,
+    amvUninitialized  = 0,
+    amvLoading        = 1,
     amvInteractive    = 3,
-    amvComplete    = 4
+    amvComplete       = 4
 };
 
 enum StateConstants
 {
     amvNotLoaded    = -1,
-    amvStopped    = 0,
-    amvPaused    = 1,
-    amvRunning    = 2
+    amvStopped      = 0,
+    amvPaused       = 1,
+    amvRunning      = 2
 };
 
 enum DisplayModeConstants
 {
-    amvTime    = 0,
+    amvTime      = 0,
     amvFrames    = 1
 };
 
@@ -320,7 +295,6 @@ struct IActiveMovie : public IDispatch
 };
 
 
-
 struct IActiveMovie2 : public IActiveMovie
 {
     STDMETHOD(IsSoundCardEnabled)(VARIANT_BOOL __RPC_FAR *pbSoundCard) PURE;
@@ -776,1014 +750,667 @@ struct INSPlay1 : public INSPlay
 };
 
 //---------------------------------------------------------------------------
-// MISC COM INTERFACES
+//  IWMP (PocketPC 2000) COM INTERFACES (dumped from PlayerOCX.idl)
 //---------------------------------------------------------------------------
-typedef enum _FilterState
+
+struct IWMP : public IDispatch
 {
-    State_Stopped,
-    State_Paused,
-    State_Running
-} FILTER_STATE;
-typedef enum _PinDirection {
-    PINDIR_INPUT,
-    PINDIR_OUTPUT
-} PIN_DIRECTION;
+public:
+    virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_AutoSize(
+        /* [in] */ VARIANT_BOOL vbool) = 0;
 
-typedef struct _FilterInfo {
-    WCHAR        achName[128];
-    struct IFilterGraph *pGraph;
-} FILTER_INFO;
+    virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_AutoSize(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pbool) = 0;
 
-typedef struct _PinInfo {
-    struct IBaseFilter *pFilter;
-    PIN_DIRECTION dir;
-    WCHAR achName[128];
-} PIN_INFO;
+    virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_BorderStyle(
+        /* [in] */ long style) = 0;
 
-struct IBaseFilter;
-struct IPin;
-struct IEnumFilters;
-typedef struct  _MediaType {
-    GUID      majortype;
-    GUID      subtype;
-    BOOL      bFixedSizeSamples;
-    BOOL      bTemporalCompression;
-    ULONG     lSampleSize;
-    GUID      formattype;
-    IUnknown  *pUnk;
-    ULONG     cbFormat;
-    BYTE *pbFormat;
-} AM_MEDIA_TYPE;
+    virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_BorderStyle(
+        /* [retval][out] */ long __RPC_FAR *pstyle) = 0;
 
-struct IFilterGraph : public IUnknown
-{
-    STDMETHOD(AddFilter)(IBaseFilter *, LPCWSTR) PURE;
-    STDMETHOD(RemoveFilter)(IBaseFilter *) PURE;
-    STDMETHOD(EnumFilters)(IEnumFilters **) PURE;
-    STDMETHOD(FindFilterByName)(LPCWSTR, IBaseFilter **) PURE;
-    STDMETHOD(ConnectDirect)(IPin *, IPin *, const AM_MEDIA_TYPE *) PURE;
-    STDMETHOD(Reconnect)(IPin *) PURE;
-    STDMETHOD(Disconnect)(IPin *) PURE;
-    STDMETHOD(SetDefaultSyncSource)() PURE;
-};
+    virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Enabled(
+        /* [in] */ VARIANT_BOOL vbool) = 0;
 
-struct IGraphBuilder : public IFilterGraph
-{
-    STDMETHOD(Connect)(IPin *, IPin *) PURE;
-    STDMETHOD(Render)(IPin *) PURE;
-    STDMETHOD(RenderFile)(LPCWSTR, LPCWSTR) PURE;
-    STDMETHOD(AddSourceFilter)(LPCWSTR, LPCWSTR, IBaseFilter **) PURE;
-    STDMETHOD(SetLogFile)(DWORD_PTR) PURE;
-    STDMETHOD(Abort)() PURE;
-    STDMETHOD(ShouldOperationContinue)() PURE;
-};
+    virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Enabled(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pbool) = 0;
 
-struct IReferenceClock;
-struct IEnumPins;
-#define REFERENCE_TIME LONGLONG
-struct IMediaFilter : public IPersist
-{
-    STDMETHOD(Stop)( void) PURE;
-    STDMETHOD(Pause)( void) PURE;
-    STDMETHOD(Run)(REFERENCE_TIME tStart) PURE;
-    STDMETHOD(GetState)(DWORD dwMilliSecsTimeout,
-                       FILTER_STATE *State) PURE;
-    STDMETHOD(SetSyncSource)(IReferenceClock *pClock) PURE;
-    STDMETHOD(GetSyncSource)(IReferenceClock **pClock) PURE;
-};
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_FileName(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
 
-struct IBaseFilter : public IMediaFilter
-{
-    STDMETHOD(EnumPins)(IEnumPins **ppEnum) PURE;
-    STDMETHOD(FindPin)(LPCWSTR Id, IPin **ppPin) PURE;
-    STDMETHOD(QueryFilterInfo)(FILTER_INFO *pInfo) PURE;
-    STDMETHOD(JoinFilterGraph)(IFilterGraph *pGraph, LPCWSTR pName) PURE;
-    STDMETHOD(QueryVendorInfo)(LPWSTR *pVendorInfo) PURE;
-};
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_FileName(
+        /* [in] */ BSTR newVal) = 0;
 
-//---------------------------------------------------------------------------
-//
-//  wxActiveX (Ryan Norton's version :))
-//  wxActiveX is (C) 2003 Lindsay Mathieson
-//
-//---------------------------------------------------------------------------
-#define WX_DECLARE_AUTOOLE(wxAutoOleInterface, I) \
-class wxAutoOleInterface \
-{   \
-    protected: \
-    I *m_interface; \
-\
-    public: \
-    explicit wxAutoOleInterface(I *pInterface = NULL) : m_interface(pInterface) {} \
-    wxAutoOleInterface(REFIID riid, IUnknown *pUnk) : m_interface(NULL) \
-    {   QueryInterface(riid, pUnk); } \
-    wxAutoOleInterface(REFIID riid, IDispatch *pDispatch) : m_interface(NULL) \
-    {   QueryInterface(riid, pDispatch); } \
-    wxAutoOleInterface(REFCLSID clsid, REFIID riid) : m_interface(NULL)\
-    {   CreateInstance(clsid, riid); }\
-    wxAutoOleInterface(const wxAutoOleInterface& ti) : m_interface(NULL)\
-    {   operator = (ti); }\
-\
-    wxAutoOleInterface& operator = (const wxAutoOleInterface& ti)\
-    {\
-        if (ti.m_interface)\
-            ti.m_interface->AddRef();\
-        Free();\
-        m_interface = ti.m_interface;\
-        return *this;\
-    }\
-\
-    wxAutoOleInterface& operator = (I *&ti)\
-    {\
-        Free();\
-        m_interface = ti;\
-        return *this;\
-    }\
-\
-    ~wxAutoOleInterface() {   Free();   }\
-\
-    inline void Free()\
-    {\
-        if (m_interface)\
-            m_interface->Release();\
-        m_interface = NULL;\
-    }\
-\
-    HRESULT QueryInterface(REFIID riid, IUnknown *pUnk)\
-    {\
-        Free();\
-        wxASSERT(pUnk != NULL);\
-        return pUnk->QueryInterface(riid, (void **) &m_interface);\
-    }\
-\
-    HRESULT CreateInstance(REFCLSID clsid, REFIID riid)\
-    {\
-        Free();\
-        return CoCreateInstance(clsid, NULL, CLSCTX_ALL, riid, (void **) &m_interface);\
-    }\
-\
-    inline operator I *() const {return m_interface;}\
-    inline I* operator ->() {return m_interface;}\
-    inline I** GetRef()    {return &m_interface;}\
-    inline bool Ok() const    {return m_interface != NULL;}\
-};
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Volume(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-WX_DECLARE_AUTOOLE(wxAutoIDispatch, IDispatch)
-WX_DECLARE_AUTOOLE(wxAutoIOleClientSite, IOleClientSite)
-WX_DECLARE_AUTOOLE(wxAutoIUnknown, IUnknown)
-WX_DECLARE_AUTOOLE(wxAutoIOleObject, IOleObject)
-WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceObject, IOleInPlaceObject)
-WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceActiveObject, IOleInPlaceActiveObject)
-WX_DECLARE_AUTOOLE(wxAutoIOleDocumentView, IOleDocumentView)
-WX_DECLARE_AUTOOLE(wxAutoIViewObject, IViewObject)
-WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceSite, IOleInPlaceSite)
-WX_DECLARE_AUTOOLE(wxAutoIOleDocument, IOleDocument)
-WX_DECLARE_AUTOOLE(wxAutoIPersistStreamInit, IPersistStreamInit)
-WX_DECLARE_AUTOOLE(wxAutoIAdviseSink, IAdviseSink)
-
-class wxActiveX : public wxWindow
-{
-public:
-    wxActiveX(wxWindow * parent, REFIID iid, IUnknown* pUnk);
-    virtual ~wxActiveX();
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_Volume(
+        /* [in] */ long newVal) = 0;
 
-    void OnSize(wxSizeEvent&);
-    void OnPaint(wxPaintEvent&);
-    void OnSetFocus(wxFocusEvent&);
-    void OnKillFocus(wxFocusEvent&);
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Mute(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-protected:
-    friend class FrameSite;
-
-    wxAutoIDispatch            m_Dispatch;
-    wxAutoIOleClientSite      m_clientSite;
-    wxAutoIUnknown         m_ActiveX;
-    wxAutoIOleObject            m_oleObject;
-    wxAutoIOleInPlaceObject    m_oleInPlaceObject;
-    wxAutoIOleInPlaceActiveObject m_oleInPlaceActiveObject;
-    wxAutoIOleDocumentView    m_docView;
-    wxAutoIViewObject            m_viewObject;
-    HWND m_oleObjectHWND;
-    bool m_bAmbientUserMode;
-    DWORD m_docAdviseCookie;
-    wxWindow* m_realparent;
-
-    void CreateActiveX(REFIID, IUnknown*);
-};
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_Mute(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
 
-#define DECLARE_OLE_UNKNOWN(cls)\
-    private:\
-    class TAutoInitInt\
-    {\
-        public:\
-        LONG l;\
-        TAutoInitInt() : l(0) {}\
-    };\
-    TAutoInitInt refCount, lockCount;\
-    static void _GetInterface(cls *self, REFIID iid, void **_interface, const char *&desc);\
-    public:\
-    LONG GetRefCount();\
-    HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject);\
-    ULONG STDMETHODCALLTYPE AddRef();\
-    ULONG STDMETHODCALLTYPE Release();\
-    ULONG STDMETHODCALLTYPE AddLock();\
-    ULONG STDMETHODCALLTYPE ReleaseLock()
-
-#define DEFINE_OLE_TABLE(cls)\
-    LONG cls::GetRefCount() {return refCount.l;}\
-    HRESULT STDMETHODCALLTYPE cls::QueryInterface(REFIID iid, void ** ppvObject)\
-    {\
-        if (! ppvObject)\
-        {\
-            return E_FAIL;\
-        };\
-        const char *desc = NULL;\
-        cls::_GetInterface(this, iid, ppvObject, desc);\
-        if (! *ppvObject)\
-        {\
-            return E_NOINTERFACE;\
-        };\
-        ((IUnknown * )(*ppvObject))->AddRef();\
-        return S_OK;\
-    };\
-    ULONG STDMETHODCALLTYPE cls::AddRef()\
-    {\
-        InterlockedIncrement(&refCount.l);\
-        return refCount.l;\
-    };\
-    ULONG STDMETHODCALLTYPE cls::Release()\
-    {\
-        if (refCount.l > 0)\
-        {\
-            InterlockedDecrement(&refCount.l);\
-            if (refCount.l == 0)\
-            {\
-                delete this;\
-                return 0;\
-            };\
-            return refCount.l;\
-        }\
-        else\
-            return 0;\
-    }\
-    ULONG STDMETHODCALLTYPE cls::AddLock()\
-    {\
-        InterlockedIncrement(&lockCount.l);\
-        return lockCount.l;\
-    };\
-    ULONG STDMETHODCALLTYPE cls::ReleaseLock()\
-    {\
-        if (lockCount.l > 0)\
-        {\
-            InterlockedDecrement(&lockCount.l);\
-            return lockCount.l;\
-        }\
-        else\
-            return 0;\
-    }\
-    DEFINE_OLE_BASE(cls)
-
-#define DEFINE_OLE_BASE(cls)\
-    void cls::_GetInterface(cls *self, REFIID iid, void **_interface, const char *&desc)\
-    {\
-        *_interface = NULL;\
-        desc = NULL;
-
-#define OLE_INTERFACE(_iid, _type)\
-    if (IsEqualIID(iid, _iid))\
-    {\
-        *_interface = (IUnknown *) (_type *) self;\
-        desc = # _iid;\
-        return;\
-    }
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_AutoStart(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-#define OLE_IINTERFACE(_face) OLE_INTERFACE(IID_##_face, _face)
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_AutoStart(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
 
-#define OLE_INTERFACE_CUSTOM(func)\
-    if (func(self, iid, _interface, desc))\
-    {\
-        return;\
-    }
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_PlayCount(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-#define END_OLE_TABLE\
-    }
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_PlayCount(
+        /* [in] */ long newVal) = 0;
 
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowStatusBar(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-class FrameSite :
-    public IOleClientSite,
-    public IOleInPlaceSiteEx,
-    public IOleInPlaceFrame,
-    public IOleItemContainer,
-    public IDispatch,
-    public IOleCommandTarget,
-    public IOleDocumentSite,
-    public IAdviseSink,
-    public IOleControlSite
-{
-private:
-    DECLARE_OLE_UNKNOWN(FrameSite);
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowStatusBar(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
 
-public:
-    FrameSite(wxWindow * win, wxActiveX * win2)
-    {
-        m_window = win2;
-        m_bSupportsWindowlessActivation = true;
-        m_bInPlaceLocked = false;
-        m_bUIActive = false;
-        m_bInPlaceActive = false;
-        m_bWindowless = false;
-
-        m_nAmbientLocale = 0;
-        m_clrAmbientForeColor = ::GetSysColor(COLOR_WINDOWTEXT);
-        m_clrAmbientBackColor = ::GetSysColor(COLOR_WINDOW);
-        m_bAmbientShowHatching = true;
-        m_bAmbientShowGrabHandles = true;
-        m_bAmbientAppearance = true;
-
-        m_hDCBuffer = NULL;
-        m_hWndParent = (HWND)win->GetHWND();
-    }
-    virtual ~FrameSite(){}
-    //***************************IDispatch*****************************
-    HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID, OLECHAR ** ,
-                                            unsigned int , LCID ,
-                                            DISPID * )
-    {   return E_NOTIMPL;   }
-    STDMETHOD(GetTypeInfo)(unsigned int, LCID, ITypeInfo **)
-    {   return E_NOTIMPL;   }
-    HRESULT STDMETHODCALLTYPE GetTypeInfoCount(unsigned int *)
-    {   return E_NOTIMPL;   }
-    HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID, LCID,
-                            WORD wFlags, DISPPARAMS *,
-                            VARIANT * pVarResult, EXCEPINFO *,
-                            unsigned int *)
-    {
-        if (!(wFlags & DISPATCH_PROPERTYGET))
-            return S_OK;
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowAudioControls(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-        if (pVarResult == NULL)
-            return E_INVALIDARG;
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowAudioControls(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
 
-        //The most common case is boolean, use as an initial type
-        V_VT(pVarResult) = VT_BOOL;
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowCaptioning(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-        switch (dispIdMember)
-        {
-            case DISPID_AMBIENT_MESSAGEREFLECT:
-                V_BOOL(pVarResult)= FALSE;
-                return S_OK;
-
-            case DISPID_AMBIENT_DISPLAYASDEFAULT:
-                V_BOOL(pVarResult)= TRUE;
-                return S_OK;
-
-            case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
-                V_BOOL(pVarResult) = TRUE;
-                return S_OK;
-
-            case DISPID_AMBIENT_SILENT:
-                V_BOOL(pVarResult)= TRUE;
-                return S_OK;
-
-            case DISPID_AMBIENT_APPEARANCE:
-                pVarResult->vt = VT_BOOL;
-                pVarResult->boolVal = m_bAmbientAppearance;
-                break;
-
-            case DISPID_AMBIENT_FORECOLOR:
-                pVarResult->vt = VT_I4;
-                pVarResult->lVal = (long) m_clrAmbientForeColor;
-                break;
-
-            case DISPID_AMBIENT_BACKCOLOR:
-                pVarResult->vt = VT_I4;
-                pVarResult->lVal = (long) m_clrAmbientBackColor;
-                break;
-
-            case DISPID_AMBIENT_LOCALEID:
-                pVarResult->vt = VT_I4;
-                pVarResult->lVal = (long) m_nAmbientLocale;
-                break;
-
-            case DISPID_AMBIENT_USERMODE:
-                pVarResult->vt = VT_BOOL;
-                pVarResult->boolVal = m_window->m_bAmbientUserMode;
-                break;
-
-            case DISPID_AMBIENT_SHOWGRABHANDLES:
-                pVarResult->vt = VT_BOOL;
-                pVarResult->boolVal = m_bAmbientShowGrabHandles;
-                break;
-
-            case DISPID_AMBIENT_SHOWHATCHING:
-                pVarResult->vt = VT_BOOL;
-                pVarResult->boolVal = m_bAmbientShowHatching;
-                break;
-
-            default:
-                return DISP_E_MEMBERNOTFOUND;
-        }
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowCaptioning(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
 
-        return S_OK;
-    }
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowControls(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-    //**************************IOleWindow***************************
-    HRESULT STDMETHODCALLTYPE GetWindow(HWND * phwnd)
-    {
-        if (phwnd == NULL)
-            return E_INVALIDARG;
-        (*phwnd) = m_hWndParent;
-        return S_OK;
-    }
-    HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL)
-    {return S_OK;}
-    //**************************IOleInPlaceUIWindow*****************
-    HRESULT STDMETHODCALLTYPE GetBorder(LPRECT lprectBorder)
-    {
-        if (lprectBorder == NULL)
-            return E_INVALIDARG;
-        return INPLACE_E_NOTOOLSPACE;
-    }
-    HRESULT STDMETHODCALLTYPE RequestBorderSpace(LPCBORDERWIDTHS pborderwidths)
-    {
-        if (pborderwidths == NULL)
-            return E_INVALIDARG;
-        return INPLACE_E_NOTOOLSPACE;
-    }
-    HRESULT STDMETHODCALLTYPE SetBorderSpace(LPCBORDERWIDTHS)
-    {return S_OK;}
-    HRESULT STDMETHODCALLTYPE SetActiveObject(
-        IOleInPlaceActiveObject *pActiveObject, LPCOLESTR)
-    {
-        if (pActiveObject)
-            pActiveObject->AddRef();
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowControls(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
 
-        m_window->m_oleInPlaceActiveObject = pActiveObject;
-        return S_OK;
-    }
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowDisplay(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-    //********************IOleInPlaceFrame************************
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowDisplay(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
 
-    STDMETHOD(InsertMenus)(HMENU, LPOLEMENUGROUPWIDTHS){return S_OK;}
-    STDMETHOD(SetMenu)(HMENU, HOLEMENU, HWND){  return S_OK;}
-    STDMETHOD(RemoveMenus)(HMENU){return S_OK;}
-    STDMETHOD(SetStatusText)(LPCOLESTR){ return S_OK;}
-    HRESULT STDMETHODCALLTYPE EnableModeless(BOOL){return S_OK;}
-    HRESULT STDMETHODCALLTYPE TranslateAccelerator(LPMSG lpmsg, WORD)
-    {
-        // TODO: send an event with this id
-        if (m_window->m_oleInPlaceActiveObject.Ok())
-            m_window->m_oleInPlaceActiveObject->TranslateAccelerator(lpmsg);
-        return S_FALSE;
-    }
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowGotoBar(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-    //*******************IOleInPlaceSite**************************
-    HRESULT STDMETHODCALLTYPE CanInPlaceActivate(){return S_OK;}
-    HRESULT STDMETHODCALLTYPE OnInPlaceActivate()
-    {   m_bInPlaceActive = true;    return S_OK;    }
-    HRESULT STDMETHODCALLTYPE OnUIActivate()
-    {   m_bUIActive = true;         return S_OK;    }
-    HRESULT STDMETHODCALLTYPE GetWindowContext(IOleInPlaceFrame **ppFrame,
-                                        IOleInPlaceUIWindow **ppDoc,
-                                        LPRECT lprcPosRect,
-                                        LPRECT lprcClipRect,
-                                        LPOLEINPLACEFRAMEINFO lpFrameInfo)
-    {
-        if (ppFrame == NULL || ppDoc == NULL || lprcPosRect == NULL ||
-            lprcClipRect == NULL || lpFrameInfo == NULL)
-        {
-            if (ppFrame != NULL)
-                (*ppFrame) = NULL;
-            if (ppDoc != NULL)
-                (*ppDoc) = NULL;
-            return E_INVALIDARG;
-        }
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowGotoBar(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
 
-        HRESULT hr = QueryInterface(IID_IOleInPlaceFrame, (void **) ppFrame);
-        if (! SUCCEEDED(hr))
-        {
-            return E_UNEXPECTED;
-        };
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowPositionControls(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-        hr = QueryInterface(IID_IOleInPlaceUIWindow, (void **) ppDoc);
-        if (! SUCCEEDED(hr))
-        {
-            (*ppFrame)->Release();
-            *ppFrame = NULL;
-            return E_UNEXPECTED;
-        };
-
-        RECT rect;
-        ::GetClientRect(m_hWndParent, &rect);
-        if (lprcPosRect)
-        {
-            lprcPosRect->left = lprcPosRect->top = 0;
-            lprcPosRect->right = rect.right;
-            lprcPosRect->bottom = rect.bottom;
-        };
-        if (lprcClipRect)
-        {
-            lprcClipRect->left = lprcClipRect->top = 0;
-            lprcClipRect->right = rect.right;
-            lprcClipRect->bottom = rect.bottom;
-        };
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowPositionControls(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
 
-        memset(lpFrameInfo, 0, sizeof(OLEINPLACEFRAMEINFO));
-        lpFrameInfo->cb = sizeof(OLEINPLACEFRAMEINFO);
-        lpFrameInfo->hwndFrame = m_hWndParent;
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowTracker(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-        return S_OK;
-    }
-    HRESULT STDMETHODCALLTYPE Scroll(SIZE){return S_OK;}
-    HRESULT STDMETHODCALLTYPE OnUIDeactivate(BOOL)
-    {   m_bUIActive = false;         return S_OK;    }
-    HRESULT STDMETHODCALLTYPE OnInPlaceDeactivate()
-    {   m_bInPlaceActive = false;    return S_OK;    }
-    HRESULT STDMETHODCALLTYPE DiscardUndoState(){return S_OK;}
-    HRESULT STDMETHODCALLTYPE DeactivateAndUndo(){return S_OK; }
-    HRESULT STDMETHODCALLTYPE OnPosRectChange(LPCRECT lprcPosRect)
-    {
-        if (m_window->m_oleInPlaceObject.Ok() && lprcPosRect)
-        {
-            m_window->m_oleInPlaceObject->SetObjectRects(
-                lprcPosRect, lprcPosRect);
-        }
-        return S_OK;
-    }
-    //*************************IOleInPlaceSiteEx***********************
-    HRESULT STDMETHODCALLTYPE OnInPlaceActivateEx(BOOL * pfNoRedraw, DWORD)
-    {
-        OleLockRunning(m_window->m_ActiveX, TRUE, FALSE);
-        if (pfNoRedraw)
-            (*pfNoRedraw) = FALSE;
-        return S_OK;
-    }
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowTracker(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
 
-    HRESULT STDMETHODCALLTYPE OnInPlaceDeactivateEx(BOOL)
-    {
-        OleLockRunning(m_window->m_ActiveX, FALSE, FALSE);
-        return S_OK;
-    }
-    STDMETHOD(RequestUIActivate)(){ return S_OK;}
-    //*************************IOleClientSite**************************
-    HRESULT STDMETHODCALLTYPE SaveObject(){return S_OK;}
-    const char *OleGetMonikerToStr(DWORD dwAssign)
-    {
-        switch (dwAssign)
-        {
-        case OLEGETMONIKER_ONLYIFTHERE  : return "OLEGETMONIKER_ONLYIFTHERE";
-        case OLEGETMONIKER_FORCEASSIGN  : return "OLEGETMONIKER_FORCEASSIGN";
-        case OLEGETMONIKER_UNASSIGN     : return "OLEGETMONIKER_UNASSIGN";
-        case OLEGETMONIKER_TEMPFORUSER  : return "OLEGETMONIKER_TEMPFORUSER";
-        default                         : return "Bad Enum";
-        };
-    };
-
-    const char *OleGetWhicMonikerStr(DWORD dwWhichMoniker)
-    {
-        switch(dwWhichMoniker)
-        {
-        case OLEWHICHMK_CONTAINER   : return "OLEWHICHMK_CONTAINER";
-        case OLEWHICHMK_OBJREL      : return "OLEWHICHMK_OBJREL";
-        case OLEWHICHMK_OBJFULL     : return "OLEWHICHMK_OBJFULL";
-        default                     : return "Bad Enum";
-        };
-    };
-    STDMETHOD(GetMoniker)(DWORD, DWORD, IMoniker **){return E_FAIL;}
-    HRESULT STDMETHODCALLTYPE GetContainer(LPOLECONTAINER * ppContainer)
-    {
-        if (ppContainer == NULL)
-            return E_INVALIDARG;
-        HRESULT hr = QueryInterface(
-            IID_IOleContainer, (void**)(ppContainer));
-        wxASSERT(SUCCEEDED(hr));
-        return hr;
-    }
-    HRESULT STDMETHODCALLTYPE ShowObject()
-    {
-        if (m_window->m_oleObjectHWND)
-            ::ShowWindow(m_window->m_oleObjectHWND, SW_SHOW);
-        return S_OK;
-    }
-    STDMETHOD(OnShowWindow)(BOOL){return S_OK;}
-    STDMETHOD(RequestNewObjectLayout)(){return E_NOTIMPL;}
-    //********************IParseDisplayName***************************
-    HRESULT STDMETHODCALLTYPE ParseDisplayName(
-        IBindCtx *, LPOLESTR, ULONG *, IMoniker **){return E_NOTIMPL;}
-    //********************IOleContainer*******************************
-    STDMETHOD(EnumObjects)(DWORD, IEnumUnknown **){return E_NOTIMPL;}
-    HRESULT STDMETHODCALLTYPE LockContainer(BOOL){return S_OK;}
-    //********************IOleItemContainer***************************
-    HRESULT STDMETHODCALLTYPE
-    #ifdef _UNICODE
-    GetObjectW
-    #else
-    GetObjectA
-    #endif
-    (LPOLESTR pszItem, DWORD, IBindCtx *, REFIID, void ** ppvObject)
-    {
-        if (pszItem == NULL || ppvObject == NULL)
-            return E_INVALIDARG;
-        *ppvObject = NULL;
-        return MK_E_NOOBJECT;
-    }
-    HRESULT STDMETHODCALLTYPE GetObjectStorage(
-        LPOLESTR pszItem, IBindCtx * , REFIID, void ** ppvStorage)
-    {
-        if (pszItem == NULL || ppvStorage == NULL)
-            return E_INVALIDARG;
-        *ppvStorage = NULL;
-        return MK_E_NOOBJECT;
-    }
-    HRESULT STDMETHODCALLTYPE IsRunning(LPOLESTR pszItem)
-    {
-        if (pszItem == NULL)
-            return E_INVALIDARG;
-        return MK_E_NOOBJECT;
-    }
-    //***********************IOleControlSite*****************************
-    HRESULT STDMETHODCALLTYPE OnControlInfoChanged()
-    {return S_OK;}
-    HRESULT STDMETHODCALLTYPE LockInPlaceActive(BOOL fLock)
-    {
-        m_bInPlaceLocked = (fLock) ? true : false;
-        return S_OK;
-    }
-    HRESULT STDMETHODCALLTYPE GetExtendedControl(IDispatch **)
-    {return E_NOTIMPL;}
-    HRESULT STDMETHODCALLTYPE TransformCoords(
-        POINTL * pPtlHimetric, POINTF * pPtfContainer, DWORD)
-    {
-        if (pPtlHimetric == NULL || pPtfContainer == NULL)
-            return E_INVALIDARG;
-        return E_NOTIMPL;
-    }
-    HRESULT STDMETHODCALLTYPE TranslateAccelerator(LPMSG, DWORD)
-    {return E_NOTIMPL;}
-    HRESULT STDMETHODCALLTYPE OnFocus(BOOL){return S_OK;}
-    HRESULT STDMETHODCALLTYPE ShowPropertyFrame(){return E_NOTIMPL;}
-    //**************************IOleCommandTarget***********************
-    HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *, ULONG cCmds,
-                                OLECMD prgCmds[], OLECMDTEXT *)
-    {
-        if (prgCmds == NULL) return E_INVALIDARG;
-        for (ULONG nCmd = 0; nCmd < cCmds; nCmd++)
-        {
-            // unsupported by default
-            prgCmds[nCmd].cmdf = 0;
-        }
-        return OLECMDERR_E_UNKNOWNGROUP;
-    }
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Startup( void ) = 0;
 
-    HRESULT STDMETHODCALLTYPE Exec(const GUID *, DWORD,
-                            DWORD, VARIANTARG *, VARIANTARG *)
-    {return OLECMDERR_E_NOTSUPPORTED;}
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Shutdown( void ) = 0;
 
-    //**********************IAdviseSink************************************
-    void STDMETHODCALLTYPE OnDataChange(FORMATETC *, STGMEDIUM *) {}
-    void STDMETHODCALLTYPE OnViewChange(DWORD, LONG) {}
-    void STDMETHODCALLTYPE OnRename(IMoniker *){}
-    void STDMETHODCALLTYPE OnSave(){}
-    void STDMETHODCALLTYPE OnClose(){}
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bandwidth(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-    //**********************IOleDocumentSite***************************
-    HRESULT STDMETHODCALLTYPE ActivateMe(
-        IOleDocumentView __RPC_FAR *pViewToActivate)
-    {
-        wxAutoIOleInPlaceSite inPlaceSite(
-            IID_IOleInPlaceSite, (IDispatch *) this);
-        if (!inPlaceSite.Ok())
-            return E_FAIL;
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_BaseURL(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
 
-        if (pViewToActivate)
-        {
-            m_window->m_docView = pViewToActivate;
-            m_window->m_docView->SetInPlaceSite(inPlaceSite);
-        }
-        else
-        {
-            wxAutoIOleDocument oleDoc(
-                IID_IOleDocument, m_window->m_oleObject);
-            if (! oleDoc.Ok())
-                return E_FAIL;
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_BaseURL(
+        /* [in] */ BSTR pVal) = 0;
 
-            HRESULT hr = oleDoc->CreateView(inPlaceSite, NULL,
-                                    0, m_window->m_docView.GetRef());
-            if (hr != S_OK)
-                return E_FAIL;
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_BufferingCount(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-            m_window->m_docView->SetInPlaceSite(inPlaceSite);
-        };
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_BufferingProgress(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-        m_window->m_docView->UIActivate(TRUE);
-        return S_OK;
-    };
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_BufferingTime(
+        /* [retval][out] */ double __RPC_FAR *pVal) = 0;
 
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CanSeek(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-protected:
-    wxActiveX * m_window;
-
-    HDC m_hDCBuffer;
-    HWND m_hWndParent;
-
-    bool m_bSupportsWindowlessActivation;
-    bool m_bInPlaceLocked;
-    bool m_bInPlaceActive;
-    bool m_bUIActive;
-    bool m_bWindowless;
-
-    LCID m_nAmbientLocale;
-    COLORREF m_clrAmbientForeColor;
-    COLORREF m_clrAmbientBackColor;
-    bool m_bAmbientShowHatching;
-    bool m_bAmbientShowGrabHandles;
-    bool m_bAmbientAppearance;
-};
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CanSeekToMarkers(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-DEFINE_OLE_TABLE(FrameSite)
-    OLE_INTERFACE(IID_IUnknown, IOleClientSite)
-    OLE_IINTERFACE(IOleClientSite)
-    OLE_INTERFACE(IID_IOleWindow, IOleInPlaceSite)
-    OLE_IINTERFACE(IOleInPlaceSite)
-    OLE_IINTERFACE(IOleInPlaceSiteEx)
-    OLE_IINTERFACE(IOleInPlaceUIWindow)
-    OLE_IINTERFACE(IOleInPlaceFrame)
-    OLE_IINTERFACE(IParseDisplayName)
-    OLE_IINTERFACE(IOleContainer)
-    OLE_IINTERFACE(IOleItemContainer)
-    OLE_IINTERFACE(IDispatch)
-    OLE_IINTERFACE(IOleCommandTarget)
-    OLE_IINTERFACE(IOleDocumentSite)
-    OLE_IINTERFACE(IAdviseSink)
-    OLE_IINTERFACE(IOleControlSite)
-END_OLE_TABLE;
-
-
-wxActiveX::wxActiveX(wxWindow * parent, REFIID iid, IUnknown* pUnk)
-    : m_realparent(parent)
-{
-    m_bAmbientUserMode = true;
-    m_docAdviseCookie = 0;
-    CreateActiveX(iid, pUnk);
-}
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ChannelDescription(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
 
-wxActiveX::~wxActiveX()
-{
-    // disconnect connection points
-    if (m_oleInPlaceObject.Ok())
-    {
-        m_oleInPlaceObject->InPlaceDeactivate();
-        m_oleInPlaceObject->UIDeactivate();
-    }
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ChannelName(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
 
-    if (m_oleObject.Ok())
-    {
-        if (m_docAdviseCookie != 0)
-            m_oleObject->Unadvise(m_docAdviseCookie);
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ChannelURL(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
 
-        m_oleObject->DoVerb(
-            OLEIVERB_HIDE, NULL, m_clientSite, 0, (HWND) GetHWND(), NULL);
-        m_oleObject->Close(OLECLOSE_NOSAVE);
-        m_oleObject->SetClientSite(NULL);
-    }
-}
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ClientID(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
 
-void wxActiveX::CreateActiveX(REFIID iid, IUnknown* pUnk)
-{
-    HRESULT hret;
-    hret = m_ActiveX.QueryInterface(iid, pUnk);
-    wxASSERT(SUCCEEDED(hret));
-
-    // FrameSite
-    FrameSite *frame = new FrameSite(m_realparent, this);
-    // oleClientSite
-    hret = m_clientSite.QueryInterface(
-        IID_IOleClientSite, (IDispatch *) frame);
-    wxASSERT(SUCCEEDED(hret));
-    // adviseSink
-    wxAutoIAdviseSink adviseSink(IID_IAdviseSink, (IDispatch *) frame);
-    wxASSERT(adviseSink.Ok());
-
-    // Get Dispatch interface
-    hret = m_Dispatch.QueryInterface(IID_IDispatch, m_ActiveX);
-
-    // Get IOleObject interface
-    hret = m_oleObject.QueryInterface(IID_IOleObject, m_ActiveX);
-    wxASSERT(SUCCEEDED(hret));
-
-    // get IViewObject Interface
-    hret = m_viewObject.QueryInterface(IID_IViewObject, m_ActiveX);
-    wxASSERT(SUCCEEDED(hret));
-
-    // document advise
-    m_docAdviseCookie = 0;
-    hret = m_oleObject->Advise(adviseSink, &m_docAdviseCookie);
-    m_oleObject->SetHostNames(L"wxActiveXContainer", NULL);
-    OleSetContainedObject(m_oleObject, TRUE);
-    OleRun(m_oleObject);
-
-
-    // Get IOleInPlaceObject interface
-    hret = m_oleInPlaceObject.QueryInterface(
-        IID_IOleInPlaceObject, m_ActiveX);
-    wxASSERT(SUCCEEDED(hret));
-
-    // status
-    DWORD dwMiscStatus;
-    m_oleObject->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus);
-    wxASSERT(SUCCEEDED(hret));
-
-    // set client site first ?
-    if (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST)
-        m_oleObject->SetClientSite(m_clientSite);
-
-
-    // stream init
-    wxAutoIPersistStreamInit
-        pPersistStreamInit(IID_IPersistStreamInit, m_oleObject);
-
-    if (pPersistStreamInit.Ok())
-    {
-        hret = pPersistStreamInit->InitNew();
-    }
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ConnectionSpeed(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-    if (! (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST))
-        m_oleObject->SetClientSite(m_clientSite);
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ContactAddress(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
 
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ContactEmail(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
 
-    RECT posRect;
-    ::GetClientRect((HWND)m_realparent->GetHWND(), &posRect);
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ContactPhone(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
 
-    m_oleObjectHWND = 0;
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CurrentMarker(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-    if (m_oleInPlaceObject.Ok())
-    {
-        hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
-        if (SUCCEEDED(hret))
-            ::SetActiveWindow(m_oleObjectHWND);
-    }
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_CurrentMarker(
+        /* [in] */ long newVal) = 0;
 
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CurrentPosition(
+        /* [retval][out] */ double __RPC_FAR *pVal) = 0;
 
-    if (! (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME))
-    {
-        if (posRect.right > 0 && posRect.bottom > 0 &&
-            m_oleInPlaceObject.Ok())
-                m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
-
-        hret = m_oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL,
-            m_clientSite, 0, (HWND)m_realparent->GetHWND(), &posRect);
-        hret = m_oleObject->DoVerb(OLEIVERB_SHOW, 0, m_clientSite, 0,
-            (HWND)m_realparent->GetHWND(), &posRect);
-    }
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_CurrentPosition(
+        /* [in] */ double newVal) = 0;
 
-    if (! m_oleObjectHWND && m_oleInPlaceObject.Ok())
-    {
-        hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
-    }
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_DefaultFrame(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
 
-    if (m_oleObjectHWND)
-    {
-        ::SetActiveWindow(m_oleObjectHWND);
-        ::ShowWindow(m_oleObjectHWND, SW_SHOW);
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_DefaultFrame(
+        /* [in] */ BSTR newVal) = 0;
 
-        this->AssociateHandle(m_oleObjectHWND);
-        this->Reparent(m_realparent);
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Duration(
+        /* [retval][out] */ double __RPC_FAR *pVal) = 0;
 
-        wxWindow* pWnd = m_realparent;
-        int id = m_realparent->GetId();
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_EntryCount(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-        pWnd->Connect(id, wxEVT_SIZE,
-            wxSizeEventHandler(wxActiveX::OnSize), 0, this);
-        pWnd->Connect(id, wxEVT_SET_FOCUS,
-            wxFocusEventHandler(wxActiveX::OnSetFocus), 0, this);
-        pWnd->Connect(id, wxEVT_KILL_FOCUS,
-            wxFocusEventHandler(wxActiveX::OnKillFocus), 0, this);
-    }
-}
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ErrorCode(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-#define HIMETRIC_PER_INCH   2540
-#define MAP_PIX_TO_LOGHIM(x,ppli)   MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ErrorDescription(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
 
-static void PixelsToHimetric(SIZEL &sz)
-{
-    static int logX = 0;
-    static int logY = 0;
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_HasError(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-    if (logY == 0)
-    {
-        // initaliase
-        HDC dc = GetDC(NULL);
-        logX = GetDeviceCaps(dc, LOGPIXELSX);
-        logY = GetDeviceCaps(dc, LOGPIXELSY);
-        ReleaseDC(NULL, dc);
-    };
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_HasMultipleItems(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-#define HIMETRIC_INCH   2540
-#define CONVERT(x, logpixels)   MulDiv(HIMETRIC_INCH, (x), (logpixels))
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ImageSourceHeight(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-    sz.cx = CONVERT(sz.cx, logX);
-    sz.cy = CONVERT(sz.cy, logY);
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ImageSourceWidth(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-#undef CONVERT
-#undef HIMETRIC_INCH
-}
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_InvokeURLs(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_InvokeURLs(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
 
-void wxActiveX::OnSize(wxSizeEvent& event)
-{
-    int w, h;
-    GetParent()->GetClientSize(&w, &h);
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_IsBroadcast(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-    RECT posRect;
-    posRect.left = 0;
-    posRect.top = 0;
-    posRect.right = w;
-    posRect.bottom = h;
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_IsDurationValid(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-    if (w <= 0 && h <= 0)
-        return;
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_LostPackets(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-    // extents are in HIMETRIC units
-    if (m_oleObject.Ok())
-    {
-        SIZEL sz = {w, h};
-        PixelsToHimetric(sz);
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_MarkerCount(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-        SIZEL sz2;
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_OpenState(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-        m_oleObject->GetExtent(DVASPECT_CONTENT, &sz2);
-        if (sz2.cx !=  sz.cx || sz.cy != sz2.cy)
-            m_oleObject->SetExtent(DVASPECT_CONTENT, &sz);
-    };
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_PlayState(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
 
-    if (m_oleInPlaceObject.Ok())
-        m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_PreviewMode(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
 
-    event.Skip();
-}
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_PreviewMode(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
 
-void wxActiveX::OnPaint(wxPaintEvent& WXUNUSED(event))
-{
-    wxPaintDC dc(this);
-    // Draw only when control is windowless or deactivated
-    if (m_viewObject)
-    {
-        dc.BeginDrawing();
-        int w, h;
-        GetParent()->GetSize(&w, &h);
-        RECT posRect;
-        posRect.left = 0;
-        posRect.top = 0;
-        posRect.right = w;
-        posRect.bottom = h;
-
-        ::RedrawWindow(m_oleObjectHWND, NULL, NULL, RDW_INTERNALPAINT);
-        RECTL *prcBounds = (RECTL *) &posRect;
-        m_viewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL,
-            (HDC)dc.GetHDC(), prcBounds, NULL, NULL, 0);
-
-        dc.EndDrawing();
-    }
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ReadyState(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ReceivedPackets(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ReceptionQuality(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_RecoveredPackets(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SAMIFileName(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SAMIFileName(
+        /* [in] */ BSTR newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SAMILang(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SAMILang(
+        /* [in] */ BSTR newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SAMIStyle(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
 
-//  We've got this one I think
-//    event.Skip();
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SAMIStyle(
+        /* [in] */ BSTR newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SelectionEnd(
+        /* [retval][out] */ double __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SelectionEnd(
+        /* [in] */ double newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SelectionStart(
+        /* [retval][out] */ double __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SelectionStart(
+        /* [in] */ double newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendErrorEvents(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendErrorEvents(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendKeyboardEvents(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendKeyboardEvents(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendMouseClickEvents(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendMouseClickEvents(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendMouseMoveEvents(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendMouseMoveEvents(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendOpenStateChangeEvents(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendOpenStateChangeEvents(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendPlayStateChangeEvents(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendPlayStateChangeEvents(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendWarningEvents(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendWarningEvents(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SourceLink(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE AboutBox( void) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Cancel( void) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetCodecDescription(
+        /* [in] */ long nCodec,
+        /* [retval][out] */ BSTR __RPC_FAR *pDescription) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetCodecInstalled(
+        /* [in] */ BSTR __RPC_FAR *pstrCodec,
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pIsInstalled) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetCurrentEntry(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetMarkerName(
+        /* [in] */ long nMarker,
+        /* [retval][out] */ BSTR __RPC_FAR *pMarkerName) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetMarkerTime(
+        /* [in] */ long nMarker,
+        /* [retval][out] */ double __RPC_FAR *pMarkerTime) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetMediaInfoString(
+        /* [in] */ long MPMediaInfoType,
+        /* [retval][out] */ BSTR __RPC_FAR *pstrMediaInfo) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Next( void) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Open(
+        BSTR pstrClip) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Pause( void) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Play( void) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Previous( void) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Stop( void) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Rate(
+        /* [retval][out] */ double __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_Rate(
+        /* [in] */ double newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_DisplaySize(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_DisplaySize(
+        /* [in] */ long newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SourceProtocol(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ErrorCorrection(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE FinalConstruct( void) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_AllowChangeDisplaySize(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_AllowChangeDisplaySize(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_AllowScan(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_AllowScan(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_AnimationAtStart(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_AnimationAtStart(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_AudioStream(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_AudioStream(
+        /* [in] */ long newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_AutoRewind(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_AutoRewind(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Balance(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_Balance(
+        /* [in] */ long newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CanPreview(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CanScan(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CaptioningID(
+        /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ClickToPlay(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ClickToPlay(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CodecCount(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CreationDate(
+        /* [retval][out] */ DATE __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CursorType(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_CursorType(
+        /* [in] */ long newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_DisplayBackColor(
+        /* [retval][out] */ VB_OLE_COLOR __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_DisplayBackColor(
+        /* [in] */ VB_OLE_COLOR newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_DisplayForeColor(
+        /* [retval][out] */ VB_OLE_COLOR __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_DisplayForeColor(
+        /* [in] */ VB_OLE_COLOR newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_DisplayMode(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_DisplayMode(
+        /* [in] */ long newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_EnableContextMenu(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_EnableContextMenu(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_EnableFullScreenControls(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_EnableFullScreenControls(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_EnablePositionControls(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_EnablePositionControls(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_EnableTracker(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_EnableTracker(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Language(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_StreamCount(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_TransparentAtStart(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_TransparentAtStart(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_VideoBorder3D(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_VideoBorder3D(
+        /* [in] */ VARIANT_BOOL newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_VideoBorderColor(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_VideoBorderColor(
+        /* [in] */ long newVal) = 0;
+
+    virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_VideoBorderWidth(
+        /* [retval][out] */ long __RPC_FAR *pVal) = 0;
+
+    virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_VideoBorderWidth(
+        /* [in] */ long newVal) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE FastForward( void) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE FastReverse( void) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetCodecURL(
+        /* [retval][out] */ BSTR __RPC_FAR *pstrCodecURL) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetMediaParameter(
+        /* [in] */ long nParam,
+        BSTR szParameterName,
+        /* [retval][out] */ BSTR __RPC_FAR *pstrParameterValue) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetMediaParameterName(
+        /* [in] */ long nParam,
+        long nIndex,
+        /* [retval][out] */ BSTR __RPC_FAR *pstrParameterName) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetMoreInfoURL(
+        /* [retval][out] */ BSTR __RPC_FAR *pstrMoreInfoURL) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetStreamGroup(
+        /* [retval][out] */ BSTR __RPC_FAR *pstrStreamGroup) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetStreamName(
+        /* [retval][out] */ BSTR __RPC_FAR *pstrStreamName) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetStreamSelected(
+        /* [in] */ long nStream,
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *fIsSelected) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IsSoundCardEnabled(
+        /* [retval][out] */ VARIANT_BOOL __RPC_FAR *fIsEnabled) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE SetCurrentEntry(
+        long nValue) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ShowDialog(
+        long nValue) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE StreamSelect(
+        long nSelect) = 0;
+
+    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE OnWindowMessage(
+        UINT msg,
+        WPARAM wParam,
+        LPARAM lParam,
+        LRESULT __RPC_FAR *plResult) = 0;
+};
+
+//---------------------------------------------------------------------------
+// MISC COM INTERFACES
+//---------------------------------------------------------------------------
+typedef enum _FilterState
+{
+    State_Stopped,
+    State_Paused,
+    State_Running
 }
+FILTER_STATE;
 
-void wxActiveX::OnSetFocus(wxFocusEvent& event)
+typedef enum _PinDirection
 {
-    if (m_oleInPlaceActiveObject.Ok())
-        m_oleInPlaceActiveObject->OnFrameWindowActivate(TRUE);
+    PINDIR_INPUT,
+    PINDIR_OUTPUT
+}
+PIN_DIRECTION;
 
-    event.Skip();
+typedef struct _FilterInfo
+{
+    WCHAR        achName[128];
+    struct IFilterGraph *pGraph;
 }
+FILTER_INFO;
 
-void wxActiveX::OnKillFocus(wxFocusEvent& event)
+typedef struct _PinInfo
 {
-    if (m_oleInPlaceActiveObject.Ok())
-        m_oleInPlaceActiveObject->OnFrameWindowActivate(FALSE);
+    struct IBaseFilter *pFilter;
+    PIN_DIRECTION dir;
+    WCHAR achName[128];
+}
+PIN_INFO;
 
-    event.Skip();
+struct IBaseFilter;
+struct IPin;
+struct IEnumFilters;
+typedef struct  _MediaType
+{
+    GUID      majortype;
+    GUID      subtype;
+    BOOL      bFixedSizeSamples;
+    BOOL      bTemporalCompression;
+    ULONG     lSampleSize;
+    GUID      formattype;
+    IUnknown  *pUnk;
+    ULONG     cbFormat;
+    BYTE *pbFormat;
 }
+AM_MEDIA_TYPE;
 
-//###########################################################################
-//
-//
-//  wxAMMediaBackend
-//
-//
-//###########################################################################
+struct IFilterGraph : public IUnknown
+{
+    STDMETHOD(AddFilter)(IBaseFilter *, LPCWSTR) PURE;
+    STDMETHOD(RemoveFilter)(IBaseFilter *) PURE;
+    STDMETHOD(EnumFilters)(IEnumFilters **) PURE;
+    STDMETHOD(FindFilterByName)(LPCWSTR, IBaseFilter **) PURE;
+    STDMETHOD(ConnectDirect)(IPin *, IPin *, const AM_MEDIA_TYPE *) PURE;
+    STDMETHOD(Reconnect)(IPin *) PURE;
+    STDMETHOD(Disconnect)(IPin *) PURE;
+    STDMETHOD(SetDefaultSyncSource)() PURE;
+};
 
-typedef BOOL (WINAPI* LPAMGETERRORTEXT)(HRESULT, wxChar *, DWORD);
+struct IGraphBuilder : public IFilterGraph
+{
+    STDMETHOD(Connect)(IPin *, IPin *) PURE;
+    STDMETHOD(Render)(IPin *) PURE;
+    STDMETHOD(RenderFile)(LPCWSTR, LPCWSTR) PURE;
+    STDMETHOD(AddSourceFilter)(LPCWSTR, LPCWSTR, IBaseFilter **) PURE;
+    STDMETHOD(SetLogFile)(DWORD_PTR) PURE;
+    STDMETHOD(Abort)() PURE;
+    STDMETHOD(ShouldOperationContinue)() PURE;
+};
 
-//cludgy workaround for wx events.  slots would be nice :)
-class WXDLLIMPEXP_MEDIA wxAMMediaEvtHandler : public wxEvtHandler
+struct IReferenceClock;
+struct IEnumPins;
+#define REFERENCE_TIME LONGLONG
+struct IMediaFilter : public IPersist
 {
-public:
-    void OnPaint(wxPaintEvent&);
-    void OnEraseBackground(wxEraseEvent&);
+    STDMETHOD(Stop)( void) PURE;
+    STDMETHOD(Pause)( void) PURE;
+    STDMETHOD(Run)(REFERENCE_TIME tStart) PURE;
+    STDMETHOD(GetState)(DWORD dwMilliSecsTimeout,
+                       FILTER_STATE *State) PURE;
+    STDMETHOD(SetSyncSource)(IReferenceClock *pClock) PURE;
+    STDMETHOD(GetSyncSource)(IReferenceClock **pClock) PURE;
+};
+
+struct IBaseFilter : public IMediaFilter
+{
+    STDMETHOD(EnumPins)(IEnumPins **ppEnum) PURE;
+    STDMETHOD(FindPin)(LPCWSTR Id, IPin **ppPin) PURE;
+    STDMETHOD(QueryFilterInfo)(FILTER_INFO *pInfo) PURE;
+    STDMETHOD(JoinFilterGraph)(IFilterGraph *pGraph, LPCWSTR pName) PURE;
+    STDMETHOD(QueryVendorInfo)(LPWSTR *pVendorInfo) PURE;
 };
 
-class WXDLLIMPEXP_MEDIA wxAMMediaBackend : public wxMediaBackend
+
+//---------------------------------------------------------------------------
+//  wxAMMediaBackend
+//---------------------------------------------------------------------------
+
+typedef BOOL (WINAPI* LPAMGETERRORTEXT)(HRESULT, wxChar *, DWORD);
+
+class WXDLLIMPEXP_MEDIA wxAMMediaBackend : public wxMediaBackendCommonBase
 {
 public:
     wxAMMediaBackend();
@@ -1828,12 +1455,14 @@ public:
     void Cleanup();
 
     void DoGetDownloadProgress(wxLongLong*, wxLongLong*);
+
     virtual wxLongLong GetDownloadProgress()
     {
         wxLongLong progress, total;
         DoGetDownloadProgress(&progress, &total);
         return progress;
     }
+
     virtual wxLongLong GetDownloadTotal()
     {
         wxLongLong progress, total;
@@ -1841,14 +1470,28 @@ public:
         return total;
     }
 
-    wxControl* m_ctrl;
-    wxActiveX* m_pAX;
+    // WinCE helpers
+
+    wxActiveXContainer* m_pAX;
+
+#ifdef __WXWINCE__
+    IWMP* m_pWMP;
+
+    IWMP* GetMP() { return m_pWMP; }
+    IWMP* GetAM() { return m_pWMP; }
+#else
     IActiveMovie* m_pAM;
     IMediaPlayer* m_pMP;
+
+    IMediaPlayer* GetMP() { return m_pMP; }
+    IActiveMovie* GetAM() { return m_pAM; }
+#endif
+
     wxTimer* m_pTimer;
     wxSize m_bestSize;
+
 #ifdef __WXDEBUG__
-    HMODULE m_hQuartzDll;
+    wxDynamicLibrary m_dllQuartz;
     LPAMGETERRORTEXT m_lpAMGetErrorText;
     wxString GetErrorString(HRESULT hrdsv);
 #endif
@@ -1857,20 +1500,18 @@ public:
 };
 
 //---------------------------------------------------------------------------
-//
 //  wxMCIMediaBackend
-//
 //---------------------------------------------------------------------------
 
 //---------------------------------------------------------------------------
 //  MCI Includes
 //---------------------------------------------------------------------------
+#ifndef __WXWINCE__
 #include <mmsystem.h>
 
-class WXDLLIMPEXP_MEDIA wxMCIMediaBackend : public wxMediaBackend
+class WXDLLIMPEXP_MEDIA wxMCIMediaBackend : public wxMediaBackendCommonBase
 {
 public:
-
     wxMCIMediaBackend();
     ~wxMCIMediaBackend();
 
@@ -1915,15 +1556,14 @@ public:
                                      WPARAM wParam, LPARAM lParam);
 
     MCIDEVICEID m_hDev;     //Our MCI Device ID/Handler
-    wxControl* m_ctrl;      //Parent control
     HWND m_hNotifyWnd;      //Window to use for MCI events
     bool m_bVideo;          //Whether or not we have video
 
     DECLARE_DYNAMIC_CLASS(wxMCIMediaBackend)
 };
+#endif
 
 //---------------------------------------------------------------------------
-//
 //  wxQTMediaBackend
 //
 // We don't include Quicktime headers here and define all the types
@@ -1937,8 +1577,8 @@ public:
 //---------------------------------------------------------------------------
 //  QT Includes
 //---------------------------------------------------------------------------
-//#include <qtml.h>                   //Windoze QT include
-//#include <QuickTimeComponents.h>    //Standard QT stuff
+//#include <qtml.h>                   // Windoze QT include
+//#include <QuickTimeComponents.h>    // Standard QT stuff
 #include "wx/dynlib.h"
 
 //---------------------------------------------------------------------------
@@ -1976,36 +1616,42 @@ const OSType VisualMediaCharacteristic = 'eyes';
 #endif
 #endif
 
-struct FSSpec {
+struct FSSpec
+{
     short      vRefNum;
     long       parID;
-    Str255     name;  /*Str63 on mac, Str255 on msw */
+    Str255     name;  // Str63 on mac, Str255 on msw
 };
 
-struct Rect {
+struct Rect
+{
     short      top;
     short      left;
     short      bottom;
     short      right;
 };
 
-struct wide {
+struct wide
+{
     wxInt32    hi;
     wxUint32   lo;
 };
 
-struct TimeRecord {
-    wide       value; /* units */
-    TimeScale  scale; /* units per second */
+struct TimeRecord
+{
+    wide       value; // units
+    TimeScale  scale; // units per second
     TimeBase   base;
 };
 
-struct Point {
+struct Point
+{
     short                           v;
     short                           h;
 };
 
-struct EventRecord {
+struct EventRecord
+{
     wxUint16                       what;
     wxUint32                          message;
     wxUint32                          when;
@@ -2013,7 +1659,8 @@ struct EventRecord {
     wxUint16                  modifiers;
 };
 
-enum {
+enum
+{
     mcTopLeftMovie              = 1,
     mcScaleMovieToFit           = 2,
     mcWithBadge                 = 4,
@@ -2046,7 +1693,7 @@ class WXDLLIMPEXP_MEDIA wxQuickTimeLibrary
 public:
     ~wxQuickTimeLibrary()
     {
-        if(m_dll.IsLoaded())
+        if (m_dll.IsLoaded())
             m_dll.Unload();
     }
 
@@ -2123,7 +1770,6 @@ public:
     wxDL_VOIDMETHOD_DEFINE(DisposeMovieController, (ComponentInstance ci), (ci));
     wxDL_METHOD_DEFINE(int, MCSetVisible, (ComponentInstance m, int b), (m, b), 0);
 
-
     wxDL_VOIDMETHOD_DEFINE(PrePrerollMovie, (Movie m, long t, Fixed r, WXFARPROC p1, void* p2), (m,t,r,p1,p2) );
     wxDL_VOIDMETHOD_DEFINE(PrerollMovie, (Movie m, long t, Fixed r), (m,t,r) );
     wxDL_METHOD_DEFINE(Fixed, GetMoviePreferredRate, (Movie m), (m), 0);
@@ -2153,9 +1799,10 @@ bool wxQuickTimeLibrary::Initialize()
 {
     m_ok = false;
 
-    bool bWasLoggingEnabled = wxLog::EnableLogging(false);    //Turn off the wxDynamicLibrary logging
+    // Turn off the wxDynamicLibrary logging
+    bool bWasLoggingEnabled = wxLog::EnableLogging(false);
 
-    if(!m_dll.Load(wxT("qtmlClient.dll")))
+    if (!m_dll.Load(wxT("qtmlClient.dll")))
     {
         wxLog::EnableLogging(bWasLoggingEnabled);
         return false;
@@ -2223,15 +1870,7 @@ bool wxQuickTimeLibrary::Initialize()
     return true;
 }
 
-//cludgy workaround for wx events.  slots would be nice :)
-class WXDLLIMPEXP_MEDIA wxQTMediaEvtHandler : public wxEvtHandler
-{
-public:
-    void OnPaint(wxPaintEvent&);
-    void OnEraseBackground(wxEraseEvent&);
-};
-
-class WXDLLIMPEXP_MEDIA wxQTMediaBackend : public wxMediaBackend
+class WXDLLIMPEXP_MEDIA wxQTMediaBackend : public wxMediaBackendCommonBase
 {
 public:
     wxQTMediaBackend();
@@ -2275,38 +1914,62 @@ public:
     void FinishLoad();
 
     static void PPRMProc (Movie theMovie, OSErr theErr, void* theRefCon);
-    //TODO: Last param actually long - does this work on 64bit machines?
-    static Boolean MCFilterProc (MovieController theController,
+
+    // TODO: Last param actually long - does this work on 64bit machines?
+    static Boolean MCFilterProc(MovieController theController,
         short action, void *params, LONG_PTR refCon);
 
     static LRESULT CALLBACK QTWndProc(HWND, UINT, WPARAM, LPARAM);
 
     virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags);
 
-    wxSize m_bestSize;              //Original movie size
-    Movie m_movie;    //QT Movie handle/instance
-    wxControl* m_ctrl;              //Parent control
-    bool m_bVideo;                  //Whether or not we have video
-    bool m_bPlaying;                //Whether or not movie is playing
-    wxTimer* m_timer;               //Load or Play timer
-    wxQuickTimeLibrary m_lib;       //DLL to load functions from
-    ComponentInstance m_pMC;        //Movie Controller
+    wxSize m_bestSize;              // Original movie size
+    Movie m_movie;    // QT Movie handle/instance
+    bool m_bVideo;                  // Whether or not we have video
+    bool m_bPlaying;                // Whether or not movie is playing
+    wxTimer* m_timer;               // Load or Play timer
+    wxQuickTimeLibrary m_lib;       // DLL to load functions from
+    ComponentInstance m_pMC;        // Movie Controller
+
+    friend class wxQTMediaEvtHandler;
 
     DECLARE_DYNAMIC_CLASS(wxQTMediaBackend)
 };
 
+// helper to hijack background erasing for the QT window
+class WXDLLIMPEXP_MEDIA wxQTMediaEvtHandler : public wxEvtHandler
+{
+public:
+    wxQTMediaEvtHandler(wxQTMediaBackend *qtb, WXHWND hwnd)
+    {
+        m_qtb = qtb;
+        m_hwnd = hwnd;
+
+        m_qtb->m_ctrl->Connect(m_qtb->m_ctrl->GetId(),
+            wxEVT_ERASE_BACKGROUND,
+            wxEraseEventHandler(wxQTMediaEvtHandler::OnEraseBackground),
+            NULL, this);
+    }
+
+    void OnEraseBackground(wxEraseEvent& event);
+
+private:
+    wxQTMediaBackend *m_qtb;
+    WXHWND m_hwnd;
+
+    DECLARE_NO_COPY_CLASS(wxQTMediaEvtHandler)
+};
+
 
 //===========================================================================
 //  IMPLEMENTATION
 //===========================================================================
 
-//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-//
+//---------------------------------------------------------------------------
 // wxAMMediaBackend
-//
-//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//---------------------------------------------------------------------------
 
-IMPLEMENT_DYNAMIC_CLASS(wxAMMediaBackend, wxMediaBackend);
+IMPLEMENT_DYNAMIC_CLASS(wxAMMediaBackend, wxMediaBackend)
 
 //---------------------------------------------------------------------------
 // Usual debugging macros
@@ -2314,12 +1977,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxAMMediaBackend, wxMediaBackend);
 #ifdef __WXDEBUG__
 #define MAX_ERROR_TEXT_LEN 160
 
-//Get the error string for Active Movie
+// Get the error string for Active Movie
 wxString wxAMMediaBackend::GetErrorString(HRESULT hrdsv)
 {
     wxChar szError[MAX_ERROR_TEXT_LEN];
-    if( m_lpAMGetErrorText != NULL &&
-       (*m_lpAMGetErrorText)(hrdsv, szError, MAX_ERROR_TEXT_LEN) == 0)
+    if ( m_lpAMGetErrorText != NULL &&
+        (*m_lpAMGetErrorText)(hrdsv, szError, MAX_ERROR_TEXT_LEN) == 0)
     {
         return wxString::Format(wxT("DirectShow error \"%s\" \n")
                                      wxT("(numeric %X)\n")
@@ -2366,11 +2029,17 @@ public:
 
     void Notify()
     {
-        if(m_parent->m_pMP)
+        if (m_parent->GetMP())
         {
             MPReadyStateConstants nState;
-            m_parent->m_pMP->get_ReadyState(&nState);
-            if(nState != mpReadyStateLoading)
+
+#ifdef __WXWINCE__ //Cast to long needed for IWMP (??)
+            m_parent->GetMP()->get_ReadyState((long*)&nState);
+#else
+            m_parent->GetMP()->get_ReadyState(&nState);
+#endif
+
+            if (nState != mpReadyStateLoading)
             {
                 Stop();
                 m_parent->FinishLoad();
@@ -2381,12 +2050,11 @@ public:
         {
             IActiveMovie2* pAM2 = NULL;
             ReadyStateConstants nState;
-            if(m_parent->m_pAM->QueryInterface(IID_IActiveMovie2,
-                                              (void**)&pAM2) == 0 &&
-                pAM2->get_ReadyState(&nState) == 0)
+            if (m_parent->GetAM()->QueryInterface(IID_IActiveMovie2, (void**)&pAM2) == 0
+                && pAM2->get_ReadyState(&nState) == 0)
             {
                 pAM2->Release();
-                if(nState != amvLoading)
+                if (nState != amvLoading)
                 {
                     Stop();
                     m_parent->FinishLoad();
@@ -2395,7 +2063,7 @@ public:
             }
             else
             {
-                if(pAM2)
+                if (pAM2)
                     pAM2->Release();
 
                 Stop();
@@ -2403,11 +2071,10 @@ public:
                 delete this;
             }
         }
-
     }
 
 protected:
-    wxAMMediaBackend* m_parent;     //Backend pointer
+    wxAMMediaBackend* m_parent;     // Backend pointer
 };
 
 //---------------------------------------------------------------------------
@@ -2425,28 +2092,21 @@ public:
 
     void Notify()
     {
-        if(m_parent->GetState() == wxMEDIASTATE_STOPPED &&
-           //NB:  Stop events could get triggered by the interface
-           //if ShowPlayerControls is enabled,
-           //so we need this hack here to make an attempt
-           //at it not getting sent - but its far from ideal -
-           //they can still get sent in some cases
-           m_parent->GetPosition() == m_parent->GetDuration())
+       // NB: Stop events could get triggered by the interface
+       // if ShowPlayerControls is enabled, so the "GetPosition == GetDuration"
+       // hack is needed here to make an attempt at it not getting sent
+       // - but its far from ideal - they can still get sent in some cases
+        if (m_parent->GetState() == wxMEDIASTATE_STOPPED &&
+            m_parent->GetPosition() == m_parent->GetDuration())
         {
-            wxMediaEvent theEvent(wxEVT_MEDIA_STOP,
-                                  m_parent->m_ctrl->GetId());
-            m_parent->m_ctrl->ProcessEvent(theEvent);
-
-            if(theEvent.IsAllowed())
+            if ( m_parent->SendStopEvent() )
             {
-                //Seek to beginning of movie
+                // seek to beginning of movie
                 m_parent->wxAMMediaBackend::SetPosition(0);
                 Stop();
 
-                //send the event to our child
-                wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
-                                      m_parent->m_ctrl->GetId());
-                m_parent->m_ctrl->AddPendingEvent(theEvent);
+                // send the event to our child
+                m_parent->QueueFinishEvent();
             }
         }
     }
@@ -2456,7 +2116,7 @@ protected:
 };
 
 
-/*
+#if 0
 // The following is an alternative way - but it doesn't seem
 // to work with the IActiveMovie control - it probably processes
 // its own events
@@ -2474,7 +2134,7 @@ public:
     {
         HRESULT hr;
         IUnknown* pGB;
-        hr = m_pBE->m_pAM->get_FilterGraph(&pGB);
+        hr = m_pBE->GetAM()->get_FilterGraph(&pGB);
         wxASSERT(SUCCEEDED(hr));
         hr = pGB->QueryInterface(IID_IMediaEvent, (void**)&m_pME);
         wxASSERT(SUCCEEDED(hr));
@@ -2489,63 +2149,51 @@ public:
     void Notify()
     {
         LONG        evCode;
-        LONG_PTR    evParam1,
-                    evParam2;
+        LONG_PTR    evParam1, evParam2;
 
-        //
         // DirectShow keeps a list of queued events, and we need
-        // to go through them one by one, stopping at (Hopefully only one)
+        // to go through them one by one, stopping at (hopefully only one)
         // EC_COMPLETE message
-        //
-        while( m_pME->GetEvent(&evCode, &evParam1, &evParam2, 0) == 0 )
+        while ( m_pME->GetEvent(&evCode, &evParam1, &evParam2, 0) == 0 )
         {
             // Cleanup memory that GetEvent allocated
-            HRESULT hr = m_pME->FreeEventParams(evCode,
-                                                evParam1, evParam2);
-            if(hr != 0)
+            HRESULT hr = m_pME->FreeEventParams(evCode, evParam1, evParam2);
+            if (hr != 0)
             {
-                //Even though this makes a messagebox this
-                //is windows where we can do gui stuff in seperate
-                //threads :)
+                // Even though this makes a messagebox, this is Windows,
+                // where we can do GUI stuff in separate threads :)
                 wxFAIL_MSG(m_pBE->GetErrorString(hr));
             }
             // If this is the end of the clip, notify handler
-            else if(1 == evCode) //EC_COMPLETE
+            else if (1 == evCode) // EC_COMPLETE
             {
-                wxMediaEvent theEvent(wxEVT_MEDIA_STOP,
-                                    m_pBE->m_ctrl->GetId());
-                m_pBE->m_ctrl->ProcessEvent(theEvent);
-
-                if(theEvent.IsAllowed())
+                if ( m_pBE->SendStopEvent() )
                 {
                     Stop();
-
-                    //send the event to our child
-                    wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
-                                        m_pBE->m_ctrl->GetId());
-                    m_pBE->m_ctrl->AddPendingEvent(theEvent);
+                    m_pBE->QueueFinishEvent();
                 }
             }
         }
     }
 
 protected:
-    wxAMMediaBackend* m_pBE;     //Backend pointer
-    IMediaEvent* m_pME;          //To determine when to send stop event
+    wxAMMediaBackend* m_pBE;     // Backend pointer
+    IMediaEvent* m_pME;          // To determine when to send stop event
 };
-*/
+#endif
 
 //---------------------------------------------------------------------------
 // wxAMMediaBackend Constructor
 //---------------------------------------------------------------------------
 wxAMMediaBackend::wxAMMediaBackend()
                  :m_pAX(NULL),
+#ifdef __WXWINCE__
+                  m_pWMP(NULL),
+#else
                   m_pAM(NULL),
                   m_pMP(NULL),
-                  m_pTimer(NULL)
-#ifdef __WXDEBUG__
-                 ,m_hQuartzDll(NULL)
 #endif
+                  m_pTimer(NULL)
 {
 }
 
@@ -2554,21 +2202,21 @@ wxAMMediaBackend::wxAMMediaBackend()
 //---------------------------------------------------------------------------
 wxAMMediaBackend::~wxAMMediaBackend()
 {
-    Clear(); //Free memory from Load()
+    // Free memory from Load()
+    Clear();
 
-    if(m_pAX)
+    if (m_pAX)
     {
         m_pAX->DissociateHandle();
         delete m_pAX;
+
+#ifndef __WXWINCE__
         m_pAM->Release();
+#endif
 
-        if(m_pMP)
-            m_pMP->Release();
+        if (GetMP())
+            GetMP()->Release();
     }
-#ifdef __WXDEBUG__
-    if(m_hQuartzDll)
-        ::FreeLibrary(m_hQuartzDll);
-#endif
 }
 
 //---------------------------------------------------------------------------
@@ -2578,8 +2226,11 @@ wxAMMediaBackend::~wxAMMediaBackend()
 //---------------------------------------------------------------------------
 void wxAMMediaBackend::Clear()
 {
-    if(m_pTimer)
+    if (m_pTimer)
+    {
         delete m_pTimer;
+        m_pTimer = NULL;
+    }
 }
 
 //---------------------------------------------------------------------------
@@ -2593,98 +2244,110 @@ bool wxAMMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
                                      const wxValidator& validator,
                                      const wxString& name)
 {
-    // First get the AMGetErrorText procedure in debug
-    // mode for more meaningful messages
+    // First get the AMGetErrorText procedure in
+    // debug mode for more meaningful messages
 #ifdef __WXDEBUG__
-    m_hQuartzDll = ::LoadLibrary(wxT("quartz.dll"));
-    if(m_hQuartzDll)
+    if ( m_dllQuartz.Load(_T("quartz.dll"), wxDL_VERBATIM) )
     {
-            m_lpAMGetErrorText = (LPAMGETERRORTEXT) ::GetProcAddress(
-                m_hQuartzDll,
-            wxString::Format(wxT("AMGetErrorText%s"),
-
-#if wxUSE_UNICODE
-            wxT("W")
-#else
-            wxT("A")
+        m_lpAMGetErrorText = (LPAMGETERRORTEXT)
+                                m_dllQuartz.GetSymbolAorW(wxT("AMGetErrorText"));
+    }
 #endif
+
 #ifdef __WXWINCE__
-                             )
+   CLSID clsid;
+
+   // Try progids first - *.WMP is PocketPC and Mediaplayer.1 is CE.NET
+   // later versions support straight creation from CLSID
+   if (CLSIDFromProgID(L"WPCEOCX.WMP", &clsid) != S_OK &&
+       CLSIDFromProgID(L"MediaPlayer.MediaPlayer.1", &clsid) != S_OK)
+   {
+       clsid = CLSID_MediaPlayer;
+   }
+
+   // While the CLSID is the same as CLSID_MediaPlayer
+   // CE only supports the IWMP interface
+   if ( ::CoCreateInstance(clsid, NULL,
+                                 CLSCTX_INPROC_SERVER,
+                                 IID_IWMP, (void**)&m_pWMP) != 0 )
+   {
+           return false;
+   }
+
 #else
-                             ).mb_str(wxConvLocal)
+   // determine which (if any) media player interface
+   // is available - IMediaPlayer or IActiveMovie
+   if ( ::CoCreateInstance(CLSID_MediaPlayer, NULL,
+                                 CLSCTX_INPROC_SERVER,
+                                 IID_IMediaPlayer, (void**)&m_pMP) != 0 )
+   {
+       if ( ::CoCreateInstance(CLSID_ActiveMovie, NULL,
+                                 CLSCTX_INPROC_SERVER,
+                                 IID_IActiveMovie, (void**)&m_pAM) != 0 )
+       {
+           return false;
+       }
+
+       m_pAM->QueryInterface(IID_IMediaPlayer, (void**)&m_pMP);
+   }
+   else
+   {
+       m_pMP->QueryInterface(IID_IActiveMovie, (void**)&m_pAM);
+   }
 #endif
-                             );
-    }
-#endif
-    // Now determine which (if any) media player interface is
-    // available - IMediaPlayer or IActiveMovie
-    if( ::CoCreateInstance(CLSID_MediaPlayer, NULL,
-                                  CLSCTX_INPROC_SERVER,
-                                  IID_IMediaPlayer, (void**)&m_pMP) != 0 )
-    {
-        if( ::CoCreateInstance(CLSID_ActiveMovie, NULL,
-                                  CLSCTX_INPROC_SERVER,
-                                  IID_IActiveMovie, (void**)&m_pAM) != 0 )
-        return false;
-        m_pAM->QueryInterface(IID_IMediaPlayer, (void**)&m_pMP);
-    }
-    else
-    {
-        m_pMP->QueryInterface(IID_IActiveMovie, (void**)&m_pAM);
-    }
-    //
+
     // Create window
     // By default wxWindow(s) is created with a border -
     // so we need to get rid of those
     //
     // Since we don't have a child window like most other
     // backends, we don't need wxCLIP_CHILDREN
-    //
     if ( !ctrl->wxControl::Create(parent, id, pos, size,
                             (style & ~wxBORDER_MASK) | wxBORDER_NONE,
                             validator, name) )
+    {
         return false;
+    }
 
-    //
-    // Now create the ActiveX container along with the media player
+    // Create the ActiveX container along with the media player
     // interface and query them
-    //
-    m_ctrl = ctrl;
-    m_pAX = new wxActiveX(ctrl,
-                m_pMP ? IID_IMediaPlayer : IID_IActiveMovie,
-                m_pAM);
-
+    m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
+    m_pAX = new wxActiveXContainer(ctrl,
+#ifdef __WXWINCE__
+                IID_IWMP, m_pWMP
+#else
+                m_pMP ? IID_IMediaPlayer : IID_IActiveMovie, m_pAM
+#endif
+                );
 
-    //
-    //  Here we set up wx-specific stuff for the default
-    //  settings wxMediaCtrl says it will stay to
-    //
-    if(m_pMP)
+    // Set up wx-specific stuff for the default
+    // settings wxMediaCtrl says it will conform to (???)
+    if (GetMP())
     {
-        m_pMP->put_DisplaySize(mpFitToSize);
+        GetMP()->put_DisplaySize(mpFitToSize);
+
+#ifndef __WXWINCE__ // Not in CE's IWMP
         // TODO: Unsure what actual effect this has
-        m_pMP->put_WindowlessVideo(VARIANT_TRUE);
+        GetMP()->put_WindowlessVideo(VARIANT_TRUE);
+#endif
     }
+#ifndef __WXWINCE__ // Not in CE's IWMP
     else
-        m_pAM->put_MovieWindowSize(amvDoubleOriginalSize);
+        GetAM()->put_MovieWindowSize(amvDoubleOriginalSize);
+#endif
 
-    //by default true
-    m_pAM->put_AutoStart(VARIANT_FALSE);
-    //by default enabled
+    // by default true
+    GetAM()->put_AutoStart(VARIANT_FALSE);
+
+    // by default enabled
     wxAMMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE);
-    //by default with AM only 0.5
+
+    // by default with AM only 0.5
     wxAMMediaBackend::SetVolume(1.0);
 
-    // My problem with this was only with a previous patch, probably the
-    // third rewrite fixed it as a side-effect. In fact, the erase
-    // background style of drawing not only works now, but is much better
-    // than paint-based updates (the paint event handler flickers if the
-    // wxMediaCtrl shares a sizer with another child window, or is on a
-    // notebook)
-    //  - Greg Hazel
-    m_ctrl->Connect(m_ctrl->GetId(), wxEVT_ERASE_BACKGROUND,
-        wxEraseEventHandler(wxAMMediaEvtHandler::OnEraseBackground),
-        NULL, (wxEvtHandler*) this);
+    // don't erase the background of our control window
+    // so that resizing is a bit smoother
+    m_ctrl->SetBackgroundStyle(wxBG_STYLE_CUSTOM);
 
     // success
     return true;
@@ -2703,11 +2366,10 @@ bool wxAMMediaBackend::Load(const wxString& fileName)
 //---------------------------------------------------------------------------
 bool wxAMMediaBackend::Load(const wxURI& location)
 {
-    //  Turn off loading from a proxy as user
-    //  may have set it previously
+    // Turn off loading from a proxy, as user may have set it previously
     INSPlay* pPlay = NULL;
-    m_pAM->QueryInterface(IID_INSPlay, (void**) &pPlay);
-    if(pPlay)
+    GetAM()->QueryInterface(IID_INSPlay, (void**) &pPlay);
+    if (pPlay)
     {
         pPlay->put_UseHTTPProxy(VARIANT_FALSE);
         pPlay->Release();
@@ -2723,9 +2385,9 @@ bool wxAMMediaBackend::Load(const wxURI& location, const wxURI& proxy)
 {
     // Set the proxy of the NETSHOW interface
     INSPlay* pPlay = NULL;
-    m_pAM->QueryInterface(IID_INSPlay, (void**) &pPlay);
+    GetAM()->QueryInterface(IID_INSPlay, (void**) &pPlay);
 
-    if(pPlay)
+    if (pPlay)
     {
         pPlay->put_UseHTTPProxy(VARIANT_TRUE);
         pPlay->put_HTTPProxyHost(wxBasicString(proxy.GetServer()).Get());
@@ -2744,20 +2406,21 @@ bool wxAMMediaBackend::Load(const wxURI& location, const wxURI& proxy)
 //---------------------------------------------------------------------------
 bool wxAMMediaBackend::DoLoad(const wxString& location)
 {
-    Clear(); //Clear up previously allocated memory
+    //Clear up previously allocated memory
+    Clear();
 
     HRESULT hr;
 
-    // Play the movie the normal way through the embedded
-    // WMP.  Supposively Open is better in theory because
+    // Play the movie the normal way through the embedded WMP.
+    // Supposedly, Open is better in theory because
     // the docs say its async and put_FileName is not -
-    // but in practice they both seem to be async anyway
-    if(m_pMP)
-        hr = m_pMP->Open( wxBasicString(location).Get() );
+    // but in practice they both appear to be async anyway
+    if (GetMP())
+        hr = GetMP()->Open( wxBasicString(location).Get() );
     else
-        hr = m_pAM->put_FileName( wxBasicString(location).Get() );
+        hr = GetAM()->put_FileName( wxBasicString(location).Get() );
 
-    if(FAILED(hr))
+    if (FAILED(hr))
     {
         wxAMLOG(hr);
         return false;
@@ -2767,6 +2430,7 @@ bool wxAMMediaBackend::DoLoad(const wxString& location)
     // the user plays before the media is loaded
     m_pTimer = new wxAMLoadTimer(this);
     m_pTimer->Start(20);
+
     return true;
 }
 
@@ -2781,30 +2445,15 @@ bool wxAMMediaBackend::DoLoad(const wxString& location)
 //---------------------------------------------------------------------------
 void wxAMMediaBackend::FinishLoad()
 {
-    //Get the original video size
-    m_pAM->get_ImageSourceWidth((long*)&m_bestSize.x);
-    m_pAM->get_ImageSourceHeight((long*)&m_bestSize.y);
+    // Get the original video size
+    GetAM()->get_ImageSourceWidth((long*)&m_bestSize.x);
+    GetAM()->get_ImageSourceHeight((long*)&m_bestSize.y);
 
-    //
-    //Start the play timer to catch stop events
-    //Previous load timer cleans up itself
-    //
+    // Start the play timer to catch stop events
+    // Previous load timer cleans up itself
     m_pTimer = new wxAMPlayTimer(this);
 
-    //Here, if the parent of the control has a sizer - we
-    //tell it to recalculate the size of this control since
-    //the user opened a separate media file
-    //
-    m_ctrl->InvalidateBestSize();
-    m_ctrl->GetParent()->Layout();
-    m_ctrl->GetParent()->Refresh();
-    m_ctrl->GetParent()->Update();
-    m_ctrl->SetSize(m_ctrl->GetSize());
-
-    //Send event to our children
-    wxMediaEvent theEvent(wxEVT_MEDIA_LOADED,
-                            m_ctrl->GetId());
-    m_ctrl->AddPendingEvent(theEvent);
+    NotifyMovieLoaded();
 }
 
 //---------------------------------------------------------------------------
@@ -2815,26 +2464,26 @@ bool wxAMMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
     // Note that IMediaPlayer doesn't have a statusbar by
     // default but IActiveMovie does - so lets try to keep
     // the interface consistant
-    if(!flags)
+    if (!flags)
     {
-        m_pAM->put_Enabled(VARIANT_FALSE);
-        m_pAM->put_ShowControls(VARIANT_FALSE);
-        if(m_pMP)
-            m_pMP->put_ShowStatusBar(VARIANT_FALSE);
+        GetAM()->put_Enabled(VARIANT_FALSE);
+        GetAM()->put_ShowControls(VARIANT_FALSE);
+        if (GetMP())
+            GetMP()->put_ShowStatusBar(VARIANT_FALSE);
     }
     else
     {
-        m_pAM->put_Enabled(VARIANT_TRUE);
-        m_pAM->put_ShowControls(VARIANT_TRUE);
+        GetAM()->put_Enabled(VARIANT_TRUE);
+        GetAM()->put_ShowControls(VARIANT_TRUE);
 
-        m_pAM->put_ShowPositionControls(
+        GetAM()->put_ShowPositionControls(
                 (flags & wxMEDIACTRLPLAYERCONTROLS_STEP) ?
                 VARIANT_TRUE : VARIANT_FALSE);
 
-        if(m_pMP)
+        if (GetMP())
         {
-            m_pMP->put_ShowStatusBar(VARIANT_TRUE);
-            m_pMP->put_ShowAudioControls(
+            GetMP()->put_ShowStatusBar(VARIANT_TRUE);
+            GetMP()->put_ShowAudioControls(
                 (flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME) ?
                 VARIANT_TRUE : VARIANT_FALSE);
         }
@@ -2853,40 +2502,20 @@ bool wxAMMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
 //---------------------------------------------------------------------------
 bool wxAMMediaBackend::Play()
 {
-    // if the movie isn't done loading yet
-    // go into an sync getmessage loop until it is :)
-    if(m_pMP)
-    {
-        MPReadyStateConstants nState;
-        m_pMP->get_ReadyState(&nState);
-        while(nState == mpReadyStateLoading && wxYieldIfNeeded())
-        {
-          m_pMP->get_ReadyState(&nState);
-        }
-    }
-    else
-    {
-        IActiveMovie2* pAM2;
-        ReadyStateConstants nState;
-        if(m_pAM->QueryInterface(IID_IActiveMovie2, (void**)&pAM2) == 0 &&
-            pAM2->get_ReadyState(&nState) == 0)
-        {
-            while(nState == amvLoading && wxYieldIfNeeded())
-            {
-                pAM2->get_ReadyState(&nState);
-            }
-            pAM2->Release();
-        }
-    }
-
-    //Actually try to play the movie
-    HRESULT hr = m_pAM->Run();
-    if(SUCCEEDED(hr))
+    // Actually try to play the movie, even though it may not be loaded yet.
+#ifdef __WXWINCE__
+    HRESULT hr = m_pWMP->Play();
+#else
+    HRESULT hr = GetAM()->Run();
+#endif
+    if (SUCCEEDED(hr))
     {
         m_pTimer->Start(20);
         return true;
     }
+
     wxAMLOG(hr);
+
     return false;
 }
 
@@ -2897,10 +2526,12 @@ bool wxAMMediaBackend::Play()
 //---------------------------------------------------------------------------
 bool wxAMMediaBackend::Pause()
 {
-    HRESULT hr = m_pAM->Pause();
-    if(SUCCEEDED(hr))
+    HRESULT hr = GetAM()->Pause();
+    if (SUCCEEDED(hr))
         return true;
+
     wxAMLOG(hr);
+
     return false;
 }
 
@@ -2911,16 +2542,19 @@ bool wxAMMediaBackend::Pause()
 //---------------------------------------------------------------------------
 bool wxAMMediaBackend::Stop()
 {
-    HRESULT hr = m_pAM->Stop();
-    if(SUCCEEDED(hr))
+    HRESULT hr = GetAM()->Stop();
+    if (SUCCEEDED(hr))
     {
-        //Seek to beginning
+        // Seek to beginning
         wxAMMediaBackend::SetPosition(0);
-        //Stop stop event timer
+
+        // Stop stop event timer
         m_pTimer->Stop();
         return true;
     }
+
     wxAMLOG(hr);
+
     return false;
 }
 
@@ -2935,10 +2569,9 @@ bool wxAMMediaBackend::Stop()
 //---------------------------------------------------------------------------
 bool wxAMMediaBackend::SetPosition(wxLongLong where)
 {
-    HRESULT hr = m_pAM->put_CurrentPosition(
-                        ((LONGLONG)where.GetValue()) / 1000.0
-                                     );
-    if(FAILED(hr))
+    HRESULT hr = GetAM()->put_CurrentPosition(
+                        ((LONGLONG)where.GetValue()) / 1000.0 );
+    if (FAILED(hr))
     {
         wxAMLOG(hr);
         return false;
@@ -2956,14 +2589,14 @@ bool wxAMMediaBackend::SetPosition(wxLongLong where)
 wxLongLong wxAMMediaBackend::GetPosition()
 {
     double outCur;
-    HRESULT hr = m_pAM->get_CurrentPosition(&outCur);
-    if(FAILED(hr))
+    HRESULT hr = GetAM()->get_CurrentPosition(&outCur);
+    if (FAILED(hr))
     {
         wxAMLOG(hr);
         return 0;
     }
 
-    //h,m,s,milli - outdur is in 1 second (double)
+    // h,m,s,milli - outdur is in 1 second (double)
     outCur *= 1000;
     wxLongLong ll;
     ll.Assign(outCur);
@@ -2980,14 +2613,15 @@ wxLongLong wxAMMediaBackend::GetPosition()
 //---------------------------------------------------------------------------
 double wxAMMediaBackend::GetVolume()
 {
-        long lVolume;
-    HRESULT hr = m_pAM->get_Volume(&lVolume);
-        if(FAILED(hr))
-        {
-            wxAMLOG(hr);
-            return 0.0;
+    long lVolume;
+    HRESULT hr = GetAM()->get_Volume(&lVolume);
+    if (FAILED(hr))
+    {
+        wxAMLOG(hr);
+        return 0.0;
     }
-    return pow(10.0, lVolume/2000.0);
+
+    return pow(10.0, lVolume / 2000.0);
 }
 
 //---------------------------------------------------------------------------
@@ -2999,15 +2633,16 @@ double wxAMMediaBackend::GetVolume()
 //---------------------------------------------------------------------------
 bool wxAMMediaBackend::SetVolume(double dVolume)
 {
-    //pow(10.0, -80.0) to correct 0 == -INF
-    long lVolume = (long)(2000.0 * log10(pow(10.0, -80.0)+dVolume));
-    HRESULT hr = m_pAM->put_Volume( lVolume );
-        if(FAILED(hr))
-        {
-            wxAMLOG(hr);
-            return false;
-        }
-        return true;
+    // pow(10.0, -80.0) to correct 0 == -INF
+    long lVolume = (long)(2000.0 * log10( pow( 10.0, -80.0) + dVolume ) );
+    HRESULT hr = GetAM()->put_Volume( lVolume );
+    if (FAILED(hr))
+    {
+        wxAMLOG(hr);
+        return false;
+    }
+
+    return true;
 }
 
 //---------------------------------------------------------------------------
@@ -3023,14 +2658,14 @@ bool wxAMMediaBackend::SetVolume(double dVolume)
 wxLongLong wxAMMediaBackend::GetDuration()
 {
     double outDuration;
-    HRESULT hr = m_pAM->get_Duration(&outDuration);
-    if(FAILED(hr))
+    HRESULT hr = GetAM()->get_Duration(&outDuration);
+    if (FAILED(hr))
     {
         wxAMLOG(hr);
         return 0;
     }
 
-    //h,m,s,milli - outdur is in 1 second (double)
+    // h,m,s,milli - outdur is in 1 second (double)
     outDuration *= 1000;
     wxLongLong ll;
     ll.Assign(outDuration);
@@ -3046,8 +2681,12 @@ wxLongLong wxAMMediaBackend::GetDuration()
 wxMediaState wxAMMediaBackend::GetState()
 {
     StateConstants nState;
-    HRESULT hr = m_pAM->get_CurrentState(&nState);
-    if(FAILED(hr))
+#ifdef __WXWINCE__
+    HRESULT hr = m_pWMP->get_PlayState((long*)&nState);
+#else
+    HRESULT hr = GetAM()->get_CurrentState(&nState);
+#endif
+    if (FAILED(hr))
     {
         wxAMLOG(hr);
         return wxMEDIASTATE_STOPPED;
@@ -3065,12 +2704,13 @@ wxMediaState wxAMMediaBackend::GetState()
 double wxAMMediaBackend::GetPlaybackRate()
 {
     double dRate;
-    HRESULT hr = m_pAM->get_Rate(&dRate);
-    if(FAILED(hr))
+    HRESULT hr = GetAM()->get_Rate(&dRate);
+    if (FAILED(hr))
     {
         wxAMLOG(hr);
         return 0.0;
     }
+
     return dRate;
 }
 
@@ -3082,8 +2722,8 @@ double wxAMMediaBackend::GetPlaybackRate()
 //---------------------------------------------------------------------------
 bool wxAMMediaBackend::SetPlaybackRate(double dRate)
 {
-    HRESULT hr = m_pAM->put_Rate(dRate);
-    if(FAILED(hr))
+    HRESULT hr = GetAM()->put_Rate(dRate);
+    if (FAILED(hr))
     {
         wxAMLOG(hr);
         return false;
@@ -3102,32 +2742,35 @@ bool wxAMMediaBackend::SetPlaybackRate(double dRate)
 void wxAMMediaBackend::DoGetDownloadProgress(wxLongLong* pLoadProgress,
                                              wxLongLong* pLoadTotal)
 {
+#ifndef __WXWINCE__
     LONGLONG loadTotal = 0, loadProgress = 0;
     IUnknown* pFG;
     IAMOpenProgress* pOP;
     HRESULT hr;
-    hr = m_pAM->get_FilterGraph(&pFG);
-    if(SUCCEEDED(hr))
-        {
+    hr = GetAM()->get_FilterGraph(&pFG);
+    if (SUCCEEDED(hr))
+    {
         hr = pFG->QueryInterface(IID_IAMOpenProgress, (void**)&pOP);
-        if(SUCCEEDED(hr))
+        if (SUCCEEDED(hr))
         {
             hr = pOP->QueryProgress(&loadTotal, &loadProgress);
             pOP->Release();
         }
+
         pFG->Release();
     }
 
-    if(SUCCEEDED(hr))
-            {
+    if (SUCCEEDED(hr))
+    {
         *pLoadProgress = loadProgress;
         *pLoadTotal = loadTotal;
-            }
+    }
     else
-            {
-        //When not loading from a URL QueryProgress will return
-        //E_NOINTERFACE or whatever
-        //wxAMFAIL(hr);
+#endif
+    {
+        // When not loading from a URL QueryProgress will return
+        // E_NOINTERFACE or whatever
+        // wxAMFAIL(hr);
         *pLoadProgress = 0;
         *pLoadTotal = 0;
     }
@@ -3153,27 +2796,16 @@ void wxAMMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y),
 {
 }
 
-//---------------------------------------------------------------------------
-// wxAMMediaEvtHandler::OnEraseBackground
-//
-// Tell WX not to erase the background of our control window
-// so that resizing is a bit smoother
-//---------------------------------------------------------------------------
-void wxAMMediaEvtHandler::OnEraseBackground(wxEraseEvent& WXUNUSED(evt))
-{
-}
-
 //---------------------------------------------------------------------------
 // End of wxAMMediaBackend
 //---------------------------------------------------------------------------
 
-//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-//
+//---------------------------------------------------------------------------
 // wxMCIMediaBackend
-//
-//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//---------------------------------------------------------------------------
 
-IMPLEMENT_DYNAMIC_CLASS(wxMCIMediaBackend, wxMediaBackend);
+#ifndef __WXWINCE__
+IMPLEMENT_DYNAMIC_CLASS(wxMCIMediaBackend, wxMediaBackend)
 
 //---------------------------------------------------------------------------
 // Usual debugging macros for MCI returns
@@ -3202,7 +2834,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxMCIMediaBackend, wxMediaBackend);
 // windows - so we provide the declarations for the types we use here
 //---------------------------------------------------------------------------
 
-typedef struct {
+typedef struct
+{
     DWORD_PTR   dwCallback;
 #ifdef MCI_USE_OFFEXT
     POINT   ptOffset;
@@ -3210,9 +2843,11 @@ typedef struct {
 #else
     RECT    rc;
 #endif
-} MCI_DGV_RECT_PARMS;
+}
+MCI_DGV_RECT_PARMS;
 
-typedef struct {
+typedef struct
+{
     DWORD_PTR   dwCallback;
     HWND    hWnd;
 #ifndef _WIN32
@@ -3223,24 +2858,29 @@ typedef struct {
     WORD    wReserved2;
 #endif
     wxChar*   lpstrText;
-} MCI_DGV_WINDOW_PARMS;
+}
+MCI_DGV_WINDOW_PARMS;
 
-typedef struct {
+typedef struct
+{
     DWORD_PTR dwCallback;
     DWORD     dwTimeFormat;
     DWORD     dwAudio;
     DWORD     dwFileFormat;
     DWORD     dwSpeed;
-} MCI_DGV_SET_PARMS;
+}
+MCI_DGV_SET_PARMS;
 
-typedef struct {
+typedef struct
+{
     DWORD_PTR   dwCallback;
     DWORD   dwItem;
     DWORD   dwValue;
     DWORD   dwOver;
     wxChar*   lpstrAlgorithm;
     wxChar*   lpstrQuality;
-} MCI_DGV_SETAUDIO_PARMS;
+}
+MCI_DGV_SETAUDIO_PARMS;
 
 //---------------------------------------------------------------------------
 // wxMCIMediaBackend Constructor
@@ -3254,12 +2894,12 @@ wxMCIMediaBackend::wxMCIMediaBackend() : m_hNotifyWnd(NULL), m_bVideo(false)
 //---------------------------------------------------------------------------
 // wxMCIMediaBackend Destructor
 //
-// We close the mci device - note that there may not be an mci device here,
+// We close the MCI device - note that there may not be an MCI device here,
 // or it may fail - but we don't really care, since we're destructing
 //---------------------------------------------------------------------------
 wxMCIMediaBackend::~wxMCIMediaBackend()
 {
-    if(m_hNotifyWnd)
+    if (m_hNotifyWnd)
     {
         mciSendCommand(m_hDev, MCI_CLOSE, 0, 0);
         DestroyWindow(m_hNotifyWnd);
@@ -3270,7 +2910,7 @@ wxMCIMediaBackend::~wxMCIMediaBackend()
 //---------------------------------------------------------------------------
 // wxMCIMediaBackend::Create
 //
-// Here we just tell wxMediaCtrl that mci does exist (which it does, on all
+// Here we just tell wxMediaCtrl that MCI does exist (which it does, on all
 // msw systems, at least in some form dating back to win16 days)
 //---------------------------------------------------------------------------
 bool wxMCIMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
@@ -3281,19 +2921,18 @@ bool wxMCIMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
                                      const wxValidator& validator,
                                      const wxString& name)
 {
-    //
     // Create window
     // By default wxWindow(s) is created with a border -
     // so we need to get rid of those, and create with
     // wxCLIP_CHILDREN, so that if the driver/backend
     // is a child window, it refereshes properly
-    //
     if ( !ctrl->wxControl::Create(parent, id, pos, size,
                             (style & ~wxBORDER_MASK) | wxBORDER_NONE | wxCLIP_CHILDREN,
                             validator, name) )
         return false;
 
-    m_ctrl = ctrl;
+    m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
+
     return true;
 }
 
@@ -3305,61 +2944,52 @@ bool wxMCIMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
 //---------------------------------------------------------------------------
 bool wxMCIMediaBackend::Load(const wxString& fileName)
 {
-    //
-    //if the user already called load close the previous MCI device
-    //
-    if(m_hNotifyWnd)
+    // if the user already called load close the previous MCI device
+    if (m_hNotifyWnd)
     {
         mciSendCommand(m_hDev, MCI_CLOSE, 0, 0);
         DestroyWindow(m_hNotifyWnd);
         m_hNotifyWnd = NULL;
     }
 
-    //
-    //Opens a file and has MCI select a device.  Normally you'd put
-    //MCI_OPEN_TYPE in addition to MCI_OPEN_ELEMENT - however if you
-    //omit this it tells MCI to select the device instead.  This is
-    //good because we have no reliable way of "enumerating" the devices
-    //in MCI
-    //
+    // Opens a file and has MCI select a device.  Normally you'd put
+    // MCI_OPEN_TYPE in addition to MCI_OPEN_ELEMENT - however if you
+    // omit this it tells MCI to select the device instead. This is good
+    // because we have no reliable way of "enumerating" the devices in MCI
     MCI_OPEN_PARMS openParms;
     openParms.lpstrElementName = (wxChar*) fileName.c_str();
 
-    if ( mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT,
+    if (mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT,
                         (DWORD)(LPVOID)&openParms) != 0)
+    {
         return false;
+    }
 
     m_hDev = openParms.wDeviceID;
 
-    //
-    //Now set the time format for the device to milliseconds
-    //
+    // set the time format for the device to milliseconds
     MCI_SET_PARMS setParms;
     setParms.dwCallback = 0;
     setParms.dwTimeFormat = MCI_FORMAT_MILLISECONDS;
 
     if (mciSendCommand(m_hDev, MCI_SET, MCI_SET_TIME_FORMAT,
                          (DWORD)(LPVOID)&setParms) != 0)
+    {
         return false;
+    }
 
-    //
-    //Now tell the MCI device to display the video in our wxMediaCtrl
-    //
+    // tell the MCI device to display the video in our wxMediaCtrl
     MCI_DGV_WINDOW_PARMS windowParms;
     windowParms.hWnd = (HWND)m_ctrl->GetHandle();
 
     m_bVideo = (mciSendCommand(m_hDev, MCI_WINDOW,
-                               0x00010000L, //MCI_DGV_WINDOW_HWND
+                               0x00010000L, // MCI_DGV_WINDOW_HWND
                                (DWORD)(LPVOID)&windowParms) == 0);
 
-    //
-    // Create a hidden window and register to handle
-    // MCI events
+    // Create a hidden window and register to handle MCI events
     // Note that wxCanvasClassName is already registered
     // and used by all wxWindows and normal wxControls
-    //
-    m_hNotifyWnd = ::CreateWindow
-                    (
+    m_hNotifyWnd = ::CreateWindow(
                         wxCanvasClassName,
                         NULL,
                         0, 0, 0, 0,
@@ -3367,10 +2997,9 @@ bool wxMCIMediaBackend::Load(const wxString& fileName)
                         (HWND) NULL,
                         (HMENU)NULL,
                         wxGetInstance(),
-                        (LPVOID) NULL
-                    );
+                        (LPVOID)NULL );
 
-    if(!m_hNotifyWnd)
+    if (!m_hNotifyWnd)
     {
         wxLogSysError( wxT("Could not create hidden needed for ")
                        wxT("registering for MCI events!")  );
@@ -3381,21 +3010,7 @@ bool wxMCIMediaBackend::Load(const wxString& fileName)
     wxSetWindowProc(m_hNotifyWnd, wxMCIMediaBackend::NotifyWndProc);
     wxSetWindowUserData(m_hNotifyWnd, this);
 
-    //
-    //Here, if the parent of the control has a sizer - we
-    //tell it to recalculate the size of this control since
-    //the user opened a separate media file
-    //
-    m_ctrl->InvalidateBestSize();
-    m_ctrl->GetParent()->Layout();
-    m_ctrl->GetParent()->Refresh();
-    m_ctrl->GetParent()->Update();
-    m_ctrl->SetSize(m_ctrl->GetSize());
-
-    //send loaded event
-    wxMediaEvent theEvent(wxEVT_MEDIA_LOADED,
-                            m_ctrl->GetId());
-    m_ctrl->AddPendingEvent(theEvent);
+    NotifyMovieLoaded();
 
     return true;
 }
@@ -3405,7 +3020,7 @@ bool wxMCIMediaBackend::Load(const wxString& fileName)
 //
 // MCI doesn't support URLs directly (?)
 //
-// TODO:  Use wxURL/wxFileSystem and mmioInstallProc
+// TODO: Use wxURL/wxFileSystem and mmioInstallProc
 //---------------------------------------------------------------------------
 bool wxMCIMediaBackend::Load(const wxURI& WXUNUSED(location))
 {
@@ -3427,10 +3042,10 @@ bool wxMCIMediaBackend::Play()
     MCI_PLAY_PARMS playParms;
     playParms.dwCallback = (DWORD)m_hNotifyWnd;
 
-    bool bOK = ( mciSendCommand(m_hDev, MCI_PLAY, MCI_NOTIFY,
-                            (DWORD)(LPVOID)&playParms) == 0 );
+    bool bOK = (mciSendCommand(m_hDev, MCI_PLAY, MCI_NOTIFY,
+                            (DWORD)(LPVOID)&playParms) == 0);
 
-    if(bOK)
+    if (bOK)
         m_ctrl->Show(m_bVideo);
 
     return bOK;
@@ -3473,9 +3088,9 @@ wxMediaState wxMCIMediaBackend::GetState()
     mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
                          (DWORD)(LPVOID)&statusParms);
 
-    if(statusParms.dwReturn == MCI_MODE_PAUSE)
+    if (statusParms.dwReturn == MCI_MODE_PAUSE)
         return wxMEDIASTATE_PAUSED;
-    else if(statusParms.dwReturn == MCI_MODE_PLAY)
+    else if (statusParms.dwReturn == MCI_MODE_PLAY)
         return wxMEDIASTATE_PLAYING;
     else
         return wxMEDIASTATE_STOPPED;
@@ -3493,22 +3108,25 @@ bool wxMCIMediaBackend::SetPosition(wxLongLong where)
 {
     MCI_SEEK_PARMS seekParms;
     seekParms.dwCallback = 0;
+
 #if wxUSE_LONGLONG_NATIVE && !wxUSE_LONGLONG_WX
     seekParms.dwTo = (DWORD)where.GetValue();
-#else /* wxUSE_LONGLONG_WX */
-    /* no way to return it in one piece */
-    wxASSERT( where.GetHi()==0 );
+#else // wxUSE_LONGLONG_WX
+    // no way to return it in one piece
+    wxASSERT( where.GetHi() == 0 );
     seekParms.dwTo = (DWORD)where.GetLo();
-#endif /* wxUSE_LONGLONG_* */
+#endif
 
-    //device was playing?
+    // device was playing?
     bool bReplay = GetState() == wxMEDIASTATE_PLAYING;
 
-    if( mciSendCommand(m_hDev, MCI_SEEK, MCI_TO,
+    if ( mciSendCommand(m_hDev, MCI_SEEK, MCI_TO,
                        (DWORD)(LPVOID)&seekParms) != 0)
+    {
         return false;
+    }
 
-    //If the device was playing, resume it
+    // If the device was playing, resume it
     if (bReplay)
         return Play();
     else
@@ -3528,7 +3146,9 @@ wxLongLong wxMCIMediaBackend::GetPosition()
 
     if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
                        (DWORD)(LPSTR)&statusParms) != 0)
+    {
         return 0;
+    }
 
     return statusParms.dwReturn;
 }
@@ -3543,11 +3163,13 @@ double wxMCIMediaBackend::GetVolume()
 {
     MCI_STATUS_PARMS statusParms;
     statusParms.dwCallback = 0;
-    statusParms.dwItem = 0x4019; //MCI_DGV_STATUS_VOLUME
+    statusParms.dwItem = 0x4019; // MCI_DGV_STATUS_VOLUME
 
     if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
                        (DWORD)(LPSTR)&statusParms) != 0)
+    {
         return 0;
+    }
 
     return ((double)statusParms.dwReturn) / 1000.0;
 }
@@ -3562,17 +3184,20 @@ bool wxMCIMediaBackend::SetVolume(double dVolume)
 {
     MCI_DGV_SETAUDIO_PARMS audioParms;
     audioParms.dwCallback = 0;
-    audioParms.dwItem = 0x4002; //MCI_DGV_SETAUDIO_VOLUME
+    audioParms.dwItem = 0x4002; // MCI_DGV_SETAUDIO_VOLUME
     audioParms.dwValue = (DWORD) (dVolume * 1000.0);
     audioParms.dwOver = 0;
     audioParms.lpstrAlgorithm = NULL;
     audioParms.lpstrQuality = NULL;
 
-    if (mciSendCommand(m_hDev, 0x0873, //MCI_SETAUDIO
-                        //MCI_DGV_SETAUDIO+(_ITEM | _VALUE)
+    if (mciSendCommand(m_hDev, 0x0873, // MCI_SETAUDIO
+                        // MCI_DGV_SETAUDIO + (_ITEM | _VALUE)
                         0x00800000L | 0x01000000L,
                        (DWORD)(LPSTR)&audioParms) != 0)
+    {
         return false;
+    }
+
     return true;
 }
 
@@ -3588,7 +3213,9 @@ wxLongLong wxMCIMediaBackend::GetDuration()
 
     if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
                         (DWORD)(LPSTR)&statusParms) != 0)
+    {
         return 0;
+    }
 
     return statusParms.dwReturn;
 }
@@ -3598,23 +3225,22 @@ wxLongLong wxMCIMediaBackend::GetDuration()
 //
 // Moves the window to a location
 //---------------------------------------------------------------------------
-void wxMCIMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y),
-                                       int w,           int h)
+void wxMCIMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int w, int h)
 {
     if (m_hNotifyWnd && m_bVideo)
     {
-        MCI_DGV_RECT_PARMS putParms; //ifdefed MCI_DGV_PUT_PARMS
+        MCI_DGV_RECT_PARMS putParms; // ifdefed MCI_DGV_PUT_PARMS
         memset(&putParms, 0, sizeof(MCI_DGV_RECT_PARMS));
         putParms.rc.bottom = h;
         putParms.rc.right = w;
 
-        //wxStackWalker will crash and burn here on assert
-        //and mci doesn't like 0 and 0 for some reason (out of range )
-        //so just don't it in that case
-        if(w || h)
+        // wxStackWalker will crash and burn here on assert
+        // and MCI doesn't like 0 and 0 for some reason (out of range)
+        // so just don't it in that case
+        if (w || h)
         {
             wxMCIVERIFY( mciSendCommand(m_hDev, MCI_PUT,
-                                   0x00040000L, //MCI_DGV_PUT_DESTINATION
+                                   0x00040000L, // MCI_DGV_PUT_DESTINATION
                                    (DWORD)(LPSTR)&putParms) );
         }
     }
@@ -3627,17 +3253,18 @@ void wxMCIMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y),
 //---------------------------------------------------------------------------
 wxSize wxMCIMediaBackend::GetVideoSize() const
 {
-    if(m_bVideo)
+    if (m_bVideo)
     {
-        MCI_DGV_RECT_PARMS whereParms; //ifdefed MCI_DGV_WHERE_PARMS
+        MCI_DGV_RECT_PARMS whereParms; // ifdefed MCI_DGV_WHERE_PARMS
 
         wxMCIVERIFY( mciSendCommand(m_hDev, MCI_WHERE,
-                       0x00020000L, //MCI_DGV_WHERE_SOURCE
+                       0x00020000L, // MCI_DGV_WHERE_SOURCE
                        (DWORD)(LPSTR)&whereParms) );
 
         return wxSize(whereParms.rc.right, whereParms.rc.bottom);
     }
-    return wxSize(0,0);
+
+    return wxSize(0, 0);
 }
 
 //---------------------------------------------------------------------------
@@ -3657,15 +3284,16 @@ double wxMCIMediaBackend::GetPlaybackRate()
 //---------------------------------------------------------------------------
 bool wxMCIMediaBackend::SetPlaybackRate(double WXUNUSED(dRate))
 {
-/*
+#if 0
     MCI_WAVE_SET_SAMPLESPERSEC
     MCI_DGV_SET_PARMS setParms;
     setParms.dwSpeed = (DWORD) (dRate * 1000.0);
 
     return (mciSendCommand(m_hDev, MCI_SET,
-                       0x00020000L, //MCI_DGV_SET_SPEED
+                       0x00020000L, // MCI_DGV_SET_SPEED
                        (DWORD)(LPSTR)&setParms) == 0);
-*/
+#endif
+
     return false;
 }
 
@@ -3689,49 +3317,41 @@ LRESULT CALLBACK wxMCIMediaBackend::OnNotifyWndProc(HWND hWnd, UINT nMsg,
                                                   WPARAM wParam,
                                                   LPARAM lParam)
 {
-    if(nMsg == MM_MCINOTIFY)
+    if (nMsg == MM_MCINOTIFY)
     {
         wxASSERT(lParam == (LPARAM) m_hDev);
-        if(wParam == MCI_NOTIFY_SUCCESSFUL && lParam == (LPARAM)m_hDev)
+        if (wParam == MCI_NOTIFY_SUCCESSFUL && lParam == (LPARAM)m_hDev)
         {
-            wxMediaEvent theEvent(wxEVT_MEDIA_STOP, m_ctrl->GetId());
-            m_ctrl->ProcessEvent(theEvent);
-
-            if(theEvent.IsAllowed())
+            if ( SendStopEvent() )
             {
-                wxMCIVERIFY( mciSendCommand(m_hDev, MCI_SEEK,
-                                            MCI_SEEK_TO_START, 0) );
-
-                //send the event to our child
-                wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
-                                      m_ctrl->GetId());
-                m_ctrl->ProcessEvent(theEvent);
+                wxMCIVERIFY( mciSendCommand(m_hDev, MCI_SEEK, MCI_SEEK_TO_START, 0) );
+                QueueFinishEvent();
             }
         }
     }
     return DefWindowProc(hWnd, nMsg, wParam, lParam);
 }
+#endif // __WXWINCE__
 
-//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-//
+//---------------------------------------------------------------------------
 // wxQTMediaBackend
 //
-// TODO: Use a less cludgy way to pause/get state/set state
+// TODO: Use a less kludgy way to pause/get state/set state
 // FIXME: Greg Hazel reports that sometimes files that cannot be played
-// with this backend are treated as playable anyway - not verifyed though.
-//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// with this backend are treated as playable anyway - not verified though.
+//---------------------------------------------------------------------------
 
-IMPLEMENT_DYNAMIC_CLASS(wxQTMediaBackend, wxMediaBackend);
+IMPLEMENT_DYNAMIC_CLASS(wxQTMediaBackend, wxMediaBackend)
 
-//Time between timer calls - this is the Apple recommondation to the TCL
-//team I believe
+// Time between timer calls - this is the Apple recommendation to the TCL
+// team I believe
 #define MOVIE_DELAY 20
 
 #include "wx/timer.h"
 
 
 //---------------------------------------------------------------------------
-//          wxQTLoadTimer
+// wxQTLoadTimer
 //
 //  QT, esp. QT for Windows is very picky about how you go about
 //  async loading.  If you were to go through a Windows message loop
@@ -3748,12 +3368,12 @@ public:
     void Notify()
     {
         m_pLib->MoviesTask(m_movie, 0);
-        //kMovieLoadStatePlayable
-        if(m_pLib->GetMovieLoadState(m_movie) >= 10000)
-    {
+        // kMovieLoadStatePlayable
+        if (m_pLib->GetMovieLoadState(m_movie) >= 10000)
+        {
             m_parent->FinishLoad();
             delete this;
-    }
+        }
     }
 
 protected:
@@ -3764,7 +3384,7 @@ protected:
 
 
 // --------------------------------------------------------------------------
-//          wxQTPlayTimer - Handle Asyncronous Playing
+// wxQTPlayTimer - Handle Asyncronous Playing
 //
 // 1) Checks to see if the movie is done, and if not continues
 //    streaming the movie
@@ -3795,35 +3415,28 @@ public:
         m_pLib->MoviesTask(m_movie, 0);
 
         //
-        //  Handle the stop event - if the movie has reached
-        //  the end, notify our handler
+        // Handle the stop event - if the movie has reached
+        // the end, notify our handler
         //
         //  m_bPlaying == !(Stopped | Paused)
         //
         if (m_parent->m_bPlaying)
         {
-            if(m_pLib->IsMovieDone(m_movie))
+            if (m_pLib->IsMovieDone(m_movie))
             {
-                wxMediaEvent theEvent(wxEVT_MEDIA_STOP,
-                                      m_parent->m_ctrl->GetId());
-                m_parent->m_ctrl->ProcessEvent(theEvent);
-
-                if(theEvent.IsAllowed())
+                if ( m_parent->SendStopEvent() )
                 {
                     m_parent->Stop();
                     wxASSERT(m_pLib->GetMoviesError() == noErr);
 
-                    //send the event to our child
-                    wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
-                                          m_parent->m_ctrl->GetId());
-                    m_parent->m_ctrl->AddPendingEvent(theEvent);
+                    m_parent->QueueFinishEvent();
                 }
             }
         }
     }
 
 protected:
-    Movie m_movie;                  //Our movie instance
+    Movie m_movie;                  // Our movie instance
     wxQTMediaBackend* m_parent;     //Backend pointer
     wxQuickTimeLibrary* m_pLib;         //Interfaces
 };
@@ -3851,6 +3464,7 @@ LRESULT CALLBACK wxQTMediaBackend::QTWndProc(HWND hWnd, UINT nMsg,
     EventRecord theEvent;
     pThis->m_lib.NativeEventToMacEvent(&msg, &theEvent);
     pThis->m_lib.MCIsPlayerEvent(pThis->m_pMC, &theEvent);
+
     return pThis->m_ctrl->MSWWindowProc(nMsg, wParam, lParam);
 }
 
@@ -3875,17 +3489,20 @@ wxQTMediaBackend::wxQTMediaBackend()
 //---------------------------------------------------------------------------
 wxQTMediaBackend::~wxQTMediaBackend()
 {
-    if(m_movie)
+    if (m_movie)
         Cleanup();
 
-    if(m_lib.IsOk())
+    if (m_lib.IsOk())
     {
-        if(m_pMC)
+        if (m_pMC)
         {
             m_lib.DisposeMovieController(m_pMC);
-        //    m_pMC = NULL;
+            // m_pMC = NULL;
         }
 
+        // destroy wxQTMediaEvtHandler we pushed on it
+        m_ctrl->PopEventHandler(true);
+
         m_lib.DestroyPortAssociation(
             (CGrafPtr)m_lib.GetNativeWindowPort(m_ctrl->GetHWND()));
 
@@ -3910,43 +3527,40 @@ bool wxQTMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
                                      const wxValidator& validator,
                                      const wxString& name)
 {
-    if(!m_lib.Initialize())
+    if (!m_lib.Initialize())
         return false;
 
     int nError = m_lib.InitializeQTML(0);
     if (nError != noErr)    //-2093 no dll
     {
-        wxFAIL_MSG(wxString::Format(wxT("Couldn't Initialize Quicktime-%i"),
-                                    nError));
+        wxFAIL_MSG(wxString::Format(wxT("Couldn't Initialize Quicktime-%i"), nError));
         return false;
     }
+
     m_lib.EnterMovies();
 
-    //
     // Create window
     // By default wxWindow(s) is created with a border -
     // so we need to get rid of those
     //
     // Since we don't have a child window like most other
     // backends, we don't need wxCLIP_CHILDREN
-    //
     if ( !ctrl->wxControl::Create(parent, id, pos, size,
                             (style & ~wxBORDER_MASK) | wxBORDER_NONE,
                             validator, name) )
+    {
         return false;
+    }
 
-
-    m_ctrl = ctrl; //assign the control to our member
+    m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
 
     // Create a port association for our window so we
     // can use it as a WindowRef
     m_lib.CreatePortAssociation(m_ctrl->GetHWND(), NULL, 0L);
 
-    //Part of a suggestion from Greg Hazel to repaint
-    //movie when idle
-    m_ctrl->Connect(m_ctrl->GetId(), wxEVT_ERASE_BACKGROUND,
-        wxEraseEventHandler(wxQTMediaEvtHandler::OnEraseBackground),
-        NULL, (wxEvtHandler*) this);
+    // Part of a suggestion from Greg Hazel
+    // to repaint movie when idle
+    m_ctrl->PushEventHandler(new wxQTMediaEvtHandler(this, m_ctrl->GetHWND()));
 
     // done
     return true;
@@ -3963,46 +3577,52 @@ bool wxQTMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
 //---------------------------------------------------------------------------
 bool wxQTMediaBackend::Load(const wxString& fileName)
 {
-    if(m_movie)
+    if (m_movie)
         Cleanup();
 
+    bool result = true;
+    OSErr err = noErr;
     short movieResFile = 0; //= 0 because of annoying VC6 warning
     FSSpec sfFile;
 
-    if (m_lib.NativePathNameToFSSpec ((char*) (const char*) fileName.mb_str(),
-                                &sfFile, 0) != noErr)
-        return false;
+    err = m_lib.NativePathNameToFSSpec(
+        (char*) (const char*) fileName.mb_str(),
+        &sfFile, 0);
+    result = (err == noErr);
 
-    if (m_lib.OpenMovieFile (&sfFile, &movieResFile, fsRdPerm) != noErr)
-        return false;
+    if (result)
+    {
+        err = m_lib.OpenMovieFile(&sfFile, &movieResFile, fsRdPerm);
+        result = (err == noErr);
+    }
 
-    short movieResID = 0;
-    Str255 movieName;
+    if (result)
+    {
+        short movieResID = 0;
+        Str255 movieName;
 
-    OSErr err = m_lib.NewMovieFromFile (
+        err = m_lib.NewMovieFromFile(
                    &m_movie,
                    movieResFile,
                    &movieResID,
                    movieName,
                    newMovieActive,
-                   NULL
-                ); //wasChanged
-
-    //m_lib.GetMoviesStickyError() because it may not find the
-    //proper codec and play black video and other strange effects,
-    //not to mention mess up the dynamic backend loading scheme
-    //of wxMediaCtrl - so it just does what the QuickTime player does
-    if(err == noErr  && m_lib.GetMoviesStickyError() == noErr)
-    {
-    m_lib.CloseMovieFile (movieResFile);
-
-        FinishLoad();
-        return true;
+                   NULL ); // wasChanged
+        result = (err == noErr && m_lib.GetMoviesStickyError() == noErr);
+
+        // check m_lib.GetMoviesStickyError() because it may not find the
+        // proper codec and play black video and other strange effects,
+        // not to mention mess up the dynamic backend loading scheme
+        // of wxMediaCtrl - so it just does what the QuickTime player does
+        if (result)
+        {
+            m_lib.CloseMovieFile(movieResFile);
+            FinishLoad();
+        }
     }
-    else
-        return false;
-}
 
+    return result;
+}
 
 //---------------------------------------------------------------------------
 // wxQTMediaBackend::PPRMProc (static)
@@ -4023,12 +3643,11 @@ void wxQTMediaBackend::PPRMProc (Movie theMovie,
 
     long lTime = pBE->m_lib.GetMovieTime(theMovie,NULL);
     Fixed rate = pBE->m_lib.GetMoviePreferredRate(theMovie);
-    pBE->m_lib.PrerollMovie(theMovie,lTime,rate);
+    pBE->m_lib.PrerollMovie(theMovie, lTime, rate);
     pBE->m_timer = new wxQTLoadTimer(pBE->m_movie, pBE, &pBE->m_lib);
     pBE->m_timer->Start(MOVIE_DELAY);
 }
 
-
 //---------------------------------------------------------------------------
 // wxQTMediaBackend::Load (URL Version)
 //
@@ -4042,7 +3661,7 @@ void wxQTMediaBackend::PPRMProc (Movie theMovie,
 //---------------------------------------------------------------------------
 bool wxQTMediaBackend::Load(const wxURI& location)
 {
-    if(m_movie)
+    if (m_movie)
         Cleanup();
 
     wxString theURI = location.BuildURI();
@@ -4052,10 +3671,10 @@ bool wxQTMediaBackend::Load(const wxURI& location)
 
     m_lib.BlockMove(theURI.mb_str(), *theHandle, theURI.length() + 1);
 
-    //create the movie from the handle that refers to the URI
+    // create the movie from the handle that refers to the URI
     OSErr err = m_lib.NewMovieFromDataRef(&m_movie, newMovieActive |
                                                     newMovieAsyncOK
-                                                    /*|newMovieIdleImportOK*/,
+                                                    /* | newMovieIdleImportOK */,
                                 NULL, theHandle,
                                 URLDataHandlerSubType);
 
@@ -4064,7 +3683,7 @@ bool wxQTMediaBackend::Load(const wxURI& location)
     if (err == noErr)
     {
         long timeNow;
-    Fixed playRate;
+        Fixed playRate;
 
         timeNow = m_lib.GetMovieTime(m_movie, NULL);
         wxASSERT(m_lib.GetMoviesError() == noErr);
@@ -4072,25 +3691,24 @@ bool wxQTMediaBackend::Load(const wxURI& location)
         playRate = m_lib.GetMoviePreferredRate(m_movie);
         wxASSERT(m_lib.GetMoviesError() == noErr);
 
-        //
-        //  Note that the callback here is optional,
-        //  but without it PrePrerollMovie can be buggy
-        //  (see Apple ml).  Also, some may wonder
-        //  why we need this at all - this is because
-        //  Apple docs say QuickTime streamed movies
-        //  require it if you don't use a Movie Controller,
-        //  which we don't by default.
+        // Note that the callback here is optional,
+        // but without it PrePrerollMovie can be buggy
+        // (see Apple ml).  Also, some may wonder
+        // why we need this at all - this is because
+        // Apple docs say QuickTime streamed movies
+        // require it if you don't use a Movie Controller,
+        // which we don't by default.
         //
         m_lib.PrePrerollMovie(m_movie, timeNow, playRate,
                               (WXFARPROC)wxQTMediaBackend::PPRMProc,
                               (void*)this);
+
         return true;
     }
     else
         return false;
 }
 
-
 //---------------------------------------------------------------------------
 // wxQTMediaBackend::FinishLoad
 //
@@ -4107,21 +3725,20 @@ void wxQTMediaBackend::FinishLoad()
     // Create the playing/streaming timer
     m_timer = new wxQTPlayTimer(m_movie, (wxQTMediaBackend*) this, &m_lib);
     wxASSERT(m_timer);
+
     m_timer->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS);
 
-    //get the real size of the movie
+    // get the real size of the movie
     Rect outRect;
-    memset(&outRect, 0, sizeof(Rect)); //for annoying VC6 warning
+    memset(&outRect, 0, sizeof(Rect)); // suppress annoying VC6 warning
     m_lib.GetMovieNaturalBoundsRect (m_movie, &outRect);
     wxASSERT(m_lib.GetMoviesError() == noErr);
 
     m_bestSize.x = outRect.right - outRect.left;
     m_bestSize.y = outRect.bottom - outRect.top;
 
-    //
     // Handle the movie GWorld
-    //
-    if(m_pMC)
+    if (m_pMC)
     {
         Point thePoint;
         thePoint.h = thePoint.v = 0;
@@ -4138,29 +3755,11 @@ void wxQTMediaBackend::FinishLoad()
                        NULL);
     }
 
-    //
     // Set the movie to millisecond precision
-    //
     m_lib.SetMovieTimeScale(m_movie, 1000);
     wxASSERT(m_lib.GetMoviesError() == noErr);
 
-    //
-    //Here, if the parent of the control has a sizer - we
-    //tell it to recalculate the size of this control since
-    //the user opened a separate media file
-    //
-    m_ctrl->InvalidateBestSize();
-    m_ctrl->GetParent()->Layout();
-    m_ctrl->GetParent()->Refresh();
-    m_ctrl->GetParent()->Update();
-    m_ctrl->SetSize(m_ctrl->GetSize());
-
-    //loaded - note that MoviesTask must and will be called before this
-    //by the previous timer since this gets appended to the event list after
-    //the timer's first go
-    wxMediaEvent theEvent(wxEVT_MEDIA_LOADED,
-                            m_ctrl->GetId());
-    m_ctrl->AddPendingEvent(theEvent);
+    NotifyMovieLoaded();
 }
 
 //---------------------------------------------------------------------------
@@ -4179,6 +3778,7 @@ bool wxQTMediaBackend::Play()
 {
     m_lib.StartMovie(m_movie);
     m_bPlaying = true;
+
     return m_lib.GetMoviesError() == noErr;
 }
 
@@ -4192,6 +3792,7 @@ bool wxQTMediaBackend::Pause()
 {
     m_bPlaying = false;
     m_lib.StopMovie(m_movie);
+
     return m_lib.GetMoviesError() == noErr;
 }
 
@@ -4207,17 +3808,16 @@ bool wxQTMediaBackend::Stop()
     m_bPlaying = false;
 
     m_lib.StopMovie(m_movie);
-    if(m_lib.GetMoviesError() != noErr)
-        return false;
+    if (m_lib.GetMoviesError() == noErr)
+        m_lib.GoToBeginningOfMovie(m_movie);
 
-    m_lib.GoToBeginningOfMovie(m_movie);
     return m_lib.GetMoviesError() == noErr;
 }
 
 //---------------------------------------------------------------------------
 // wxQTMediaBackend::GetPlaybackRate
 //
-// 1) Get the movie playback rate from ::GetMovieRate
+// Get the movie playback rate from ::GetMovieRate
 //---------------------------------------------------------------------------
 double wxQTMediaBackend::GetPlaybackRate()
 {
@@ -4227,11 +3827,12 @@ double wxQTMediaBackend::GetPlaybackRate()
 //---------------------------------------------------------------------------
 // wxQTMediaBackend::SetPlaybackRate
 //
-// 1) Convert dRate to Fixed and Set the movie rate through SetMovieRate
+// Convert dRate to Fixed and Set the movie rate through SetMovieRate
 //---------------------------------------------------------------------------
 bool wxQTMediaBackend::SetPlaybackRate(double dRate)
 {
     m_lib.SetMovieRate(m_movie, (Fixed) (dRate * 0x10000));
+
     return m_lib.GetMoviesError() == noErr;
 }
 
@@ -4243,12 +3844,12 @@ bool wxQTMediaBackend::SetPlaybackRate(double dRate)
 //---------------------------------------------------------------------------
 bool wxQTMediaBackend::SetPosition(wxLongLong where)
 {
-    //NB:  For some reason SetMovieTime does not work
-    //correctly with the Quicktime Windows SDK (6)
-    //From Muskelkatermann at the wxForum
-    //http://www.solidsteel.nl/users/wxwidgets/viewtopic.php?t=2957
-    //RN - note that I have not verified this but there
-    //is no harm in calling SetMovieTimeValue instead
+    // NB:  For some reason SetMovieTime does not work
+    // correctly with the Quicktime Windows SDK (6)
+    // From Muskelkatermann at the wxForum
+    // http://www.solidsteel.nl/users/wxwidgets/viewtopic.php?t=2957
+    // RN - note that I have not verified this but there
+    // is no harm in calling SetMovieTimeValue instead
 #if 0
     TimeRecord theTimeRecord;
     memset(&theTimeRecord, 0, sizeof(TimeRecord));
@@ -4259,10 +3860,8 @@ bool wxQTMediaBackend::SetPosition(wxLongLong where)
 #else
     m_lib.SetMovieTimeValue(m_movie, where.GetLo());
 #endif
-    if (m_lib.GetMoviesError() != noErr)
-        return false;
 
-    return true;
+    return (m_lib.GetMoviesError() == noErr);
 }
 
 //---------------------------------------------------------------------------
@@ -4296,10 +3895,10 @@ double wxQTMediaBackend::GetVolume()
     short sVolume = m_lib.GetMovieVolume(m_movie);
     wxASSERT(m_lib.GetMoviesError() == noErr);
 
-    if(sVolume & (128 << 8)) //negative - no sound
+    if (sVolume & (128 << 8)) //negative - no sound
         return 0.0;
 
-    return sVolume/256.0;
+    return sVolume / 256.0;
 }
 
 //---------------------------------------------------------------------------
@@ -4336,14 +3935,14 @@ wxLongLong wxQTMediaBackend::GetDuration()
 //---------------------------------------------------------------------------
 // wxQTMediaBackend::GetState
 //
-// Determines the current state - if we are at the beginning we
-// are stopped
+// Determines the current state:
+// if we are at the beginning, then we are stopped
 //---------------------------------------------------------------------------
 wxMediaState wxQTMediaBackend::GetState()
 {
-    if (m_bPlaying == true)
+    if (m_bPlaying)
         return wxMEDIASTATE_PLAYING;
-    else if ( !m_movie || wxQTMediaBackend::GetPosition() == 0)
+    else if ( !m_movie || wxQTMediaBackend::GetPosition() == 0 )
         return wxMEDIASTATE_STOPPED;
     else
         return wxMEDIASTATE_PAUSED;
@@ -4360,15 +3959,15 @@ void wxQTMediaBackend::Cleanup()
 {
     m_bPlaying = false;
 
-    if(m_timer)
+    if (m_timer)
     {
-    delete m_timer;
-    m_timer = NULL;
+        delete m_timer;
+        m_timer = NULL;
     }
 
     m_lib.StopMovie(m_movie);
 
-    if(m_pMC)
+    if (m_pMC)
     {
         Point thePoint;
         thePoint.h = thePoint.v = 0;
@@ -4387,22 +3986,24 @@ void wxQTMediaBackend::Cleanup()
 //---------------------------------------------------------------------------
 bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
 {
-    if(m_pMC)
+    if (m_pMC)
     {
-        //restore old wndproc
+        // restore old wndproc
         wxSetWindowProc((HWND)m_ctrl->GetHWND(), wxWndProc);
         m_lib.DisposeMovieController(m_pMC);
         m_pMC = NULL;
-        m_bestSize.y -= 16; //movie controller height
+
+        // movie controller height
+        m_bestSize.y -= 16;
     }
 
-    if(flags && m_movie)
+    if (flags && m_movie)
     {
         Rect rect;
         wxRect wxrect = m_ctrl->GetClientRect();
 
-        //make room for controller
-        if(wxrect.width < 320)
+        // make room for controller
+        if (wxrect.width < 320)
             wxrect.width = 320;
 
         rect.top = (short)wxrect.y;
@@ -4410,56 +4011,45 @@ bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
         rect.right = (short)(rect.left + wxrect.width);
         rect.bottom = (short)(rect.top + wxrect.height);
 
-        if(!m_pMC)
+        if (!m_pMC)
         {
             m_pMC = m_lib.NewMovieController(m_movie, &rect, mcTopLeftMovie |
                                 //                        mcScaleMovieToFit |
                                 //                        mcWithBadge |
                                                         mcWithFrame);
-            m_lib.MCDoAction(m_pMC, 32, (void*)true); //mcActionSetKeysEnabled
+            m_lib.MCDoAction(m_pMC, 32, (void*)true); // mcActionSetKeysEnabled
             m_lib.MCSetActionFilterWithRefCon(m_pMC,
                 (WXFARPROC)wxQTMediaBackend::MCFilterProc, (void*)this);
-            m_bestSize.y += 16; //movie controller height
-
-            //
-            // By default the movie controller uses its own color
-            // pallette for the movie which can be bad on some files -
-            // so turn it off.  Also turn off its frame/border for
-            // the movie
-            //
-            // Also we take care of a couple of the interface flags here
-            //
+            m_bestSize.y += 16; // movie controller height
+
+            // By default the movie controller uses its own colour palette
+            // for the movie which can be bad on some files, so turn it off.
+            // Also turn off its frame / border for the movie
+            // Also take care of a couple of the interface flags here
             long mcFlags = 0;
             m_lib.MCDoAction(m_pMC, 39/*mcActionGetFlags*/, (void*)&mcFlags);
-            mcFlags |= (  //(1<<0)/*mcFlagSuppressMovieFrame*/ |
-                 (1<<3)/*mcFlagsUseWindowPalette*/
-                   | ((flags & wxMEDIACTRLPLAYERCONTROLS_STEP)
-                      ? 0 : (1<<1)/*mcFlagSuppressStepButtons*/)
-                   | ((flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME)
-                      ? 0 : (1<<2)/*mcFlagSuppressSpeakerButton*/)
-     //              | (1<<4) /*mcFlagDontInvalidate*/ //if we take care of repainting ourselves
-                      );
+
+            mcFlags |=
+                // (1<< 0) /*mcFlagSuppressMovieFrame*/ |
+                (1<< 3) /*mcFlagsUseWindowPalette*/
+                | ((flags & wxMEDIACTRLPLAYERCONTROLS_STEP)
+                      ? 0 : (1<< 1) /*mcFlagSuppressStepButtons*/)
+                | ((flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME)
+                      ? 0 : (1<< 2) /*mcFlagSuppressSpeakerButton*/)
+//              | (1<< 4) /*mcFlagDontInvalidate*/ // if we take care of repainting ourselves
+                      ;
+
             m_lib.MCDoAction(m_pMC, 38/*mcActionSetFlags*/, (void*)mcFlags);
 
-            //intercept the wndproc of our control window
-            wxSetWindowProc((HWND)m_ctrl->GetHWND(),
-                wxQTMediaBackend::QTWndProc);
+            // intercept the wndproc of our control window
+            wxSetWindowProc((HWND)m_ctrl->GetHWND(), wxQTMediaBackend::QTWndProc);
 
-            //set the user data of our window
+            // set the user data of our window
             wxSetWindowUserData((HWND)m_ctrl->GetHWND(), this);
         }
     }
 
-    //
-    //Here, if the parent of the control has a sizer - we
-    //tell it to recalculate the size of this control since
-    //the user opened a separate media file
-    //
-    m_ctrl->InvalidateBestSize();
-    m_ctrl->GetParent()->Layout();
-    m_ctrl->GetParent()->Refresh();
-    m_ctrl->GetParent()->Update();
-    m_ctrl->SetSize(m_ctrl->GetSize());
+    NotifyMovieSizeChanged();
 
     return m_lib.GetMoviesError() == noErr;
 }
@@ -4469,32 +4059,40 @@ bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
 //
 // Callback for when the movie controller recieves a message
 //---------------------------------------------------------------------------
-Boolean
-wxQTMediaBackend::MCFilterProc(MovieController WXUNUSED(theController),
+Boolean wxQTMediaBackend::MCFilterProc(MovieController WXUNUSED(theController),
                                short action,
                                void * WXUNUSED(params),
                                LONG_PTR refCon)
 {
-    if(action != 1) //don't process idle events
-    {
-        wxQTMediaBackend* pThis = (wxQTMediaBackend*)refCon;
+// NB: potential optimisation
+//    if (action == 1)
+//        return 0;
 
-        switch(action)
-        {
-        case 8: //play button triggered - MC will set movie to opposite state
-                //of current - playing ? paused : playing
+    wxQTMediaBackend* pThis = (wxQTMediaBackend*)refCon;
+
+    switch (action)
+    {
+    case 1:
+        // don't process idle events
+        break;
+
+    case 8:
+        // play button triggered - MC will set movie to opposite state
+        // of current - playing ? paused : playing
+        if (pThis)
             pThis->m_bPlaying = !(pThis->m_bPlaying);
 
-            // NB: Sometimes it doesn't redraw properly -
-            // if you click on the button but don't move the mouse
-            // the button will not change its state until you move
-            // mcActionDraw and Refresh/Update combo do nothing
-            // to help this unfortunately
-            break;
-        default:
-            break;
-        }
+        // NB: Sometimes it doesn't redraw properly -
+        // if you click on the button but don't move the mouse
+        // the button will not change its state until you move
+        // mcActionDraw and Refresh/Update combo do nothing
+        // to help this unfortunately
+        break;
+
+    default:
+        break;
     }
+
     return 0;
 }
 
@@ -4515,12 +4113,12 @@ wxSize wxQTMediaBackend::GetVideoSize() const
 //---------------------------------------------------------------------------
 void wxQTMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int w, int h)
 {
-    if(m_movie)
+    if (m_movie)
     {
-        //make room for controller
-        if(m_pMC)
+        // make room for controller
+        if (m_pMC)
         {
-            if(w < 320)
+            if (w < 320)
                 w = 320;
 
             Rect theRect = {0, 0, (short)h, (short)w};
@@ -4529,7 +4127,7 @@ void wxQTMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int w, int h)
         else
         {
             Rect theRect = {0, 0, (short)h, (short)w};
-        m_lib.SetMovieBox(m_movie, &theRect);
+            m_lib.SetMovieBox(m_movie, &theRect);
         }
 
         wxASSERT(m_lib.GetMoviesError() == noErr);
@@ -4542,34 +4140,36 @@ void wxQTMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int w, int h)
 // Suggestion from Greg Hazel to repaint the movie when idle
 // (on pause also)
 //
-// TODO:  We may be repainting too much here - under what exact circumstances
-// do we need this?  I think Move also repaints correctly for the Movie
+// TODO: We may be repainting too much here - under what exact circumstances
+// do we need this? I think Move also repaints correctly for the Movie
 // Controller, so in that instance we don't need this either
 //---------------------------------------------------------------------------
 void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt)
 {
-    wxQTMediaBackend* qtb = (wxQTMediaBackend*)this;
-    wxQuickTimeLibrary* m_pLib = &(qtb->m_lib);
+    wxQuickTimeLibrary& m_pLib = m_qtb->m_lib;
 
-    if(qtb->m_pMC)
+    if ( m_qtb->m_pMC )
     {
-        //repaint movie controller
-        m_pLib->MCDoAction(qtb->m_pMC, 2 /*mcActionDraw*/,
-            m_pLib->GetNativeWindowPort(qtb->m_ctrl->GetHWND())
-                           );
+        // repaint movie controller
+        m_pLib.MCDoAction(m_qtb->m_pMC, 2 /*mcActionDraw*/,
+                            m_pLib.GetNativeWindowPort(m_hwnd));
     }
-    else if(qtb->m_movie)
+    else if ( m_qtb->m_movie )
     {
-        CGrafPtr port = (CGrafPtr)m_pLib->GetNativeWindowPort
-        (qtb->m_ctrl->GetHWND());
+        // no movie controller
+        CGrafPtr port = (CGrafPtr)m_pLib.GetNativeWindowPort(m_hwnd);
 
-        m_pLib->BeginUpdate(port);
-        m_pLib->UpdateMovie(qtb->m_movie);
-        wxASSERT(m_pLib->GetMoviesError() == noErr);
-        m_pLib->EndUpdate(port);
+        m_pLib.BeginUpdate(port);
+        m_pLib.UpdateMovie(m_qtb->m_movie);
+        wxASSERT(m_pLib.GetMoviesError() == noErr);
+        m_pLib.EndUpdate(port);
+    }
+    else
+    {
+        // no movie
+        // let the system repaint the window
+        evt.Skip();
     }
-
-    evt.Skip(); //repaint with window background (TODO: maybe !m_movie?)
 }
 
 //---------------------------------------------------------------------------
@@ -4577,12 +4177,10 @@ void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt)
 //---------------------------------------------------------------------------
 
 //in source file that contains stuff you don't directly use
-#include <wx/html/forcelnk.h>
-FORCE_LINK_ME(basewxmediabackends);
+#include "wx/html/forcelnk.h"
+FORCE_LINK_ME(basewxmediabackends)
 
 //---------------------------------------------------------------------------
 //  End wxMediaCtrl Compilation Guard and this file
 //---------------------------------------------------------------------------
 #endif //wxUSE_MEDIACTRL
-
-