Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

265 lines
7.0 KiB

  1. #include "stdafx.h"
  2. #include "msictrl.h"
  3. //#include "ctrlref.h"
  4. //#include "msishell.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CMSIControl
  7. IMPLEMENT_DYNCREATE(CMSIControl, CWnd)
  8. CMSIControl::~CMSIControl()
  9. {
  10. /*if (m_fInRefresh && m_pRefresh)
  11. delete m_pRefresh;*/
  12. ASSERT(1);
  13. }
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CHWDiag properties
  16. long CMSIControl::GetMSInfoView()
  17. {
  18. long result = -1;
  19. DISPID dispid;
  20. if (GetDISPID("MSInfoView", &dispid))
  21. GetProperty(dispid, VT_I4, (void*)&result);
  22. return result;
  23. }
  24. void CMSIControl::SetMSInfoView(long propVal)
  25. {
  26. DISPID dispid;
  27. if (GetDISPID("MSInfoView", &dispid))
  28. SetProperty(dispid, VT_I4, propVal);
  29. }
  30. void CMSIControl::Refresh()
  31. {
  32. InvokeHelper(DISPID_REFRESH, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
  33. }
  34. //---------------------------------------------------------------------------
  35. // MSInfoRefresh instructs the control to refresh itself. Rather than just
  36. // calling the method, we create a thread which calls the method.
  37. //---------------------------------------------------------------------------
  38. //extern CMSIShellApp theApp;
  39. void CMSIControl::MSInfoRefresh()
  40. {
  41. /*if (m_fInRefresh)
  42. {
  43. if (m_pRefresh->IsDone())
  44. delete m_pRefresh;
  45. else
  46. {
  47. MessageBeep(MB_OK);
  48. return;
  49. }
  50. }
  51. m_pRefresh = new CCtrlRefresh;
  52. if (m_pRefresh)
  53. {
  54. if (m_pRefresh->Create(this, THREAD_PRIORITY_NORMAL, FALSE))
  55. {
  56. m_fInRefresh = TRUE;
  57. // theApp.m_pCtrlInRefresh = this;
  58. }
  59. else
  60. delete m_pRefresh;
  61. }*/
  62. }
  63. //---------------------------------------------------------------------------
  64. // This method returns a boolean indicating if this control is currently
  65. // in an MSInfoRefresh operation.
  66. //---------------------------------------------------------------------------
  67. BOOL CMSIControl::InRefresh()
  68. {
  69. return (m_fInRefresh /*&& !m_pRefresh->IsDone()*/);
  70. }
  71. //---------------------------------------------------------------------------
  72. // This method cancels a refresh in progress. Note that this method does not
  73. // call a method in the OLE control, but instead manipulate the refresh
  74. // object (if there is one).
  75. //---------------------------------------------------------------------------
  76. void CMSIControl::CancelMSInfoRefresh()
  77. {
  78. if (!m_fInRefresh)
  79. return;
  80. /* if (m_pRefresh)
  81. {
  82. delete m_pRefresh;
  83. m_pRefresh = NULL;
  84. }*/
  85. m_fInRefresh = FALSE;
  86. }
  87. void CMSIControl::MSInfoSelectAll()
  88. {
  89. DISPID dispid;
  90. if (GetDISPID("MSInfoSelectAll", &dispid))
  91. InvokeHelper(dispid, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
  92. }
  93. void CMSIControl::MSInfoCopy()
  94. {
  95. DISPID dispid;
  96. if (GetDISPID("MSInfoCopy", &dispid))
  97. InvokeHelper(dispid, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
  98. }
  99. BOOL CMSIControl::MSInfoLoadFile(LPCTSTR strFileName)
  100. {
  101. BOOL result = FALSE;
  102. static BYTE parms[] = VTS_BSTR;
  103. DISPID dispid;
  104. if (GetDISPID("MSInfoLoadFile", &dispid))
  105. InvokeHelper(dispid, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms, strFileName);
  106. return result;
  107. }
  108. void CMSIControl::MSInfoUpdateView()
  109. {
  110. DISPID dispid;
  111. if (GetDISPID("MSInfoUpdateView", &dispid))
  112. InvokeHelper(dispid, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
  113. }
  114. long CMSIControl::MSInfoGetData(long dwMSInfoView, long* pBuffer, long dwLength)
  115. {
  116. long result = -1;
  117. static BYTE parms[] = VTS_I4 VTS_PI4 VTS_I4;
  118. DISPID dispid;
  119. if (GetDISPID("MSInfoGetData", &dispid))
  120. InvokeHelper(dispid, DISPATCH_METHOD, VT_I4, (void*)&result, parms, dwMSInfoView, pBuffer, dwLength);
  121. return result;
  122. }
  123. void CMSIControl::AboutBox()
  124. {
  125. InvokeHelper(0xfffffdd8, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
  126. }
  127. //---------------------------------------------------------------------------
  128. // GetDISPID returns the DISPID for a given string, by looking it up using
  129. // IDispatch->GetIDsOfNames. This avoids hardcoding DISPIDs in this class.
  130. //---------------------------------------------------------------------------
  131. BOOL CMSIControl::GetDISPID(char *szName, DISPID *pID)
  132. {
  133. USES_CONVERSION;
  134. BOOL result = FALSE;
  135. DISPID dispid;
  136. OLECHAR FAR* szMember = A2OLE(szName);//T2OLE(szName);
  137. LPDISPATCH pDispatch;
  138. LPUNKNOWN pUnknown;
  139. pUnknown = GetControlUnknown();
  140. if (pUnknown)
  141. {
  142. if (SUCCEEDED(pUnknown->QueryInterface(IID_IDispatch, (void FAR* FAR*) &pDispatch)))
  143. {
  144. if (SUCCEEDED(pDispatch->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_SYSTEM_DEFAULT, &dispid)))
  145. {
  146. *pID = dispid;
  147. result = TRUE;
  148. }
  149. else
  150. TRACE0("+++ couldn't find method for MSInfoLoadFile\n");
  151. pDispatch->Release();
  152. }
  153. else
  154. TRACE0("+++ could not get IDispatch interface\n");
  155. }
  156. else
  157. TRACE0("+++ could not get IUnknown interface\n");
  158. return result;
  159. }
  160. //---------------------------------------------------------------------------
  161. // Save the contents of the control to a stream.
  162. //---------------------------------------------------------------------------
  163. BOOL CMSIControl::SaveToStream(IStream *pStream)
  164. {
  165. BOOL result = FALSE;
  166. LPUNKNOWN pUnknown;
  167. IPersistStreamInit *pPersist;
  168. pUnknown = GetControlUnknown();
  169. if (pUnknown)
  170. {
  171. if (SUCCEEDED(pUnknown->QueryInterface(IID_IPersistStreamInit, (void FAR* FAR*) &pPersist)))
  172. {
  173. result = SUCCEEDED(pPersist->Save(pStream, FALSE));
  174. pPersist->Release();
  175. }
  176. else
  177. TRACE0("+++ could not get IPersistStreamInit interface\n");
  178. }
  179. else
  180. TRACE0("+++ could not get IUnknown interface\n");
  181. return result;
  182. }
  183. //---------------------------------------------------------------------------
  184. // The following code isn't used now, but might be useful later.
  185. //---------------------------------------------------------------------------
  186. #if FALSE
  187. //---------------------------------------------------------------------------
  188. // RefreshForSave calls the MSInfoRefresh method, but waits for it to
  189. // complete.
  190. //---------------------------------------------------------------------------
  191. void CMSIControl::RefreshForSave()
  192. {
  193. USES_CONVERSION;
  194. OLECHAR FAR* szMember = T2OLE("MSInfoRefresh");
  195. DISPID dispid;
  196. LPDISPATCH pDispatch;
  197. DISPPARAMS dispparamsNoArgs;
  198. VARIANTARG variantargs[2];
  199. LPUNKNOWN pUnknown;
  200. DWORD dwCancel = 0;
  201. pUnknown = GetControlUnknown();
  202. if (pUnknown)
  203. if (SUCCEEDED(pUnknown->QueryInterface(IID_IDispatch, (void FAR* FAR*) &pDispatch)))
  204. {
  205. if (SUCCEEDED(pDispatch->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_SYSTEM_DEFAULT, &dispid)))
  206. {
  207. variantargs[0].vt = VT_I4 | VT_BYREF;
  208. variantargs[0].plVal = (long *) &dwCancel;
  209. variantargs[1].vt = VT_BOOL;
  210. variantargs[1].iVal = (short) -1;
  211. dispparamsNoArgs.cNamedArgs = 0;
  212. dispparamsNoArgs.rgdispidNamedArgs = NULL;
  213. dispparamsNoArgs.cArgs = 2;
  214. dispparamsNoArgs.rgvarg = variantargs;
  215. pDispatch->Invoke(dispid, IID_NULL, 0, DISPATCH_METHOD, &dispparamsNoArgs, NULL, NULL, NULL);
  216. }
  217. pDispatch->Release();
  218. }
  219. }
  220. #endif