Source code of Windows XP (NT5)
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.

180 lines
5.4 KiB

  1. // Copyright (C) 1996-1997 Microsoft Corporation. All rights reserved.
  2. // helper routines for our COleControl implementation
  3. #include "header.h"
  4. #include "internet.h"
  5. #include "CtlHelp.H"
  6. #include <windowsx.h>
  7. #ifndef _DEBUG
  8. #undef THIS_FILE
  9. static const char THIS_FILE[] = __FILE__;
  10. #endif
  11. // define this here, since it's the only guid we really need to define in the
  12. // framework -- the user control defines all other interesting guids.
  13. static const GUID IID_IControlPrv =
  14. { 0xd97180, 0xfcf7, 0x11ce, { 0xa0, 0x9e, 0x0, 0xaa, 0x0, 0x62, 0xbe, 0x57 } };
  15. // this table is used for copying data around, and persisting properties.
  16. // basically, it contains the size of a given data type
  17. const BYTE g_rgcbDataTypeSize[] = {
  18. 0, // VT_EMPTY= 0,
  19. 0, // VT_NULL= 1,
  20. sizeof(short), // VT_I2= 2,
  21. sizeof(long), // VT_I4 = 3,
  22. sizeof(float), // VT_R4 = 4,
  23. sizeof(double), // VT_R8= 5,
  24. sizeof(CURRENCY), // VT_CY= 6,
  25. sizeof(DATE), // VT_DATE = 7,
  26. sizeof(BSTR), // VT_BSTR = 8,
  27. sizeof(IDispatch *), // VT_DISPATCH = 9,
  28. sizeof(SCODE), // VT_ERROR = 10,
  29. sizeof(VARIANT_BOOL), // VT_BOOL = 11,
  30. sizeof(VARIANT), // VT_VARIANT= 12,
  31. sizeof(IUnknown *), // VT_UNKNOWN= 13,
  32. };
  33. const BYTE g_rgcbPromotedDataTypeSize[] = {
  34. 0, // VT_EMPTY= 0,
  35. 0, // VT_NULL= 1,
  36. sizeof(int ), // VT_I2= 2,
  37. sizeof(long), // VT_I4 = 3,
  38. sizeof(double), // VT_R4 = 4,
  39. sizeof(double), // VT_R8= 5,
  40. sizeof(CURRENCY), // VT_CY= 6,
  41. sizeof(DATE), // VT_DATE = 7,
  42. sizeof(BSTR), // VT_BSTR = 8,
  43. sizeof(IDispatch *), // VT_DISPATCH = 9,
  44. sizeof(SCODE), // VT_ERROR = 10,
  45. sizeof(int), // VT_BOOL = 11,
  46. sizeof(VARIANT), // VT_VARIANT= 12,
  47. sizeof(IUnknown *), // VT_UNKNOWN= 13,
  48. };
  49. //=--------------------------------------------------------------------------=
  50. // _SpecialKeyState
  51. //=--------------------------------------------------------------------------=
  52. // returns a short with some information on which of the SHIFT, ALT, and CTRL
  53. // keys are set.
  54. //
  55. // Output:
  56. // short - bit 0 is shift, bit 1 is ctrl, bit 2 is ALT.
  57. short _SpecialKeyState()
  58. {
  59. // don't appear to be able to reduce number of calls to GetKeyState
  60. //
  61. BOOL bShift = (GetKeyState(VK_SHIFT) < 0);
  62. BOOL bCtrl = (GetKeyState(VK_CONTROL) < 0);
  63. BOOL bAlt = (GetKeyState(VK_MENU) < 0);
  64. return (short)(bShift + (bCtrl << 1) + (bAlt << 2));
  65. }
  66. //=--------------------------------------------------------------------------=
  67. // CopyAndAddRefObject
  68. //=--------------------------------------------------------------------------=
  69. // copies an object pointer, and then addref's the object.
  70. //
  71. // Parameters:
  72. // void * - [in] dest.
  73. // const void * - [in] src
  74. // DWORD - [in] size, ignored, since it's always 4
  75. void WINAPI CopyAndAddRefObject(void *pDest, const void *pSource, DWORD dwSize)
  76. {
  77. ASSERT_COMMENT(pDest && pSource, "Bogus Pointer(s) passed into CopyAndAddRefObject!!!!");
  78. *((IUnknown **)pDest) = *((IUnknown **)pSource);
  79. ADDREF_OBJECT(*((IUnknown **)pDest));
  80. return;
  81. }
  82. //=--------------------------------------------------------------------------=
  83. // CopyOleVerb [helper]
  84. //=--------------------------------------------------------------------------=
  85. // copies an OLEVERB structure. used in CStandardEnum
  86. //
  87. // Parameters:
  88. // void * - [out] where to copy to
  89. // const void * - [in] where to copy from
  90. // DWORD - [in] bytes to copy
  91. void WINAPI CopyOleVerb(void *pvDest, const void *pvSrc, DWORD cbCopy)
  92. {
  93. VERBINFO * pVerbDest = (VERBINFO *) pvDest;
  94. const VERBINFO * pVerbSrc = (const VERBINFO *) pvSrc;
  95. *pVerbDest = *pVerbSrc;
  96. ((OLEVERB *)pVerbDest)->lpszVerbName = OLESTRFROMRESID((WORD)((VERBINFO *)pvSrc)->idVerbName);
  97. }
  98. //=--------------------------------------------------------------------------=
  99. // ControlFromUnknown [helper, callable]
  100. //=--------------------------------------------------------------------------=
  101. // given an unknown, get the COleControl pointer for it.
  102. //
  103. // Parameters:
  104. // IUnknown * - [in]
  105. COleControl *ControlFromUnknown(IUnknown *pUnk)
  106. {
  107. COleControl *pCtl = NULL;
  108. if (!pUnk) return NULL;
  109. pUnk->QueryInterface(IID_IControlPrv, (void **)&pCtl);
  110. return pCtl;
  111. }
  112. // in case the user doesn't want our default window proc, we support
  113. // letting them specify one themselves. this is defined in their main ipserver
  114. // file.
  115. extern WNDPROC g_ParkingWindowProc;
  116. //=--------------------------------------------------------------------------=
  117. // GetParkingWindow
  118. //=--------------------------------------------------------------------------=
  119. // creates the global parking window that we'll use to parent things, or
  120. // returns the already existing one
  121. //
  122. // Output:
  123. // HWND - our parking window
  124. HWND GetParkingWindow(void)
  125. {
  126. WNDCLASS wndclass;
  127. // crit sect this creation for apartment threading support.
  128. // EnterCriticalSection(&g_CriticalSection);
  129. if (g_hwndParking)
  130. goto CleanUp;
  131. ZeroMemory(&wndclass, sizeof(wndclass));
  132. wndclass.lpfnWndProc = (g_ParkingWindowProc) ? g_ParkingWindowProc : DefWindowProc;
  133. wndclass.hInstance = _Module.GetModuleInstance();
  134. wndclass.lpszClassName = "CtlFrameWork_Parking";
  135. if (!RegisterClass(&wndclass)) {
  136. FAIL("Couldn't Register Parking Window Class!");
  137. goto CleanUp;
  138. }
  139. g_hwndParking = CreateWindow("CtlFrameWork_Parking", NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, _Module.GetModuleInstance(), NULL);
  140. if (g_hwndParking != NULL)
  141. ++g_cLocks;
  142. ASSERT_COMMENT(g_hwndParking, "Couldn't Create Global parking window!!");
  143. CleanUp:
  144. // LeaveCriticalSection(&g_CriticalSection);
  145. return g_hwndParking;
  146. }