4 * Copyright 1995 Martin von Loewis
5 * Copyright 1999 Francis Beaudet
6 * Copyright 1999 Noel Borthwick
7 * Copyright 1999, 2000 Marcus Meissner
8 * Copyright 2005 Juan Lang
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #define NONAMELESSUNION
35 #define NONAMELESSSTRUCT
49 #include "wine/unicode.h"
50 #include "wine/winbase16.h"
51 #include "wine/wingdi16.h"
52 #include "wine/winuser16.h"
53 #include "compobj_private.h"
55 #include "wine/debug.h"
57 WINE_DEFAULT_DEBUG_CHANNEL(ole);
58 WINE_DECLARE_DEBUG_CHANNEL(accel);
60 #define HICON_16(h32) (LOWORD(h32))
61 #define HICON_32(h16) ((HICON)(ULONG_PTR)(h16))
62 #define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
64 /******************************************************************************
65 * These are static/global variables and internal data structures that the
66 * OLE module uses to maintain it's state.
68 typedef struct tagDropTargetNode
71 IDropTarget* dropTarget;
72 struct tagDropTargetNode* prevDropTarget;
73 struct tagDropTargetNode* nextDropTarget;
76 typedef struct tagTrackerWindowInfo
78 IDataObject* dataObject;
79 IDropSource* dropSource;
86 HWND curTargetHWND; /* window the mouse is hovering over */
87 HWND curDragTargetHWND; /* might be a ancestor of curTargetHWND */
88 IDropTarget* curDragTarget;
91 typedef struct tagOleMenuDescriptor /* OleMenuDescriptor */
93 HWND hwndFrame; /* The containers frame window */
94 HWND hwndActiveObject; /* The active objects window */
95 OLEMENUGROUPWIDTHS mgw; /* OLE menu group widths for the shared menu */
96 HMENU hmenuCombined; /* The combined menu */
97 BOOL bIsServerItem; /* True if the currently open popup belongs to the server */
100 typedef struct tagOleMenuHookItem /* OleMenu hook item in per thread hook list */
102 DWORD tid; /* Thread Id */
103 HANDLE hHeap; /* Heap this is allocated from */
104 HHOOK GetMsg_hHook; /* message hook for WH_GETMESSAGE */
105 HHOOK CallWndProc_hHook; /* message hook for WH_CALLWNDPROC */
106 struct tagOleMenuHookItem *next;
109 static OleMenuHookItem *hook_list;
112 * This is the lock count on the OLE library. It is controlled by the
113 * OLEInitialize/OLEUninitialize methods.
115 static ULONG OLE_moduleLockCount = 0;
118 * Name of our registered window class.
120 static const char OLEDD_DRAGTRACKERCLASS[] = "WineDragDropTracker32";
123 * This is the head of the Drop target container.
125 static DropTargetNode* targetListHead = NULL;
127 /******************************************************************************
128 * These are the prototypes of miscelaneous utility methods
130 static void OLEUTL_ReadRegistryDWORDValue(HKEY regKey, DWORD* pdwValue);
132 /******************************************************************************
133 * These are the prototypes of the utility methods used to manage a shared menu
135 static void OLEMenu_Initialize(void);
136 static void OLEMenu_UnInitialize(void);
137 BOOL OLEMenu_InstallHooks( DWORD tid );
138 BOOL OLEMenu_UnInstallHooks( DWORD tid );
139 OleMenuHookItem * OLEMenu_IsHookInstalled( DWORD tid );
140 static BOOL OLEMenu_FindMainMenuIndex( HMENU hMainMenu, HMENU hPopupMenu, UINT *pnPos );
141 BOOL OLEMenu_SetIsServerMenu( HMENU hmenu, OleMenuDescriptor *pOleMenuDescriptor );
142 LRESULT CALLBACK OLEMenu_CallWndProc(INT code, WPARAM wParam, LPARAM lParam);
143 LRESULT CALLBACK OLEMenu_GetMsgProc(INT code, WPARAM wParam, LPARAM lParam);
145 /******************************************************************************
146 * These are the prototypes of the OLE Clipboard initialization methods (in clipboard.c)
148 extern void OLEClipbrd_UnInitialize(void);
149 extern void OLEClipbrd_Initialize(void);
151 /******************************************************************************
152 * These are the prototypes of the utility methods used for OLE Drag n Drop
154 static void OLEDD_Initialize(void);
155 static void OLEDD_UnInitialize(void);
156 static void OLEDD_InsertDropTarget(
157 DropTargetNode* nodeToAdd);
158 static DropTargetNode* OLEDD_ExtractDropTarget(
160 static DropTargetNode* OLEDD_FindDropTarget(
162 static LRESULT WINAPI OLEDD_DragTrackerWindowProc(
167 static void OLEDD_TrackMouseMove(
168 TrackerWindowInfo* trackerInfo,
171 static void OLEDD_TrackStateChange(
172 TrackerWindowInfo* trackerInfo,
175 static DWORD OLEDD_GetButtonState(void);
178 /******************************************************************************
179 * OleBuildVersion [OLE2.1]
180 * OleBuildVersion [OLE32.@]
182 DWORD WINAPI OleBuildVersion(void)
184 TRACE("Returning version %d, build %d.\n", rmm, rup);
185 return (rmm<<16)+rup;
188 /***********************************************************************
189 * OleInitialize (OLE2.2)
190 * OleInitialize (OLE32.@)
192 HRESULT WINAPI OleInitialize(LPVOID reserved)
196 TRACE("(%p)\n", reserved);
199 * The first duty of the OleInitialize is to initialize the COM libraries.
201 hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
204 * If the CoInitializeEx call failed, the OLE libraries can't be
211 * Then, it has to initialize the OLE specific modules.
215 * Object linking and Embedding
216 * In-place activation
218 if (OLE_moduleLockCount==0)
221 * Initialize the libraries.
223 TRACE("() - Initializing the OLE libraries\n");
228 OLEClipbrd_Initialize();
238 OLEMenu_Initialize();
242 * Then, we increase the lock count on the OLE module.
244 OLE_moduleLockCount++;
249 /******************************************************************************
250 * OleUninitialize [OLE2.3]
251 * OleUninitialize [OLE32.@]
253 void WINAPI OleUninitialize(void)
258 * Decrease the lock count on the OLE module.
260 OLE_moduleLockCount--;
263 * If we hit the bottom of the lock stack, free the libraries.
265 if (OLE_moduleLockCount==0)
268 * Actually free the libraries.
270 TRACE("() - Freeing the last reference count\n");
275 OLEClipbrd_UnInitialize();
280 OLEDD_UnInitialize();
285 OLEMenu_UnInitialize();
289 * Then, uninitialize the COM libraries.
294 /******************************************************************************
295 * OleInitializeWOW [OLE32.@]
297 HRESULT WINAPI OleInitializeWOW(DWORD x, DWORD y) {
298 FIXME("(0x%08lx, 0x%08lx),stub!\n",x, y);
302 /***********************************************************************
303 * RegisterDragDrop (OLE32.@)
305 HRESULT WINAPI RegisterDragDrop(
307 LPDROPTARGET pDropTarget)
309 DropTargetNode* dropTargetInfo;
311 TRACE("(%p,%p)\n", hwnd, pDropTarget);
317 * First, check if the window is already registered.
319 dropTargetInfo = OLEDD_FindDropTarget(hwnd);
321 if (dropTargetInfo!=NULL)
322 return DRAGDROP_E_ALREADYREGISTERED;
325 * If it's not there, we can add it. We first create a node for it.
327 dropTargetInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(DropTargetNode));
329 if (dropTargetInfo==NULL)
330 return E_OUTOFMEMORY;
332 dropTargetInfo->hwndTarget = hwnd;
333 dropTargetInfo->prevDropTarget = NULL;
334 dropTargetInfo->nextDropTarget = NULL;
337 * Don't forget that this is an interface pointer, need to nail it down since
338 * we keep a copy of it.
340 dropTargetInfo->dropTarget = pDropTarget;
341 IDropTarget_AddRef(dropTargetInfo->dropTarget);
343 OLEDD_InsertDropTarget(dropTargetInfo);
348 /***********************************************************************
349 * RevokeDragDrop (OLE32.@)
351 HRESULT WINAPI RevokeDragDrop(
354 DropTargetNode* dropTargetInfo;
356 TRACE("(%p)\n", hwnd);
359 * First, check if the window is already registered.
361 dropTargetInfo = OLEDD_ExtractDropTarget(hwnd);
364 * If it ain't in there, it's an error.
366 if (dropTargetInfo==NULL)
367 return DRAGDROP_E_NOTREGISTERED;
370 * If it's in there, clean-up it's used memory and
373 IDropTarget_Release(dropTargetInfo->dropTarget);
374 HeapFree(GetProcessHeap(), 0, dropTargetInfo);
379 /***********************************************************************
380 * OleRegGetUserType (OLE32.@)
382 * This implementation of OleRegGetUserType ignores the dwFormOfType
383 * parameter and always returns the full name of the object. This is
384 * not too bad since this is the case for many objects because of the
385 * way they are registered.
387 HRESULT WINAPI OleRegGetUserType(
390 LPOLESTR* pszUserType)
400 * Initialize the out parameter.
405 * Build the key name we're looking for
407 sprintf( keyName, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\",
408 clsid->Data1, clsid->Data2, clsid->Data3,
409 clsid->Data4[0], clsid->Data4[1], clsid->Data4[2], clsid->Data4[3],
410 clsid->Data4[4], clsid->Data4[5], clsid->Data4[6], clsid->Data4[7] );
412 TRACE("(%s, %ld, %p)\n", keyName, dwFormOfType, pszUserType);
415 * Open the class id Key
417 hres = RegOpenKeyA(HKEY_CLASSES_ROOT,
421 if (hres != ERROR_SUCCESS)
422 return REGDB_E_CLASSNOTREG;
425 * Retrieve the size of the name string.
429 hres = RegQueryValueExA(clsidKey,
436 if (hres!=ERROR_SUCCESS)
438 RegCloseKey(clsidKey);
439 return REGDB_E_READREGDB;
443 * Allocate a buffer for the registry value.
445 *pszUserType = CoTaskMemAlloc(cbData*2);
447 if (*pszUserType==NULL)
449 RegCloseKey(clsidKey);
450 return E_OUTOFMEMORY;
453 buffer = HeapAlloc(GetProcessHeap(), 0, cbData);
457 RegCloseKey(clsidKey);
458 CoTaskMemFree(*pszUserType);
460 return E_OUTOFMEMORY;
463 hres = RegQueryValueExA(clsidKey,
470 RegCloseKey(clsidKey);
473 if (hres!=ERROR_SUCCESS)
475 CoTaskMemFree(*pszUserType);
478 retVal = REGDB_E_READREGDB;
482 MultiByteToWideChar( CP_ACP, 0, buffer, -1, *pszUserType, cbData /*FIXME*/ );
485 HeapFree(GetProcessHeap(), 0, buffer);
490 /***********************************************************************
491 * DoDragDrop [OLE32.@]
493 HRESULT WINAPI DoDragDrop (
494 IDataObject *pDataObject, /* [in] ptr to the data obj */
495 IDropSource* pDropSource, /* [in] ptr to the source obj */
496 DWORD dwOKEffect, /* [in] effects allowed by the source */
497 DWORD *pdwEffect) /* [out] ptr to effects of the source */
499 TrackerWindowInfo trackerInfo;
500 HWND hwndTrackWindow;
503 TRACE("(DataObject %p, DropSource %p)\n", pDataObject, pDropSource);
506 * Setup the drag n drop tracking window.
508 if (!IsValidInterface((LPUNKNOWN)pDropSource))
511 trackerInfo.dataObject = pDataObject;
512 trackerInfo.dropSource = pDropSource;
513 trackerInfo.dwOKEffect = dwOKEffect;
514 trackerInfo.pdwEffect = pdwEffect;
515 trackerInfo.trackingDone = FALSE;
516 trackerInfo.escPressed = FALSE;
517 trackerInfo.curDragTargetHWND = 0;
518 trackerInfo.curTargetHWND = 0;
519 trackerInfo.curDragTarget = 0;
521 hwndTrackWindow = CreateWindowA(OLEDD_DRAGTRACKERCLASS,
524 CW_USEDEFAULT, CW_USEDEFAULT,
525 CW_USEDEFAULT, CW_USEDEFAULT,
529 (LPVOID)&trackerInfo);
531 if (hwndTrackWindow!=0)
534 * Capture the mouse input
536 SetCapture(hwndTrackWindow);
539 * Pump messages. All mouse input should go the the capture window.
541 while (!trackerInfo.trackingDone && GetMessageA(&msg, 0, 0, 0) )
543 if ( (msg.message >= WM_KEYFIRST) &&
544 (msg.message <= WM_KEYLAST) )
547 * When keyboard messages are sent to windows on this thread, we
548 * want to ignore notify the drop source that the state changed.
549 * in the case of the Escape key, we also notify the drop source
550 * we give it a special meaning.
552 if ( (msg.message==WM_KEYDOWN) &&
553 (msg.wParam==VK_ESCAPE) )
555 trackerInfo.escPressed = TRUE;
559 * Notify the drop source.
561 OLEDD_TrackStateChange(&trackerInfo,
563 OLEDD_GetButtonState());
568 * Dispatch the messages only when it's not a keyboard message.
570 DispatchMessageA(&msg);
575 * Destroy the temporary window.
577 DestroyWindow(hwndTrackWindow);
579 return trackerInfo.returnValue;
585 /***********************************************************************
586 * OleQueryLinkFromData [OLE32.@]
588 HRESULT WINAPI OleQueryLinkFromData(
589 IDataObject* pSrcDataObject)
591 FIXME("(%p),stub!\n", pSrcDataObject);
595 /***********************************************************************
596 * OleRegGetMiscStatus [OLE32.@]
598 HRESULT WINAPI OleRegGetMiscStatus(
610 * Initialize the out parameter.
615 * Build the key name we're looking for
617 sprintf( keyName, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\",
618 clsid->Data1, clsid->Data2, clsid->Data3,
619 clsid->Data4[0], clsid->Data4[1], clsid->Data4[2], clsid->Data4[3],
620 clsid->Data4[4], clsid->Data4[5], clsid->Data4[6], clsid->Data4[7] );
622 TRACE("(%s, %ld, %p)\n", keyName, dwAspect, pdwStatus);
625 * Open the class id Key
627 result = RegOpenKeyA(HKEY_CLASSES_ROOT,
631 if (result != ERROR_SUCCESS)
632 return REGDB_E_CLASSNOTREG;
637 result = RegOpenKeyA(clsidKey,
642 if (result != ERROR_SUCCESS)
644 RegCloseKey(clsidKey);
645 return REGDB_E_READREGDB;
649 * Read the default value
651 OLEUTL_ReadRegistryDWORDValue(miscStatusKey, pdwStatus);
654 * Open the key specific to the requested aspect.
656 sprintf(keyName, "%ld", dwAspect);
658 result = RegOpenKeyA(miscStatusKey,
662 if (result == ERROR_SUCCESS)
664 OLEUTL_ReadRegistryDWORDValue(aspectKey, pdwStatus);
665 RegCloseKey(aspectKey);
671 RegCloseKey(miscStatusKey);
672 RegCloseKey(clsidKey);
677 /******************************************************************************
678 * OleSetContainedObject [OLE32.@]
680 HRESULT WINAPI OleSetContainedObject(
684 IRunnableObject* runnable = NULL;
687 TRACE("(%p,%x), stub!\n", pUnknown, fContained);
689 hres = IUnknown_QueryInterface(pUnknown,
690 &IID_IRunnableObject,
695 hres = IRunnableObject_SetContainedObject(runnable, fContained);
697 IRunnableObject_Release(runnable);
705 /******************************************************************************
708 HRESULT WINAPI OleLoad(
711 LPOLECLIENTSITE pClientSite,
714 IPersistStorage* persistStorage = NULL;
715 IOleObject* oleObject = NULL;
719 TRACE("(%p,%p,%p,%p)\n", pStg, riid, pClientSite, ppvObj);
722 * TODO, Conversion ... OleDoAutoConvert
726 * Get the class ID for the object.
728 hres = IStorage_Stat(pStg, &storageInfo, STATFLAG_NONAME);
731 * Now, try and create the handler for the object
733 hres = CoCreateInstance(&storageInfo.clsid,
735 CLSCTX_INPROC_HANDLER,
740 * If that fails, as it will most times, load the default
745 hres = OleCreateDefaultHandler(&storageInfo.clsid,
752 * If we couldn't find a handler... this is bad. Abort the whole thing.
758 * Inform the new object of it's client site.
760 hres = IOleObject_SetClientSite(oleObject, pClientSite);
763 * Initialize the object with it's IPersistStorage interface.
765 hres = IOleObject_QueryInterface(oleObject,
766 &IID_IPersistStorage,
767 (void**)&persistStorage);
771 IPersistStorage_Load(persistStorage, pStg);
773 IPersistStorage_Release(persistStorage);
774 persistStorage = NULL;
778 * Return the requested interface to the caller.
780 hres = IOleObject_QueryInterface(oleObject, riid, ppvObj);
783 * Cleanup interfaces used internally
785 IOleObject_Release(oleObject);
790 /***********************************************************************
793 HRESULT WINAPI OleSave(
794 LPPERSISTSTORAGE pPS,
801 TRACE("(%p,%p,%x)\n", pPS, pStg, fSameAsLoad);
804 * First, we transfer the class ID (if available)
806 hres = IPersistStorage_GetClassID(pPS, &objectClass);
810 WriteClassStg(pStg, &objectClass);
814 * Then, we ask the object to save itself to the
815 * storage. If it is successful, we commit the storage.
817 hres = IPersistStorage_Save(pPS, pStg, fSameAsLoad);
821 IStorage_Commit(pStg,
829 /******************************************************************************
830 * OleLockRunning [OLE32.@]
832 HRESULT WINAPI OleLockRunning(LPUNKNOWN pUnknown, BOOL fLock, BOOL fLastUnlockCloses)
834 IRunnableObject* runnable = NULL;
837 TRACE("(%p,%x,%x)\n", pUnknown, fLock, fLastUnlockCloses);
839 hres = IUnknown_QueryInterface(pUnknown,
840 &IID_IRunnableObject,
845 hres = IRunnableObject_LockRunning(runnable, fLock, fLastUnlockCloses);
847 IRunnableObject_Release(runnable);
856 /**************************************************************************
857 * Internal methods to manage the shared OLE menu in response to the
858 * OLE***MenuDescriptor API
862 * OLEMenu_Initialize()
864 * Initializes the OLEMENU data structures.
866 static void OLEMenu_Initialize()
871 * OLEMenu_UnInitialize()
873 * Releases the OLEMENU data structures.
875 static void OLEMenu_UnInitialize()
879 /*************************************************************************
880 * OLEMenu_InstallHooks
881 * Install thread scope message hooks for WH_GETMESSAGE and WH_CALLWNDPROC
883 * RETURNS: TRUE if message hooks were successfully installed
886 BOOL OLEMenu_InstallHooks( DWORD tid )
888 OleMenuHookItem *pHookItem = NULL;
890 /* Create an entry for the hook table */
891 if ( !(pHookItem = HeapAlloc(GetProcessHeap(), 0,
892 sizeof(OleMenuHookItem)) ) )
895 pHookItem->tid = tid;
896 pHookItem->hHeap = GetProcessHeap();
898 /* Install a thread scope message hook for WH_GETMESSAGE */
899 pHookItem->GetMsg_hHook = SetWindowsHookExA( WH_GETMESSAGE, OLEMenu_GetMsgProc,
900 0, GetCurrentThreadId() );
901 if ( !pHookItem->GetMsg_hHook )
904 /* Install a thread scope message hook for WH_CALLWNDPROC */
905 pHookItem->CallWndProc_hHook = SetWindowsHookExA( WH_CALLWNDPROC, OLEMenu_CallWndProc,
906 0, GetCurrentThreadId() );
907 if ( !pHookItem->CallWndProc_hHook )
910 /* Insert the hook table entry */
911 pHookItem->next = hook_list;
912 hook_list = pHookItem;
917 /* Unhook any hooks */
918 if ( pHookItem->GetMsg_hHook )
919 UnhookWindowsHookEx( pHookItem->GetMsg_hHook );
920 if ( pHookItem->CallWndProc_hHook )
921 UnhookWindowsHookEx( pHookItem->CallWndProc_hHook );
922 /* Release the hook table entry */
923 HeapFree(pHookItem->hHeap, 0, pHookItem );
928 /*************************************************************************
929 * OLEMenu_UnInstallHooks
930 * UnInstall thread scope message hooks for WH_GETMESSAGE and WH_CALLWNDPROC
932 * RETURNS: TRUE if message hooks were successfully installed
935 BOOL OLEMenu_UnInstallHooks( DWORD tid )
937 OleMenuHookItem *pHookItem = NULL;
938 OleMenuHookItem **ppHook = &hook_list;
942 if ((*ppHook)->tid == tid)
945 *ppHook = pHookItem->next;
948 ppHook = &(*ppHook)->next;
950 if (!pHookItem) return FALSE;
952 /* Uninstall the hooks installed for this thread */
953 if ( !UnhookWindowsHookEx( pHookItem->GetMsg_hHook ) )
955 if ( !UnhookWindowsHookEx( pHookItem->CallWndProc_hHook ) )
958 /* Release the hook table entry */
959 HeapFree(pHookItem->hHeap, 0, pHookItem );
964 /* Release the hook table entry */
965 HeapFree(pHookItem->hHeap, 0, pHookItem );
970 /*************************************************************************
971 * OLEMenu_IsHookInstalled
972 * Tests if OLEMenu hooks have been installed for a thread
974 * RETURNS: The pointer and index of the hook table entry for the tid
975 * NULL and -1 for the index if no hooks were installed for this thread
977 OleMenuHookItem * OLEMenu_IsHookInstalled( DWORD tid )
979 OleMenuHookItem *pHookItem = NULL;
981 /* Do a simple linear search for an entry whose tid matches ours.
982 * We really need a map but efficiency is not a concern here. */
983 for (pHookItem = hook_list; pHookItem; pHookItem = pHookItem->next)
985 if ( tid == pHookItem->tid )
992 /***********************************************************************
993 * OLEMenu_FindMainMenuIndex
995 * Used by OLEMenu API to find the top level group a menu item belongs to.
996 * On success pnPos contains the index of the item in the top level menu group
998 * RETURNS: TRUE if the ID was found, FALSE on failure
1000 static BOOL OLEMenu_FindMainMenuIndex( HMENU hMainMenu, HMENU hPopupMenu, UINT *pnPos )
1004 nItems = GetMenuItemCount( hMainMenu );
1006 for (i = 0; i < nItems; i++)
1010 /* Is the current item a submenu? */
1011 if ( (hsubmenu = GetSubMenu(hMainMenu, i)) )
1013 /* If the handle is the same we're done */
1014 if ( hsubmenu == hPopupMenu )
1020 /* Recursively search without updating pnPos */
1021 else if ( OLEMenu_FindMainMenuIndex( hsubmenu, hPopupMenu, NULL ) )
1033 /***********************************************************************
1034 * OLEMenu_SetIsServerMenu
1036 * Checks whether a popup menu belongs to a shared menu group which is
1037 * owned by the server, and sets the menu descriptor state accordingly.
1038 * All menu messages from these groups should be routed to the server.
1040 * RETURNS: TRUE if the popup menu is part of a server owned group
1041 * FALSE if the popup menu is part of a container owned group
1043 BOOL OLEMenu_SetIsServerMenu( HMENU hmenu, OleMenuDescriptor *pOleMenuDescriptor )
1045 UINT nPos = 0, nWidth, i;
1047 pOleMenuDescriptor->bIsServerItem = FALSE;
1049 /* Don't bother searching if the popup is the combined menu itself */
1050 if ( hmenu == pOleMenuDescriptor->hmenuCombined )
1053 /* Find the menu item index in the shared OLE menu that this item belongs to */
1054 if ( !OLEMenu_FindMainMenuIndex( pOleMenuDescriptor->hmenuCombined, hmenu, &nPos ) )
1057 /* The group widths array has counts for the number of elements
1058 * in the groups File, Edit, Container, Object, Window, Help.
1059 * The Edit, Object & Help groups belong to the server object
1060 * and the other three belong to the container.
1061 * Loop through the group widths and locate the group we are a member of.
1063 for ( i = 0, nWidth = 0; i < 6; i++ )
1065 nWidth += pOleMenuDescriptor->mgw.width[i];
1066 if ( nPos < nWidth )
1068 /* Odd elements are server menu widths */
1069 pOleMenuDescriptor->bIsServerItem = (i%2) ? TRUE : FALSE;
1074 return pOleMenuDescriptor->bIsServerItem;
1077 /*************************************************************************
1078 * OLEMenu_CallWndProc
1079 * Thread scope WH_CALLWNDPROC hook proc filter function (callback)
1080 * This is invoked from a message hook installed in OleSetMenuDescriptor.
1082 LRESULT CALLBACK OLEMenu_CallWndProc(INT code, WPARAM wParam, LPARAM lParam)
1084 LPCWPSTRUCT pMsg = NULL;
1085 HOLEMENU hOleMenu = 0;
1086 OleMenuDescriptor *pOleMenuDescriptor = NULL;
1087 OleMenuHookItem *pHookItem = NULL;
1090 TRACE("%i, %04x, %08x\n", code, wParam, (unsigned)lParam );
1092 /* Check if we're being asked to process the message */
1093 if ( HC_ACTION != code )
1096 /* Retrieve the current message being dispatched from lParam */
1097 pMsg = (LPCWPSTRUCT)lParam;
1099 /* Check if the message is destined for a window we are interested in:
1100 * If the window has an OLEMenu property we may need to dispatch
1101 * the menu message to its active objects window instead. */
1103 hOleMenu = (HOLEMENU)GetPropA( pMsg->hwnd, "PROP_OLEMenuDescriptor" );
1107 /* Get the menu descriptor */
1108 pOleMenuDescriptor = (OleMenuDescriptor *) GlobalLock( hOleMenu );
1109 if ( !pOleMenuDescriptor ) /* Bad descriptor! */
1112 /* Process menu messages */
1113 switch( pMsg->message )
1117 /* Reset the menu descriptor state */
1118 pOleMenuDescriptor->bIsServerItem = FALSE;
1120 /* Send this message to the server as well */
1121 SendMessageA( pOleMenuDescriptor->hwndActiveObject,
1122 pMsg->message, pMsg->wParam, pMsg->lParam );
1126 case WM_INITMENUPOPUP:
1128 /* Save the state for whether this is a server owned menu */
1129 OLEMenu_SetIsServerMenu( (HMENU)pMsg->wParam, pOleMenuDescriptor );
1135 fuFlags = HIWORD(pMsg->wParam); /* Get flags */
1136 if ( fuFlags & MF_SYSMENU )
1139 /* Save the state for whether this is a server owned popup menu */
1140 else if ( fuFlags & MF_POPUP )
1141 OLEMenu_SetIsServerMenu( (HMENU)pMsg->lParam, pOleMenuDescriptor );
1148 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT) pMsg->lParam;
1149 if ( pMsg->wParam != 0 || lpdis->CtlType != ODT_MENU )
1150 goto NEXTHOOK; /* Not a menu message */
1159 /* If the message was for the server dispatch it accordingly */
1160 if ( pOleMenuDescriptor->bIsServerItem )
1162 SendMessageA( pOleMenuDescriptor->hwndActiveObject,
1163 pMsg->message, pMsg->wParam, pMsg->lParam );
1167 if ( pOleMenuDescriptor )
1168 GlobalUnlock( hOleMenu );
1170 /* Lookup the hook item for the current thread */
1171 if ( !( pHookItem = OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) )
1173 /* This should never fail!! */
1174 WARN("could not retrieve hHook for current thread!\n" );
1178 /* Pass on the message to the next hooker */
1179 return CallNextHookEx( pHookItem->CallWndProc_hHook, code, wParam, lParam );
1182 /*************************************************************************
1183 * OLEMenu_GetMsgProc
1184 * Thread scope WH_GETMESSAGE hook proc filter function (callback)
1185 * This is invoked from a message hook installed in OleSetMenuDescriptor.
1187 LRESULT CALLBACK OLEMenu_GetMsgProc(INT code, WPARAM wParam, LPARAM lParam)
1190 HOLEMENU hOleMenu = 0;
1191 OleMenuDescriptor *pOleMenuDescriptor = NULL;
1192 OleMenuHookItem *pHookItem = NULL;
1195 TRACE("%i, %04x, %08x\n", code, wParam, (unsigned)lParam );
1197 /* Check if we're being asked to process a messages */
1198 if ( HC_ACTION != code )
1201 /* Retrieve the current message being dispatched from lParam */
1202 pMsg = (LPMSG)lParam;
1204 /* Check if the message is destined for a window we are interested in:
1205 * If the window has an OLEMenu property we may need to dispatch
1206 * the menu message to its active objects window instead. */
1208 hOleMenu = (HOLEMENU)GetPropA( pMsg->hwnd, "PROP_OLEMenuDescriptor" );
1212 /* Process menu messages */
1213 switch( pMsg->message )
1217 wCode = HIWORD(pMsg->wParam); /* Get notification code */
1219 goto NEXTHOOK; /* Not a menu message */
1226 /* Get the menu descriptor */
1227 pOleMenuDescriptor = (OleMenuDescriptor *) GlobalLock( hOleMenu );
1228 if ( !pOleMenuDescriptor ) /* Bad descriptor! */
1231 /* If the message was for the server dispatch it accordingly */
1232 if ( pOleMenuDescriptor->bIsServerItem )
1234 /* Change the hWnd in the message to the active objects hWnd.
1235 * The message loop which reads this message will automatically
1236 * dispatch it to the embedded objects window. */
1237 pMsg->hwnd = pOleMenuDescriptor->hwndActiveObject;
1241 if ( pOleMenuDescriptor )
1242 GlobalUnlock( hOleMenu );
1244 /* Lookup the hook item for the current thread */
1245 if ( !( pHookItem = OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) )
1247 /* This should never fail!! */
1248 WARN("could not retrieve hHook for current thread!\n" );
1252 /* Pass on the message to the next hooker */
1253 return CallNextHookEx( pHookItem->GetMsg_hHook, code, wParam, lParam );
1256 /***********************************************************************
1257 * OleCreateMenuDescriptor [OLE32.@]
1258 * Creates an OLE menu descriptor for OLE to use when dispatching
1259 * menu messages and commands.
1262 * hmenuCombined - Handle to the objects combined menu
1263 * lpMenuWidths - Pointer to array of 6 LONG's indicating menus per group
1266 HOLEMENU WINAPI OleCreateMenuDescriptor(
1267 HMENU hmenuCombined,
1268 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1271 OleMenuDescriptor *pOleMenuDescriptor;
1274 if ( !hmenuCombined || !lpMenuWidths )
1277 /* Create an OLE menu descriptor */
1278 if ( !(hOleMenu = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT,
1279 sizeof(OleMenuDescriptor) ) ) )
1282 pOleMenuDescriptor = (OleMenuDescriptor *) GlobalLock( hOleMenu );
1283 if ( !pOleMenuDescriptor )
1286 /* Initialize menu group widths and hmenu */
1287 for ( i = 0; i < 6; i++ )
1288 pOleMenuDescriptor->mgw.width[i] = lpMenuWidths->width[i];
1290 pOleMenuDescriptor->hmenuCombined = hmenuCombined;
1291 pOleMenuDescriptor->bIsServerItem = FALSE;
1292 GlobalUnlock( hOleMenu );
1297 /***********************************************************************
1298 * OleDestroyMenuDescriptor [OLE32.@]
1299 * Destroy the shared menu descriptor
1301 HRESULT WINAPI OleDestroyMenuDescriptor(
1302 HOLEMENU hmenuDescriptor)
1304 if ( hmenuDescriptor )
1305 GlobalFree( hmenuDescriptor );
1309 /***********************************************************************
1310 * OleSetMenuDescriptor [OLE32.@]
1311 * Installs or removes OLE dispatching code for the containers frame window
1312 * FIXME: The lpFrame and lpActiveObject parameters are currently ignored
1313 * OLE should install context sensitive help F1 filtering for the app when
1314 * these are non null.
1317 * hOleMenu Handle to composite menu descriptor
1318 * hwndFrame Handle to containers frame window
1319 * hwndActiveObject Handle to objects in-place activation window
1320 * lpFrame Pointer to IOleInPlaceFrame on containers window
1321 * lpActiveObject Pointer to IOleInPlaceActiveObject on active in-place object
1324 * S_OK - menu installed correctly
1325 * E_FAIL, E_INVALIDARG, E_UNEXPECTED - failure
1327 HRESULT WINAPI OleSetMenuDescriptor(
1330 HWND hwndActiveObject,
1331 LPOLEINPLACEFRAME lpFrame,
1332 LPOLEINPLACEACTIVEOBJECT lpActiveObject)
1334 OleMenuDescriptor *pOleMenuDescriptor = NULL;
1337 if ( !hwndFrame || (hOleMenu && !hwndActiveObject) )
1338 return E_INVALIDARG;
1340 if ( lpFrame || lpActiveObject )
1342 FIXME("(%p, %p, %p, %p, %p), Context sensitive help filtering not implemented!\n",
1350 /* Set up a message hook to intercept the containers frame window messages.
1351 * The message filter is responsible for dispatching menu messages from the
1352 * shared menu which are intended for the object.
1355 if ( hOleMenu ) /* Want to install dispatching code */
1357 /* If OLEMenu hooks are already installed for this thread, fail
1358 * Note: This effectively means that OleSetMenuDescriptor cannot
1359 * be called twice in succession on the same frame window
1360 * without first calling it with a null hOleMenu to uninstall */
1361 if ( OLEMenu_IsHookInstalled( GetCurrentThreadId() ) )
1364 /* Get the menu descriptor */
1365 pOleMenuDescriptor = (OleMenuDescriptor *) GlobalLock( hOleMenu );
1366 if ( !pOleMenuDescriptor )
1367 return E_UNEXPECTED;
1369 /* Update the menu descriptor */
1370 pOleMenuDescriptor->hwndFrame = hwndFrame;
1371 pOleMenuDescriptor->hwndActiveObject = hwndActiveObject;
1373 GlobalUnlock( hOleMenu );
1374 pOleMenuDescriptor = NULL;
1376 /* Add a menu descriptor windows property to the frame window */
1377 SetPropA( hwndFrame, "PROP_OLEMenuDescriptor", hOleMenu );
1379 /* Install thread scope message hooks for WH_GETMESSAGE and WH_CALLWNDPROC */
1380 if ( !OLEMenu_InstallHooks( GetCurrentThreadId() ) )
1383 else /* Want to uninstall dispatching code */
1385 /* Uninstall the hooks */
1386 if ( !OLEMenu_UnInstallHooks( GetCurrentThreadId() ) )
1389 /* Remove the menu descriptor property from the frame window */
1390 RemovePropA( hwndFrame, "PROP_OLEMenuDescriptor" );
1396 /******************************************************************************
1397 * IsAccelerator [OLE32.@]
1398 * Mostly copied from controls/menu.c TranslateAccelerator implementation
1400 BOOL WINAPI IsAccelerator(HACCEL hAccel, int cAccelEntries, LPMSG lpMsg, WORD* lpwCmd)
1405 if(!lpMsg) return FALSE;
1408 WARN_(accel)("NULL accel handle\n");
1411 if((lpMsg->message != WM_KEYDOWN &&
1412 lpMsg->message != WM_KEYUP &&
1413 lpMsg->message != WM_SYSKEYDOWN &&
1414 lpMsg->message != WM_SYSKEYUP &&
1415 lpMsg->message != WM_CHAR)) return FALSE;
1416 lpAccelTbl = HeapAlloc(GetProcessHeap(), 0, cAccelEntries * sizeof(ACCEL));
1417 if (NULL == lpAccelTbl)
1421 if (CopyAcceleratorTableW(hAccel, lpAccelTbl, cAccelEntries) != cAccelEntries)
1423 WARN_(accel)("CopyAcceleratorTableW failed\n");
1424 HeapFree(GetProcessHeap(), 0, lpAccelTbl);
1428 TRACE_(accel)("hAccel=%p, cAccelEntries=%d,"
1429 "msg->hwnd=%p, msg->message=%04x, wParam=%08x, lParam=%08lx\n",
1430 hAccel, cAccelEntries,
1431 lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam);
1432 for(i = 0; i < cAccelEntries; i++)
1434 if(lpAccelTbl[i].key != lpMsg->wParam)
1437 if(lpMsg->message == WM_CHAR)
1439 if(!(lpAccelTbl[i].fVirt & FALT) && !(lpAccelTbl[i].fVirt & FVIRTKEY))
1441 TRACE_(accel)("found accel for WM_CHAR: ('%c')\n", lpMsg->wParam & 0xff);
1447 if(lpAccelTbl[i].fVirt & FVIRTKEY)
1450 TRACE_(accel)("found accel for virt_key %04x (scan %04x)\n",
1451 lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff);
1452 if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
1453 if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
1454 if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
1455 if(mask == (lpAccelTbl[i].fVirt & (FSHIFT | FCONTROL | FALT))) goto found;
1456 TRACE_(accel)("incorrect SHIFT/CTRL/ALT-state\n");
1460 if(!(lpMsg->lParam & 0x01000000)) /* no special_key */
1462 if((lpAccelTbl[i].fVirt & FALT) && (lpMsg->lParam & 0x20000000))
1463 { /* ^^ ALT pressed */
1464 TRACE_(accel)("found accel for Alt-%c\n", lpMsg->wParam & 0xff);
1472 WARN_(accel)("couldn't translate accelerator key\n");
1473 HeapFree(GetProcessHeap(), 0, lpAccelTbl);
1477 if(lpwCmd) *lpwCmd = lpAccelTbl[i].cmd;
1478 HeapFree(GetProcessHeap(), 0, lpAccelTbl);
1482 /***********************************************************************
1483 * ReleaseStgMedium [OLE32.@]
1485 void WINAPI ReleaseStgMedium(
1488 switch (pmedium->tymed)
1492 if ( (pmedium->pUnkForRelease==0) &&
1493 (pmedium->u.hGlobal!=0) )
1494 GlobalFree(pmedium->u.hGlobal);
1499 if (pmedium->u.lpszFileName!=0)
1501 if (pmedium->pUnkForRelease==0)
1503 DeleteFileW(pmedium->u.lpszFileName);
1506 CoTaskMemFree(pmedium->u.lpszFileName);
1512 if (pmedium->u.pstm!=0)
1514 IStream_Release(pmedium->u.pstm);
1518 case TYMED_ISTORAGE:
1520 if (pmedium->u.pstg!=0)
1522 IStorage_Release(pmedium->u.pstg);
1528 if ( (pmedium->pUnkForRelease==0) &&
1529 (pmedium->u.hBitmap!=0) )
1530 DeleteObject(pmedium->u.hBitmap);
1535 if ( (pmedium->pUnkForRelease==0) &&
1536 (pmedium->u.hMetaFilePict!=0) )
1538 LPMETAFILEPICT pMP = GlobalLock(pmedium->u.hMetaFilePict);
1539 DeleteMetaFile(pMP->hMF);
1540 GlobalUnlock(pmedium->u.hMetaFilePict);
1541 GlobalFree(pmedium->u.hMetaFilePict);
1547 if ( (pmedium->pUnkForRelease==0) &&
1548 (pmedium->u.hEnhMetaFile!=0) )
1550 DeleteEnhMetaFile(pmedium->u.hEnhMetaFile);
1558 pmedium->tymed=TYMED_NULL;
1561 * After cleaning up, the unknown is released
1563 if (pmedium->pUnkForRelease!=0)
1565 IUnknown_Release(pmedium->pUnkForRelease);
1566 pmedium->pUnkForRelease = 0;
1571 * OLEDD_Initialize()
1573 * Initializes the OLE drag and drop data structures.
1575 static void OLEDD_Initialize()
1579 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
1580 wndClass.style = CS_GLOBALCLASS;
1581 wndClass.lpfnWndProc = OLEDD_DragTrackerWindowProc;
1582 wndClass.cbClsExtra = 0;
1583 wndClass.cbWndExtra = sizeof(TrackerWindowInfo*);
1584 wndClass.hCursor = 0;
1585 wndClass.hbrBackground = 0;
1586 wndClass.lpszClassName = OLEDD_DRAGTRACKERCLASS;
1588 RegisterClassA (&wndClass);
1592 * OLEDD_UnInitialize()
1594 * Releases the OLE drag and drop data structures.
1596 static void OLEDD_UnInitialize()
1599 * Simply empty the list.
1601 while (targetListHead!=NULL)
1603 RevokeDragDrop(targetListHead->hwndTarget);
1608 * OLEDD_InsertDropTarget()
1610 * Insert the target node in the tree.
1612 static void OLEDD_InsertDropTarget(DropTargetNode* nodeToAdd)
1614 DropTargetNode* curNode;
1615 DropTargetNode** parentNodeLink;
1618 * Iterate the tree to find the insertion point.
1620 curNode = targetListHead;
1621 parentNodeLink = &targetListHead;
1623 while (curNode!=NULL)
1625 if (nodeToAdd->hwndTarget<curNode->hwndTarget)
1628 * If the node we want to add has a smaller HWND, go left
1630 parentNodeLink = &curNode->prevDropTarget;
1631 curNode = curNode->prevDropTarget;
1633 else if (nodeToAdd->hwndTarget>curNode->hwndTarget)
1636 * If the node we want to add has a larger HWND, go right
1638 parentNodeLink = &curNode->nextDropTarget;
1639 curNode = curNode->nextDropTarget;
1644 * The item was found in the list. It shouldn't have been there
1652 * If we get here, we have found a spot for our item. The parentNodeLink
1653 * pointer points to the pointer that we have to modify.
1654 * The curNode should be NULL. We just have to establish the link and Voila!
1656 assert(curNode==NULL);
1657 assert(parentNodeLink!=NULL);
1658 assert(*parentNodeLink==NULL);
1660 *parentNodeLink=nodeToAdd;
1664 * OLEDD_ExtractDropTarget()
1666 * Removes the target node from the tree.
1668 static DropTargetNode* OLEDD_ExtractDropTarget(HWND hwndOfTarget)
1670 DropTargetNode* curNode;
1671 DropTargetNode** parentNodeLink;
1674 * Iterate the tree to find the insertion point.
1676 curNode = targetListHead;
1677 parentNodeLink = &targetListHead;
1679 while (curNode!=NULL)
1681 if (hwndOfTarget<curNode->hwndTarget)
1684 * If the node we want to add has a smaller HWND, go left
1686 parentNodeLink = &curNode->prevDropTarget;
1687 curNode = curNode->prevDropTarget;
1689 else if (hwndOfTarget>curNode->hwndTarget)
1692 * If the node we want to add has a larger HWND, go right
1694 parentNodeLink = &curNode->nextDropTarget;
1695 curNode = curNode->nextDropTarget;
1700 * The item was found in the list. Detach it from it's parent and
1701 * re-insert it's kids in the tree.
1703 assert(parentNodeLink!=NULL);
1704 assert(*parentNodeLink==curNode);
1707 * We arbitrately re-attach the left sub-tree to the parent.
1709 *parentNodeLink = curNode->prevDropTarget;
1712 * And we re-insert the right subtree
1714 if (curNode->nextDropTarget!=NULL)
1716 OLEDD_InsertDropTarget(curNode->nextDropTarget);
1720 * The node we found is still a valid node once we complete
1721 * the unlinking of the kids.
1723 curNode->nextDropTarget=NULL;
1724 curNode->prevDropTarget=NULL;
1731 * If we get here, the node is not in the tree
1737 * OLEDD_FindDropTarget()
1739 * Finds information about the drop target.
1741 static DropTargetNode* OLEDD_FindDropTarget(HWND hwndOfTarget)
1743 DropTargetNode* curNode;
1746 * Iterate the tree to find the HWND value.
1748 curNode = targetListHead;
1750 while (curNode!=NULL)
1752 if (hwndOfTarget<curNode->hwndTarget)
1755 * If the node we want to add has a smaller HWND, go left
1757 curNode = curNode->prevDropTarget;
1759 else if (hwndOfTarget>curNode->hwndTarget)
1762 * If the node we want to add has a larger HWND, go right
1764 curNode = curNode->nextDropTarget;
1769 * The item was found in the list.
1776 * If we get here, the item is not in the list
1782 * OLEDD_DragTrackerWindowProc()
1784 * This method is the WindowProcedure of the drag n drop tracking
1785 * window. During a drag n Drop operation, an invisible window is created
1786 * to receive the user input and act upon it. This procedure is in charge
1789 static LRESULT WINAPI OLEDD_DragTrackerWindowProc(
1799 LPCREATESTRUCTA createStruct = (LPCREATESTRUCTA)lParam;
1801 SetWindowLongA(hwnd, 0, (LONG)createStruct->lpCreateParams);
1808 TrackerWindowInfo* trackerInfo = (TrackerWindowInfo*)GetWindowLongA(hwnd, 0);
1812 * Get the current mouse position in screen coordinates.
1814 mousePos.x = LOWORD(lParam);
1815 mousePos.y = HIWORD(lParam);
1816 ClientToScreen(hwnd, &mousePos);
1819 * Track the movement of the mouse.
1821 OLEDD_TrackMouseMove(trackerInfo, mousePos, wParam);
1828 case WM_LBUTTONDOWN:
1829 case WM_MBUTTONDOWN:
1830 case WM_RBUTTONDOWN:
1832 TrackerWindowInfo* trackerInfo = (TrackerWindowInfo*)GetWindowLongA(hwnd, 0);
1836 * Get the current mouse position in screen coordinates.
1838 mousePos.x = LOWORD(lParam);
1839 mousePos.y = HIWORD(lParam);
1840 ClientToScreen(hwnd, &mousePos);
1843 * Notify everyone that the button state changed
1844 * TODO: Check if the "escape" key was pressed.
1846 OLEDD_TrackStateChange(trackerInfo, mousePos, wParam);
1853 * This is a window proc after all. Let's call the default.
1855 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
1859 * OLEDD_TrackMouseMove()
1861 * This method is invoked while a drag and drop operation is in effect.
1862 * it will generate the appropriate callbacks in the drop source
1863 * and drop target. It will also provide the expected feedback to
1867 * trackerInfo - Pointer to the structure identifying the
1868 * drag & drop operation that is currently
1870 * mousePos - Current position of the mouse in screen
1872 * keyState - Contains the state of the shift keys and the
1873 * mouse buttons (MK_LBUTTON and the like)
1875 static void OLEDD_TrackMouseMove(
1876 TrackerWindowInfo* trackerInfo,
1880 HWND hwndNewTarget = 0;
1884 * Get the handle of the window under the mouse
1886 hwndNewTarget = WindowFromPoint(mousePos);
1889 * Every time, we re-initialize the effects passed to the
1890 * IDropTarget to the effects allowed by the source.
1892 *trackerInfo->pdwEffect = trackerInfo->dwOKEffect;
1895 * If we are hovering over the same target as before, send the
1896 * DragOver notification
1898 if ( (trackerInfo->curDragTarget != 0) &&
1899 (trackerInfo->curTargetHWND == hwndNewTarget) )
1901 POINTL mousePosParam;
1904 * The documentation tells me that the coordinate should be in the target
1905 * window's coordinate space. However, the tests I made tell me the
1906 * coordinates should be in screen coordinates.
1908 mousePosParam.x = mousePos.x;
1909 mousePosParam.y = mousePos.y;
1911 IDropTarget_DragOver(trackerInfo->curDragTarget,
1914 trackerInfo->pdwEffect);
1918 DropTargetNode* newDropTargetNode = 0;
1921 * If we changed window, we have to notify our old target and check for
1924 if (trackerInfo->curDragTarget!=0)
1926 IDropTarget_DragLeave(trackerInfo->curDragTarget);
1930 * Make sure we're hovering over a window.
1932 if (hwndNewTarget!=0)
1935 * Find-out if there is a drag target under the mouse
1937 HWND nexttar = hwndNewTarget;
1938 trackerInfo->curTargetHWND = hwndNewTarget;
1941 newDropTargetNode = OLEDD_FindDropTarget(nexttar);
1942 } while (!newDropTargetNode && (nexttar = GetParent(nexttar)) != 0);
1943 if(nexttar) hwndNewTarget = nexttar;
1945 trackerInfo->curDragTargetHWND = hwndNewTarget;
1946 trackerInfo->curDragTarget = newDropTargetNode ? newDropTargetNode->dropTarget : 0;
1949 * If there is, notify it that we just dragged-in
1951 if (trackerInfo->curDragTarget!=0)
1953 POINTL mousePosParam;
1956 * The documentation tells me that the coordinate should be in the target
1957 * window's coordinate space. However, the tests I made tell me the
1958 * coordinates should be in screen coordinates.
1960 mousePosParam.x = mousePos.x;
1961 mousePosParam.y = mousePos.y;
1963 IDropTarget_DragEnter(trackerInfo->curDragTarget,
1964 trackerInfo->dataObject,
1967 trackerInfo->pdwEffect);
1973 * The mouse is not over a window so we don't track anything.
1975 trackerInfo->curDragTargetHWND = 0;
1976 trackerInfo->curTargetHWND = 0;
1977 trackerInfo->curDragTarget = 0;
1982 * Now that we have done that, we have to tell the source to give
1983 * us feedback on the work being done by the target. If we don't
1984 * have a target, simulate no effect.
1986 if (trackerInfo->curDragTarget==0)
1988 *trackerInfo->pdwEffect = DROPEFFECT_NONE;
1991 hr = IDropSource_GiveFeedback(trackerInfo->dropSource,
1992 *trackerInfo->pdwEffect);
1995 * When we ask for feedback from the drop source, sometimes it will
1996 * do all the necessary work and sometimes it will not handle it
1997 * when that's the case, we must display the standard drag and drop
2000 if (hr==DRAGDROP_S_USEDEFAULTCURSORS)
2002 if (*trackerInfo->pdwEffect & DROPEFFECT_MOVE)
2004 SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(1)));
2006 else if (*trackerInfo->pdwEffect & DROPEFFECT_COPY)
2008 SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(2)));
2010 else if (*trackerInfo->pdwEffect & DROPEFFECT_LINK)
2012 SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(3)));
2016 SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(0)));
2022 * OLEDD_TrackStateChange()
2024 * This method is invoked while a drag and drop operation is in effect.
2025 * It is used to notify the drop target/drop source callbacks when
2026 * the state of the keyboard or mouse button change.
2029 * trackerInfo - Pointer to the structure identifying the
2030 * drag & drop operation that is currently
2032 * mousePos - Current position of the mouse in screen
2034 * keyState - Contains the state of the shift keys and the
2035 * mouse buttons (MK_LBUTTON and the like)
2037 static void OLEDD_TrackStateChange(
2038 TrackerWindowInfo* trackerInfo,
2043 * Ask the drop source what to do with the operation.
2045 trackerInfo->returnValue = IDropSource_QueryContinueDrag(
2046 trackerInfo->dropSource,
2047 trackerInfo->escPressed,
2051 * All the return valued will stop the operation except the S_OK
2054 if (trackerInfo->returnValue!=S_OK)
2057 * Make sure the message loop in DoDragDrop stops
2059 trackerInfo->trackingDone = TRUE;
2062 * Release the mouse in case the drop target decides to show a popup
2063 * or a menu or something.
2068 * If we end-up over a target, drop the object in the target or
2069 * inform the target that the operation was cancelled.
2071 if (trackerInfo->curDragTarget!=0)
2073 switch (trackerInfo->returnValue)
2076 * If the source wants us to complete the operation, we tell
2077 * the drop target that we just dropped the object in it.
2079 case DRAGDROP_S_DROP:
2081 POINTL mousePosParam;
2084 * The documentation tells me that the coordinate should be
2085 * in the target window's coordinate space. However, the tests
2086 * I made tell me the coordinates should be in screen coordinates.
2088 mousePosParam.x = mousePos.x;
2089 mousePosParam.y = mousePos.y;
2091 IDropTarget_Drop(trackerInfo->curDragTarget,
2092 trackerInfo->dataObject,
2095 trackerInfo->pdwEffect);
2099 * If the source told us that we should cancel, fool the drop
2100 * target by telling it that the mouse left it's window.
2101 * Also set the drop effect to "NONE" in case the application
2102 * ignores the result of DoDragDrop.
2104 case DRAGDROP_S_CANCEL:
2105 IDropTarget_DragLeave(trackerInfo->curDragTarget);
2106 *trackerInfo->pdwEffect = DROPEFFECT_NONE;
2114 * OLEDD_GetButtonState()
2116 * This method will use the current state of the keyboard to build
2117 * a button state mask equivalent to the one passed in the
2118 * WM_MOUSEMOVE wParam.
2120 static DWORD OLEDD_GetButtonState()
2122 BYTE keyboardState[256];
2125 GetKeyboardState(keyboardState);
2127 if ( (keyboardState[VK_SHIFT] & 0x80) !=0)
2128 keyMask |= MK_SHIFT;
2130 if ( (keyboardState[VK_CONTROL] & 0x80) !=0)
2131 keyMask |= MK_CONTROL;
2133 if ( (keyboardState[VK_LBUTTON] & 0x80) !=0)
2134 keyMask |= MK_LBUTTON;
2136 if ( (keyboardState[VK_RBUTTON] & 0x80) !=0)
2137 keyMask |= MK_RBUTTON;
2139 if ( (keyboardState[VK_MBUTTON] & 0x80) !=0)
2140 keyMask |= MK_MBUTTON;
2146 * OLEDD_GetButtonState()
2148 * This method will read the default value of the registry key in
2149 * parameter and extract a DWORD value from it. The registry key value
2150 * can be in a string key or a DWORD key.
2153 * regKey - Key to read the default value from
2154 * pdwValue - Pointer to the location where the DWORD
2155 * value is returned. This value is not modified
2156 * if the value is not found.
2159 static void OLEUTL_ReadRegistryDWORDValue(
2168 lres = RegQueryValueExA(regKey,
2175 if (lres==ERROR_SUCCESS)
2180 *pdwValue = *(DWORD*)buffer;
2185 *pdwValue = (DWORD)strtoul(buffer, NULL, 10);
2191 /******************************************************************************
2194 * The operation of this function is documented literally in the WinAPI
2195 * documentation to involve a QueryInterface for the IViewObject interface,
2196 * followed by a call to IViewObject::Draw.
2198 HRESULT WINAPI OleDraw(
2205 IViewObject *viewobject;
2207 hres = IUnknown_QueryInterface(pUnk,
2209 (void**)&viewobject);
2211 if (SUCCEEDED(hres))
2215 rectl.left = lprcBounds->left;
2216 rectl.right = lprcBounds->right;
2217 rectl.top = lprcBounds->top;
2218 rectl.bottom = lprcBounds->bottom;
2219 hres = IViewObject_Draw(viewobject, dwAspect, -1, 0, 0, 0, hdcDraw, &rectl, 0, 0, 0);
2221 IViewObject_Release(viewobject);
2226 return DV_E_NOIVIEWOBJECT;
2230 /***********************************************************************
2231 * OleTranslateAccelerator [OLE32.@]
2233 HRESULT WINAPI OleTranslateAccelerator (LPOLEINPLACEFRAME lpFrame,
2234 LPOLEINPLACEFRAMEINFO lpFrameInfo, LPMSG lpmsg)
2238 TRACE("(%p,%p,%p)\n", lpFrame, lpFrameInfo, lpmsg);
2240 if (IsAccelerator(lpFrameInfo->haccel,lpFrameInfo->cAccelEntries,lpmsg,&wID))
2241 return IOleInPlaceFrame_TranslateAccelerator(lpFrame,lpmsg,wID);
2246 /******************************************************************************
2247 * OleCreate [OLE32.@]
2250 HRESULT WINAPI OleCreate(
2254 LPFORMATETC pFormatEtc,
2255 LPOLECLIENTSITE pClientSite,
2259 HRESULT hres, hres1;
2260 IUnknown * pUnk = NULL;
2262 FIXME("\n\t%s\n\t%s semi-stub!\n", debugstr_guid(rclsid), debugstr_guid(riid));
2264 if (SUCCEEDED((hres = CoCreateInstance(rclsid, 0, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER|CLSCTX_LOCAL_SERVER , riid, (LPVOID*)&pUnk))))
2269 IPersistStorage * pPS;
2270 if (SUCCEEDED((hres = IUnknown_QueryInterface( pUnk, &IID_IOleObject, (LPVOID*)&pOE))))
2272 TRACE("trying to set clientsite %p\n", pClientSite);
2273 hres1 = IOleObject_SetClientSite(pOE, pClientSite);
2274 TRACE("-- result 0x%08lx\n", hres1);
2275 IOleObject_Release(pOE);
2277 if (SUCCEEDED((hres = IUnknown_QueryInterface( pUnk, &IID_IPersistStorage, (LPVOID*)&pPS))))
2279 TRACE("trying to set stg %p\n", pStg);
2280 hres1 = IPersistStorage_InitNew(pPS, pStg);
2281 TRACE("-- result 0x%08lx\n", hres1);
2282 IPersistStorage_Release(pPS);
2289 TRACE("-- %p \n", pUnk);
2293 /******************************************************************************
2294 * OleSetAutoConvert [OLE32.@]
2296 HRESULT WINAPI OleSetAutoConvert(REFCLSID clsidOld, REFCLSID clsidNew)
2298 static const WCHAR wszAutoConvertTo[] = {'A','u','t','o','C','o','n','v','e','r','t','T','o',0};
2300 WCHAR szClsidNew[CHARS_IN_GUID];
2303 TRACE("(%s,%s)\n", debugstr_guid(clsidOld), debugstr_guid(clsidNew));
2305 if (COM_OpenKeyForCLSID(clsidOld, KEY_READ | KEY_WRITE, &hkey))
2307 res = REGDB_E_CLASSNOTREG;
2310 StringFromGUID2(clsidNew, szClsidNew, CHARS_IN_GUID);
2311 if (RegSetValueW(hkey, wszAutoConvertTo, REG_SZ, szClsidNew, (strlenW(szClsidNew)+1) * sizeof(WCHAR)))
2313 res = REGDB_E_WRITEREGDB;
2318 if (hkey) RegCloseKey(hkey);
2322 /******************************************************************************
2323 * OleDoAutoConvert [OLE32.@]
2325 HRESULT WINAPI OleDoAutoConvert(LPSTORAGE pStg, LPCLSID pClsidNew)
2327 FIXME("(%p,%p) : stub\n",pStg,pClsidNew);
2331 /******************************************************************************
2332 * OleDoAutoConvert [OLE2.79]
2334 HRESULT WINAPI OleDoAutoConvert16(LPSTORAGE pStg, LPCLSID pClsidNew)
2336 FIXME("(%p,%p) : stub\n",pStg,pClsidNew);
2340 /******************************************************************************
2341 * OleIsRunning [OLE32.@]
2343 BOOL WINAPI OleIsRunning(LPOLEOBJECT pObject)
2345 IRunnableObject *pRunnable;
2349 TRACE("(%p)\n", pObject);
2351 hr = IOleObject_QueryInterface(pObject, &IID_IRunnableObject, (void **)&pRunnable);
2354 running = IRunnableObject_IsRunning(pRunnable);
2355 IRunnableObject_Release(pRunnable);
2359 /***********************************************************************
2360 * OLE_FreeClipDataArray [internal]
2363 * frees the data associated with an array of CLIPDATAs
2365 static void OLE_FreeClipDataArray(ULONG count, CLIPDATA * pClipDataArray)
2368 for (i = 0; i < count; i++)
2369 if (pClipDataArray[i].pClipData)
2370 CoTaskMemFree(pClipDataArray[i].pClipData);
2373 /***********************************************************************
2374 * PropSysAllocString [OLE32.@]
2376 * Basically a copy of SysAllocStringLen.
2378 BSTR WINAPI PropSysAllocString(LPCOLESTR str)
2382 WCHAR* stringBuffer;
2387 len = lstrlenW(str);
2389 * Find the length of the buffer passed-in in bytes.
2391 bufferSize = len * sizeof (WCHAR);
2394 * Allocate a new buffer to hold the string.
2395 * don't forget to keep an empty spot at the beginning of the
2396 * buffer for the character count and an extra character at the
2399 newBuffer = HeapAlloc(GetProcessHeap(), 0,
2400 bufferSize + sizeof(WCHAR) + sizeof(DWORD));
2403 * If the memory allocation failed, return a null pointer.
2409 * Copy the length of the string in the placeholder.
2411 *newBuffer = bufferSize;
2414 * Skip the byte count.
2419 * Copy the information in the buffer.
2420 * Since it is valid to pass a NULL pointer here, we'll initialize the
2421 * buffer to nul if it is the case.
2424 memcpy(newBuffer, str, bufferSize);
2426 memset(newBuffer, 0, bufferSize);
2429 * Make sure that there is a nul character at the end of the
2432 stringBuffer = (WCHAR*)newBuffer;
2433 stringBuffer[len] = L'\0';
2435 return (LPWSTR)stringBuffer;
2438 /***********************************************************************
2439 * PropSysFreeString [OLE32.@]
2441 * Copy of SysFreeString.
2443 void WINAPI PropSysFreeString(LPOLESTR str)
2445 DWORD* bufferPointer;
2447 /* NULL is a valid parameter */
2451 * We have to be careful when we free a BSTR pointer, it points to
2452 * the beginning of the string but it skips the byte count contained
2453 * before the string.
2455 bufferPointer = (DWORD*)str;
2460 * Free the memory from its "real" origin.
2462 HeapFree(GetProcessHeap(), 0, bufferPointer);
2465 /******************************************************************************
2466 * Check if a PROPVARIANT's type is valid.
2468 static inline HRESULT PROPVARIANT_ValidateType(VARTYPE vt)
2494 case VT_STREAMED_OBJECT:
2495 case VT_STORED_OBJECT:
2496 case VT_BLOB_OBJECT:
2499 case VT_I2|VT_VECTOR:
2500 case VT_I4|VT_VECTOR:
2501 case VT_R4|VT_VECTOR:
2502 case VT_R8|VT_VECTOR:
2503 case VT_CY|VT_VECTOR:
2504 case VT_DATE|VT_VECTOR:
2505 case VT_BSTR|VT_VECTOR:
2506 case VT_ERROR|VT_VECTOR:
2507 case VT_BOOL|VT_VECTOR:
2508 case VT_VARIANT|VT_VECTOR:
2509 case VT_UI1|VT_VECTOR:
2510 case VT_UI2|VT_VECTOR:
2511 case VT_UI4|VT_VECTOR:
2512 case VT_I8|VT_VECTOR:
2513 case VT_UI8|VT_VECTOR:
2514 case VT_LPSTR|VT_VECTOR:
2515 case VT_LPWSTR|VT_VECTOR:
2516 case VT_FILETIME|VT_VECTOR:
2517 case VT_CF|VT_VECTOR:
2518 case VT_CLSID|VT_VECTOR:
2521 WARN("Bad type %d\n", vt);
2522 return STG_E_INVALIDPARAMETER;
2525 /***********************************************************************
2526 * PropVariantClear [OLE32.@]
2528 HRESULT WINAPI PropVariantClear(PROPVARIANT * pvar) /* [in/out] */
2532 TRACE("(%p)\n", pvar);
2537 hr = PROPVARIANT_ValidateType(pvar->vt);
2544 case VT_STREAMED_OBJECT:
2546 case VT_STORED_OBJECT:
2547 if (pvar->u.pStream)
2548 IUnknown_Release(pvar->u.pStream);
2553 /* pick an arbitary typed pointer - we don't care about the type
2554 * as we are just freeing it */
2555 CoTaskMemFree(pvar->u.puuid);
2558 case VT_BLOB_OBJECT:
2559 CoTaskMemFree(pvar->u.blob.pBlobData);
2562 if (pvar->u.bstrVal)
2563 PropSysFreeString(pvar->u.bstrVal);
2566 if (pvar->u.pclipdata)
2568 OLE_FreeClipDataArray(1, pvar->u.pclipdata);
2569 CoTaskMemFree(pvar->u.pclipdata);
2573 if (pvar->vt & VT_VECTOR)
2577 switch (pvar->vt & ~VT_VECTOR)
2580 FreePropVariantArray(pvar->u.capropvar.cElems, pvar->u.capropvar.pElems);
2583 OLE_FreeClipDataArray(pvar->u.caclipdata.cElems, pvar->u.caclipdata.pElems);
2586 for (i = 0; i < pvar->u.cabstr.cElems; i++)
2587 PropSysFreeString(pvar->u.cabstr.pElems[i]);
2590 for (i = 0; i < pvar->u.calpstr.cElems; i++)
2591 CoTaskMemFree(pvar->u.calpstr.pElems[i]);
2594 for (i = 0; i < pvar->u.calpwstr.cElems; i++)
2595 CoTaskMemFree(pvar->u.calpwstr.pElems[i]);
2598 if (pvar->vt & ~VT_VECTOR)
2600 /* pick an arbitary VT_VECTOR structure - they all have the same
2602 CoTaskMemFree(pvar->u.capropvar.pElems);
2606 WARN("Invalid/unsupported type %d\n", pvar->vt);
2609 ZeroMemory(pvar, sizeof(*pvar));
2614 /***********************************************************************
2615 * PropVariantCopy [OLE32.@]
2617 HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, /* [out] */
2618 const PROPVARIANT *pvarSrc) /* [in] */
2623 TRACE("(%p, %p)\n", pvarDest, pvarSrc);
2625 hr = PROPVARIANT_ValidateType(pvarSrc->vt);
2629 /* this will deal with most cases */
2630 CopyMemory(pvarDest, pvarSrc, sizeof(*pvarDest));
2635 case VT_STREAMED_OBJECT:
2637 case VT_STORED_OBJECT:
2638 IUnknown_AddRef((LPUNKNOWN)pvarDest->u.pStream);
2641 pvarDest->u.puuid = CoTaskMemAlloc(sizeof(CLSID));
2642 CopyMemory(pvarDest->u.puuid, pvarSrc->u.puuid, sizeof(CLSID));
2645 len = strlen(pvarSrc->u.pszVal);
2646 pvarDest->u.pszVal = CoTaskMemAlloc((len+1)*sizeof(CHAR));
2647 CopyMemory(pvarDest->u.pszVal, pvarSrc->u.pszVal, (len+1)*sizeof(CHAR));
2650 len = lstrlenW(pvarSrc->u.pwszVal);
2651 pvarDest->u.pwszVal = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
2652 CopyMemory(pvarDest->u.pwszVal, pvarSrc->u.pwszVal, (len+1)*sizeof(WCHAR));
2655 case VT_BLOB_OBJECT:
2656 if (pvarSrc->u.blob.pBlobData)
2658 len = pvarSrc->u.blob.cbSize;
2659 pvarDest->u.blob.pBlobData = CoTaskMemAlloc(len);
2660 CopyMemory(pvarDest->u.blob.pBlobData, pvarSrc->u.blob.pBlobData, len);
2664 pvarDest->u.bstrVal = PropSysAllocString(pvarSrc->u.bstrVal);
2667 if (pvarSrc->u.pclipdata)
2669 len = pvarSrc->u.pclipdata->cbSize - sizeof(pvarSrc->u.pclipdata->ulClipFmt);
2670 CoTaskMemAlloc(len);
2671 CopyMemory(pvarDest->u.pclipdata->pClipData, pvarSrc->u.pclipdata->pClipData, len);
2675 if (pvarSrc->vt & VT_VECTOR)
2680 switch(pvarSrc->vt & ~VT_VECTOR)
2682 case VT_I1: elemSize = sizeof(pvarSrc->u.cVal); break;
2683 case VT_UI1: elemSize = sizeof(pvarSrc->u.bVal); break;
2684 case VT_I2: elemSize = sizeof(pvarSrc->u.iVal); break;
2685 case VT_UI2: elemSize = sizeof(pvarSrc->u.uiVal); break;
2686 case VT_BOOL: elemSize = sizeof(pvarSrc->u.boolVal); break;
2687 case VT_I4: elemSize = sizeof(pvarSrc->u.lVal); break;
2688 case VT_UI4: elemSize = sizeof(pvarSrc->u.ulVal); break;
2689 case VT_R4: elemSize = sizeof(pvarSrc->u.fltVal); break;
2690 case VT_R8: elemSize = sizeof(pvarSrc->u.dblVal); break;
2691 case VT_ERROR: elemSize = sizeof(pvarSrc->u.scode); break;
2692 case VT_I8: elemSize = sizeof(pvarSrc->u.hVal); break;
2693 case VT_UI8: elemSize = sizeof(pvarSrc->u.uhVal); break;
2694 case VT_CY: elemSize = sizeof(pvarSrc->u.cyVal); break;
2695 case VT_DATE: elemSize = sizeof(pvarSrc->u.date); break;
2696 case VT_FILETIME: elemSize = sizeof(pvarSrc->u.filetime); break;
2697 case VT_CLSID: elemSize = sizeof(*pvarSrc->u.puuid); break;
2698 case VT_CF: elemSize = sizeof(*pvarSrc->u.pclipdata); break;
2699 case VT_BSTR: elemSize = sizeof(*pvarSrc->u.bstrVal); break;
2700 case VT_LPSTR: elemSize = sizeof(*pvarSrc->u.pszVal); break;
2701 case VT_LPWSTR: elemSize = sizeof(*pvarSrc->u.pwszVal); break;
2705 FIXME("Invalid element type: %ul\n", pvarSrc->vt & ~VT_VECTOR);
2706 return E_INVALIDARG;
2708 len = pvarSrc->u.capropvar.cElems;
2709 pvarDest->u.capropvar.pElems = CoTaskMemAlloc(len * elemSize);
2710 if (pvarSrc->vt == (VT_VECTOR | VT_VARIANT))
2712 for (i = 0; i < len; i++)
2713 PropVariantCopy(&pvarDest->u.capropvar.pElems[i], &pvarSrc->u.capropvar.pElems[i]);
2715 else if (pvarSrc->vt == (VT_VECTOR | VT_CF))
2717 FIXME("Copy clipformats\n");
2719 else if (pvarSrc->vt == (VT_VECTOR | VT_BSTR))
2721 for (i = 0; i < len; i++)
2722 pvarDest->u.cabstr.pElems[i] = PropSysAllocString(pvarSrc->u.cabstr.pElems[i]);
2724 else if (pvarSrc->vt == (VT_VECTOR | VT_LPSTR))
2727 for (i = 0; i < len; i++)
2729 strLen = lstrlenA(pvarSrc->u.calpstr.pElems[i]) + 1;
2730 pvarDest->u.calpstr.pElems[i] = CoTaskMemAlloc(strLen);
2731 memcpy(pvarDest->u.calpstr.pElems[i],
2732 pvarSrc->u.calpstr.pElems[i], strLen);
2735 else if (pvarSrc->vt == (VT_VECTOR | VT_LPWSTR))
2738 for (i = 0; i < len; i++)
2740 strLen = (lstrlenW(pvarSrc->u.calpwstr.pElems[i]) + 1) *
2742 pvarDest->u.calpstr.pElems[i] = CoTaskMemAlloc(strLen);
2743 memcpy(pvarDest->u.calpstr.pElems[i],
2744 pvarSrc->u.calpstr.pElems[i], strLen);
2748 CopyMemory(pvarDest->u.capropvar.pElems, pvarSrc->u.capropvar.pElems, len * elemSize);
2751 WARN("Invalid/unsupported type %d\n", pvarSrc->vt);
2757 /***********************************************************************
2758 * FreePropVariantArray [OLE32.@]
2760 HRESULT WINAPI FreePropVariantArray(ULONG cVariants, /* [in] */
2761 PROPVARIANT *rgvars) /* [in/out] */
2765 TRACE("(%lu, %p)\n", cVariants, rgvars);
2767 for(i = 0; i < cVariants; i++)
2768 PropVariantClear(&rgvars[i]);
2773 /******************************************************************************
2774 * DllDebugObjectRPCHook (OLE32.@)
2775 * turns on and off internal debugging, pointer is only used on macintosh
2778 BOOL WINAPI DllDebugObjectRPCHook(BOOL b, void *dummy)