GME
13
|
00001 // GMEOLEPanel.cpp : implementation file 00002 // 00003 00004 #include "stdafx.h" 00005 #include "gme.h" 00006 #include "GMEOLEPanel.h" 00007 #include "GMEOLEError.h" 00008 #include "GMEView.h" 00009 #include "MainFrm.h" 00010 #include "GMEEventLogger.h" 00011 00012 00013 #ifdef _DEBUG 00014 #define new DEBUG_NEW 00015 #undef THIS_FILE 00016 static char THIS_FILE[] = __FILE__; 00017 #endif 00018 00020 // CGMEOLEPanel 00021 00022 IMPLEMENT_DYNCREATE(CGMEOLEPanel, CCmdTarget) 00023 00024 CGMEOLEPanel::CGMEOLEPanel() 00025 { 00026 EnableAutomation(); 00027 } 00028 00029 CGMEOLEPanel::~CGMEOLEPanel() 00030 { 00031 } 00032 00033 00034 void CGMEOLEPanel::OnFinalRelease() 00035 { 00036 // When the last reference for an automation object is released 00037 // OnFinalRelease is called. The base class will automatically 00038 // deletes the object. Add additional cleanup required for your 00039 // object before calling the base class. 00040 00041 CCmdTarget::OnFinalRelease(); 00042 } 00043 00044 00045 BEGIN_MESSAGE_MAP(CGMEOLEPanel, CCmdTarget) 00046 //{{AFX_MSG_MAP(CGMEOLEPanel) 00047 // NOTE - the ClassWizard will add and remove mapping macros here. 00048 //}}AFX_MSG_MAP 00049 END_MESSAGE_MAP() 00050 00051 BEGIN_DISPATCH_MAP(CGMEOLEPanel, CCmdTarget) 00052 //{{AFX_DISPATCH_MAP(CGMEOLEPanel) 00053 DISP_PROPERTY_EX(CGMEOLEPanel, "Name", GetName, SetName, VT_BSTR) 00054 DISP_PROPERTY_EX(CGMEOLEPanel, "Visible", GetVisible, SetVisible, VT_BOOL) 00055 DISP_PROPERTY_EX(CGMEOLEPanel, "Interface", GetInterface, SetInterface, VT_DISPATCH) 00056 //}}AFX_DISPATCH_MAP 00057 END_DISPATCH_MAP() 00058 00059 // Note: we add support for IID_IGMEOLEPanel to support typesafe binding 00060 // from VBA. This IID must match the GUID that is attached to the 00061 // dispinterface in the .ODL file. 00062 00063 // {C047FAEB-7AE7-40fb-8C5C-90C73DAD4BC6} 00064 //static const GUID <<name>> = 00065 //{ 0xc047faeb, 0x7ae7, 0x40fb, { 0x8c, 0x5c, 0x90, 0xc7, 0x3d, 0xad, 0x4b, 0xc6 } }; 00066 00067 00068 BEGIN_INTERFACE_MAP(CGMEOLEPanel, CCmdTarget) 00069 INTERFACE_PART(CGMEOLEPanel, __uuidof(IGMEOLEPanel), Dual) 00070 DUAL_ERRORINFO_PART(CGMEOLEPanel) 00071 END_INTERFACE_MAP() 00072 00074 // CGMEOLEPanel message handlers 00075 00076 BSTR CGMEOLEPanel::GetName() 00077 { 00078 CGMEEventLogger::LogGMEEvent("CGMEOLEPanel::GetName()\r\n"); 00079 00080 PRECONDITION_VALID_PANEL 00081 00082 return m_name.AllocSysString(); 00083 } 00084 00085 void CGMEOLEPanel::SetName(LPCTSTR) 00086 { 00087 CGMEEventLogger::LogGMEEvent("CGMEOLEPanel::SetName()\r\n"); 00088 00089 SetNotSupported(); 00090 } 00091 00092 BOOL CGMEOLEPanel::GetVisible() 00093 { 00094 CGMEEventLogger::LogGMEEvent("CGMEOLEPanel::GetVisible()\r\n"); 00095 00096 PRECONDITION_VALID_PANEL 00097 00098 return m_control->IsVisible(); 00099 } 00100 00101 void CGMEOLEPanel::SetVisible(BOOL bNewValue) 00102 { 00103 CGMEEventLogger::LogGMEEvent("CGMEOLEPanel::SetVisible()\r\n"); 00104 00105 PRECONDITION_VALID_PANEL 00106 00107 CMainFrame::theInstance->ShowPane(m_control, bNewValue, FALSE, FALSE); 00108 } 00109 00110 IDispatch* CGMEOLEPanel::GetInterface() 00111 { 00112 CGMEEventLogger::LogGMEEvent("CGMEOLEPanel::GetInterface()\r\n"); 00113 00114 PRECONDITION_VALID_PANEL 00115 if (m_interf == NULL) 00116 AfxThrowOleDispatchException(ID_ERROR_PTR_INVALID, _T("GUI panel is invalid.")); 00117 /* 00118 IDispatch* interf = NULL; 00119 CSizingControlBar * scb = dynamic_cast<CSizingControlBar *>( m_control); 00120 if( scb) interf = scb->GetInterface(); 00121 */ 00122 m_interf->AddRef(); 00123 return m_interf; 00124 } 00125 00126 void CGMEOLEPanel::SetInterface(IDispatch* intf) 00127 { 00128 CGMEEventLogger::LogGMEEvent("CGMEOLEPanel::SetInterface()\r\n"); 00129 00130 SetNotSupported(); 00131 } 00132 00133 00134 DELEGATE_DUAL_INTERFACE(CGMEOLEPanel, Dual) 00135 00136 // Implement ISupportErrorInfo to indicate we support the 00137 // OLE Automation error handler. 00138 IMPLEMENT_DUAL_ERRORINFO(CGMEOLEPanel, __uuidof(IGMEOLEPanel)) 00139 00140 00141 STDMETHODIMP CGMEOLEPanel::XDual::get_Name(BSTR* name) 00142 { 00143 METHOD_PROLOGUE(CGMEOLEPanel, Dual) 00144 00145 TRY_DUAL(__uuidof(IGMEOLEPanel)) 00146 { 00147 CString str = pThis->GetName(); 00148 str.SetSysString(name); 00149 return NOERROR; 00150 } 00151 CATCH_ALL_DUAL 00152 } 00153 00154 00155 STDMETHODIMP CGMEOLEPanel::XDual::put_Visible(VARIANT_BOOL isVisible) 00156 { 00157 METHOD_PROLOGUE(CGMEOLEPanel, Dual) 00158 00159 TRY_DUAL(__uuidof(IGMEOLEPanel)) 00160 { 00161 pThis->SetVisible(isVisible); 00162 return NOERROR; 00163 } 00164 CATCH_ALL_DUAL 00165 } 00166 00167 00168 STDMETHODIMP CGMEOLEPanel::XDual::get_Visible(VARIANT_BOOL* isVisible) 00169 { 00170 METHOD_PROLOGUE(CGMEOLEPanel, Dual) 00171 00172 TRY_DUAL(__uuidof(IGMEOLEPanel)) 00173 { 00174 *isVisible = (pThis->GetVisible() == FALSE) ? VARIANT_FALSE : VARIANT_TRUE; 00175 return NOERROR; 00176 } 00177 CATCH_ALL_DUAL 00178 } 00179 00180 STDMETHODIMP CGMEOLEPanel::XDual::get_Interface(IDispatch** interf) 00181 { 00182 METHOD_PROLOGUE(CGMEOLEPanel, Dual) 00183 00184 TRY_DUAL(__uuidof(IGMEOLEPanel)) 00185 { 00186 *interf = pThis->GetInterface(); 00187 return NOERROR; 00188 } 00189 CATCH_ALL_DUAL 00190 }