4 * Copyright 1995 Martin von Loewis
5 * Copyright 1999 Francis Beaudet
6 * Copyright 1999 Noel Borthwick
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #define NONAMELESSUNION
33 #define NONAMELESSSTRUCT
47 #include "wine/winbase16.h"
48 #include "wine/wingdi16.h"
49 #include "wine/winuser16.h"
50 #include "ole32_main.h"
51 #include "compobj_private.h"
53 #include "wine/debug.h"
55 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
56 WINE_DECLARE_DEBUG_CHANNEL(accel
);
58 #define HICON_16(h32) (LOWORD(h32))
59 #define HICON_32(h16) ((HICON)(ULONG_PTR)(h16))
60 #define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
62 /******************************************************************************
63 * These are static/global variables and internal data structures that the
64 * OLE module uses to maintain it's state.
66 typedef struct tagDropTargetNode
69 IDropTarget
* dropTarget
;
70 struct tagDropTargetNode
* prevDropTarget
;
71 struct tagDropTargetNode
* nextDropTarget
;
74 typedef struct tagTrackerWindowInfo
76 IDataObject
* dataObject
;
77 IDropSource
* dropSource
;
84 HWND curTargetHWND
; /* window the mouse is hovering over */
85 HWND curDragTargetHWND
; /* might be a ancestor of curTargetHWND */
86 IDropTarget
* curDragTarget
;
89 typedef struct tagOleMenuDescriptor
/* OleMenuDescriptor */
91 HWND hwndFrame
; /* The containers frame window */
92 HWND hwndActiveObject
; /* The active objects window */
93 OLEMENUGROUPWIDTHS mgw
; /* OLE menu group widths for the shared menu */
94 HMENU hmenuCombined
; /* The combined menu */
95 BOOL bIsServerItem
; /* True if the currently open popup belongs to the server */
98 typedef struct tagOleMenuHookItem
/* OleMenu hook item in per thread hook list */
100 DWORD tid
; /* Thread Id */
101 HANDLE hHeap
; /* Heap this is allocated from */
102 HHOOK GetMsg_hHook
; /* message hook for WH_GETMESSAGE */
103 HHOOK CallWndProc_hHook
; /* message hook for WH_CALLWNDPROC */
104 struct tagOleMenuHookItem
*next
;
107 static OleMenuHookItem
*hook_list
;
110 * This is the lock count on the OLE library. It is controlled by the
111 * OLEInitialize/OLEUninitialize methods.
113 static ULONG OLE_moduleLockCount
= 0;
116 * Name of our registered window class.
118 static const char OLEDD_DRAGTRACKERCLASS
[] = "WineDragDropTracker32";
121 * This is the head of the Drop target container.
123 static DropTargetNode
* targetListHead
= NULL
;
125 /******************************************************************************
126 * These are the prototypes of miscelaneous utility methods
128 static void OLEUTL_ReadRegistryDWORDValue(HKEY regKey
, DWORD
* pdwValue
);
130 /******************************************************************************
131 * These are the prototypes of the utility methods used to manage a shared menu
133 static void OLEMenu_Initialize(void);
134 static void OLEMenu_UnInitialize(void);
135 BOOL
OLEMenu_InstallHooks( DWORD tid
);
136 BOOL
OLEMenu_UnInstallHooks( DWORD tid
);
137 OleMenuHookItem
* OLEMenu_IsHookInstalled( DWORD tid
);
138 static BOOL
OLEMenu_FindMainMenuIndex( HMENU hMainMenu
, HMENU hPopupMenu
, UINT
*pnPos
);
139 BOOL
OLEMenu_SetIsServerMenu( HMENU hmenu
, OleMenuDescriptor
*pOleMenuDescriptor
);
140 LRESULT CALLBACK
OLEMenu_CallWndProc(INT code
, WPARAM wParam
, LPARAM lParam
);
141 LRESULT CALLBACK
OLEMenu_GetMsgProc(INT code
, WPARAM wParam
, LPARAM lParam
);
143 /******************************************************************************
144 * These are the prototypes of the OLE Clipboard initialization methods (in clipboard.c)
146 void OLEClipbrd_UnInitialize(void);
147 void OLEClipbrd_Initialize(void);
149 /******************************************************************************
150 * These are the prototypes of the utility methods used for OLE Drag n Drop
152 static void OLEDD_Initialize(void);
153 static void OLEDD_UnInitialize(void);
154 static void OLEDD_InsertDropTarget(
155 DropTargetNode
* nodeToAdd
);
156 static DropTargetNode
* OLEDD_ExtractDropTarget(
158 static DropTargetNode
* OLEDD_FindDropTarget(
160 static LRESULT WINAPI
OLEDD_DragTrackerWindowProc(
165 static void OLEDD_TrackMouseMove(
166 TrackerWindowInfo
* trackerInfo
,
169 static void OLEDD_TrackStateChange(
170 TrackerWindowInfo
* trackerInfo
,
173 static DWORD
OLEDD_GetButtonState(void);
176 /******************************************************************************
177 * OleBuildVersion [OLE2.1]
178 * OleBuildVersion [OLE32.@]
180 DWORD WINAPI
OleBuildVersion(void)
182 TRACE("Returning version %d, build %d.\n", rmm
, rup
);
183 return (rmm
<<16)+rup
;
186 /***********************************************************************
187 * OleInitialize (OLE2.2)
188 * OleInitialize (OLE32.@)
190 HRESULT WINAPI
OleInitialize(LPVOID reserved
)
194 TRACE("(%p)\n", reserved
);
197 * The first duty of the OleInitialize is to initialize the COM libraries.
199 hr
= CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
202 * If the CoInitializeEx call failed, the OLE libraries can't be
209 * Then, it has to initialize the OLE specific modules.
213 * Object linking and Embedding
214 * In-place activation
216 if (OLE_moduleLockCount
==0)
219 * Initialize the libraries.
221 TRACE("() - Initializing the OLE libraries\n");
226 OLEClipbrd_Initialize();
236 OLEMenu_Initialize();
240 * Then, we increase the lock count on the OLE module.
242 OLE_moduleLockCount
++;
247 /******************************************************************************
248 * OleUninitialize [OLE2.3]
249 * OleUninitialize [OLE32.@]
251 void WINAPI
OleUninitialize(void)
256 * Decrease the lock count on the OLE module.
258 OLE_moduleLockCount
--;
261 * If we hit the bottom of the lock stack, free the libraries.
263 if (OLE_moduleLockCount
==0)
266 * Actually free the libraries.
268 TRACE("() - Freeing the last reference count\n");
273 OLEClipbrd_UnInitialize();
278 OLEDD_UnInitialize();
283 OLEMenu_UnInitialize();
287 * Then, uninitialize the COM libraries.
292 /******************************************************************************
293 * OleInitializeWOW [OLE32.@]
295 HRESULT WINAPI
OleInitializeWOW(DWORD x
) {
296 FIXME("(0x%08lx),stub!\n",x
);
300 /***********************************************************************
301 * RegisterDragDrop (OLE32.@)
303 HRESULT WINAPI
RegisterDragDrop(
305 LPDROPTARGET pDropTarget
)
307 DropTargetNode
* dropTargetInfo
;
309 TRACE("(%p,%p)\n", hwnd
, pDropTarget
);
315 * First, check if the window is already registered.
317 dropTargetInfo
= OLEDD_FindDropTarget(hwnd
);
319 if (dropTargetInfo
!=NULL
)
320 return DRAGDROP_E_ALREADYREGISTERED
;
323 * If it's not there, we can add it. We first create a node for it.
325 dropTargetInfo
= HeapAlloc(GetProcessHeap(), 0, sizeof(DropTargetNode
));
327 if (dropTargetInfo
==NULL
)
328 return E_OUTOFMEMORY
;
330 dropTargetInfo
->hwndTarget
= hwnd
;
331 dropTargetInfo
->prevDropTarget
= NULL
;
332 dropTargetInfo
->nextDropTarget
= NULL
;
335 * Don't forget that this is an interface pointer, need to nail it down since
336 * we keep a copy of it.
338 dropTargetInfo
->dropTarget
= pDropTarget
;
339 IDropTarget_AddRef(dropTargetInfo
->dropTarget
);
341 OLEDD_InsertDropTarget(dropTargetInfo
);
346 /***********************************************************************
347 * RevokeDragDrop (OLE32.@)
349 HRESULT WINAPI
RevokeDragDrop(
352 DropTargetNode
* dropTargetInfo
;
354 TRACE("(%p)\n", hwnd
);
357 * First, check if the window is already registered.
359 dropTargetInfo
= OLEDD_ExtractDropTarget(hwnd
);
362 * If it ain't in there, it's an error.
364 if (dropTargetInfo
==NULL
)
365 return DRAGDROP_E_NOTREGISTERED
;
368 * If it's in there, clean-up it's used memory and
371 IDropTarget_Release(dropTargetInfo
->dropTarget
);
372 HeapFree(GetProcessHeap(), 0, dropTargetInfo
);
377 /***********************************************************************
378 * OleRegGetUserType (OLE32.@)
380 * This implementation of OleRegGetUserType ignores the dwFormOfType
381 * parameter and always returns the full name of the object. This is
382 * not too bad since this is the case for many objects because of the
383 * way they are registered.
385 HRESULT WINAPI
OleRegGetUserType(
388 LPOLESTR
* pszUserType
)
398 * Initialize the out parameter.
403 * Build the key name we're looking for
405 sprintf( keyName
, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\",
406 clsid
->Data1
, clsid
->Data2
, clsid
->Data3
,
407 clsid
->Data4
[0], clsid
->Data4
[1], clsid
->Data4
[2], clsid
->Data4
[3],
408 clsid
->Data4
[4], clsid
->Data4
[5], clsid
->Data4
[6], clsid
->Data4
[7] );
410 TRACE("(%s, %ld, %p)\n", keyName
, dwFormOfType
, pszUserType
);
413 * Open the class id Key
415 hres
= RegOpenKeyA(HKEY_CLASSES_ROOT
,
419 if (hres
!= ERROR_SUCCESS
)
420 return REGDB_E_CLASSNOTREG
;
423 * Retrieve the size of the name string.
427 hres
= RegQueryValueExA(clsidKey
,
434 if (hres
!=ERROR_SUCCESS
)
436 RegCloseKey(clsidKey
);
437 return REGDB_E_READREGDB
;
441 * Allocate a buffer for the registry value.
443 *pszUserType
= CoTaskMemAlloc(cbData
*2);
445 if (*pszUserType
==NULL
)
447 RegCloseKey(clsidKey
);
448 return E_OUTOFMEMORY
;
451 buffer
= HeapAlloc(GetProcessHeap(), 0, cbData
);
455 RegCloseKey(clsidKey
);
456 CoTaskMemFree(*pszUserType
);
458 return E_OUTOFMEMORY
;
461 hres
= RegQueryValueExA(clsidKey
,
468 RegCloseKey(clsidKey
);
471 if (hres
!=ERROR_SUCCESS
)
473 CoTaskMemFree(*pszUserType
);
476 retVal
= REGDB_E_READREGDB
;
480 MultiByteToWideChar( CP_ACP
, 0, buffer
, -1, *pszUserType
, cbData
/*FIXME*/ );
483 HeapFree(GetProcessHeap(), 0, buffer
);
488 /***********************************************************************
489 * DoDragDrop [OLE32.@]
491 HRESULT WINAPI
DoDragDrop (
492 IDataObject
*pDataObject
, /* [in] ptr to the data obj */
493 IDropSource
* pDropSource
, /* [in] ptr to the source obj */
494 DWORD dwOKEffect
, /* [in] effects allowed by the source */
495 DWORD
*pdwEffect
) /* [out] ptr to effects of the source */
497 TrackerWindowInfo trackerInfo
;
498 HWND hwndTrackWindow
;
501 TRACE("(DataObject %p, DropSource %p)\n", pDataObject
, pDropSource
);
504 * Setup the drag n drop tracking window.
506 if (!IsValidInterface((LPUNKNOWN
)pDropSource
))
509 trackerInfo
.dataObject
= pDataObject
;
510 trackerInfo
.dropSource
= pDropSource
;
511 trackerInfo
.dwOKEffect
= dwOKEffect
;
512 trackerInfo
.pdwEffect
= pdwEffect
;
513 trackerInfo
.trackingDone
= FALSE
;
514 trackerInfo
.escPressed
= FALSE
;
515 trackerInfo
.curDragTargetHWND
= 0;
516 trackerInfo
.curTargetHWND
= 0;
517 trackerInfo
.curDragTarget
= 0;
519 hwndTrackWindow
= CreateWindowA(OLEDD_DRAGTRACKERCLASS
,
522 CW_USEDEFAULT
, CW_USEDEFAULT
,
523 CW_USEDEFAULT
, CW_USEDEFAULT
,
527 (LPVOID
)&trackerInfo
);
529 if (hwndTrackWindow
!=0)
532 * Capture the mouse input
534 SetCapture(hwndTrackWindow
);
537 * Pump messages. All mouse input should go the the capture window.
539 while (!trackerInfo
.trackingDone
&& GetMessageA(&msg
, 0, 0, 0) )
541 if ( (msg
.message
>= WM_KEYFIRST
) &&
542 (msg
.message
<= WM_KEYLAST
) )
545 * When keyboard messages are sent to windows on this thread, we
546 * want to ignore notify the drop source that the state changed.
547 * in the case of the Escape key, we also notify the drop source
548 * we give it a special meaning.
550 if ( (msg
.message
==WM_KEYDOWN
) &&
551 (msg
.wParam
==VK_ESCAPE
) )
553 trackerInfo
.escPressed
= TRUE
;
557 * Notify the drop source.
559 OLEDD_TrackStateChange(&trackerInfo
,
561 OLEDD_GetButtonState());
566 * Dispatch the messages only when it's not a keyboard message.
568 DispatchMessageA(&msg
);
573 * Destroy the temporary window.
575 DestroyWindow(hwndTrackWindow
);
577 return trackerInfo
.returnValue
;
583 /***********************************************************************
584 * OleQueryLinkFromData [OLE32.@]
586 HRESULT WINAPI
OleQueryLinkFromData(
587 IDataObject
* pSrcDataObject
)
589 FIXME("(%p),stub!\n", pSrcDataObject
);
593 /***********************************************************************
594 * OleRegGetMiscStatus [OLE32.@]
596 HRESULT WINAPI
OleRegGetMiscStatus(
608 * Initialize the out parameter.
613 * Build the key name we're looking for
615 sprintf( keyName
, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\",
616 clsid
->Data1
, clsid
->Data2
, clsid
->Data3
,
617 clsid
->Data4
[0], clsid
->Data4
[1], clsid
->Data4
[2], clsid
->Data4
[3],
618 clsid
->Data4
[4], clsid
->Data4
[5], clsid
->Data4
[6], clsid
->Data4
[7] );
620 TRACE("(%s, %ld, %p)\n", keyName
, dwAspect
, pdwStatus
);
623 * Open the class id Key
625 result
= RegOpenKeyA(HKEY_CLASSES_ROOT
,
629 if (result
!= ERROR_SUCCESS
)
630 return REGDB_E_CLASSNOTREG
;
635 result
= RegOpenKeyA(clsidKey
,
640 if (result
!= ERROR_SUCCESS
)
642 RegCloseKey(clsidKey
);
643 return REGDB_E_READREGDB
;
647 * Read the default value
649 OLEUTL_ReadRegistryDWORDValue(miscStatusKey
, pdwStatus
);
652 * Open the key specific to the requested aspect.
654 sprintf(keyName
, "%ld", dwAspect
);
656 result
= RegOpenKeyA(miscStatusKey
,
660 if (result
== ERROR_SUCCESS
)
662 OLEUTL_ReadRegistryDWORDValue(aspectKey
, pdwStatus
);
663 RegCloseKey(aspectKey
);
669 RegCloseKey(miscStatusKey
);
670 RegCloseKey(clsidKey
);
675 /******************************************************************************
676 * OleSetContainedObject [OLE32.@]
678 HRESULT WINAPI
OleSetContainedObject(
682 IRunnableObject
* runnable
= NULL
;
685 TRACE("(%p,%x), stub!\n", pUnknown
, fContained
);
687 hres
= IUnknown_QueryInterface(pUnknown
,
688 &IID_IRunnableObject
,
693 hres
= IRunnableObject_SetContainedObject(runnable
, fContained
);
695 IRunnableObject_Release(runnable
);
703 /******************************************************************************
706 HRESULT WINAPI
OleLoad(
709 LPOLECLIENTSITE pClientSite
,
712 IPersistStorage
* persistStorage
= NULL
;
713 IOleObject
* oleObject
= NULL
;
717 TRACE("(%p,%p,%p,%p)\n", pStg
, riid
, pClientSite
, ppvObj
);
720 * TODO, Conversion ... OleDoAutoConvert
724 * Get the class ID for the object.
726 hres
= IStorage_Stat(pStg
, &storageInfo
, STATFLAG_NONAME
);
729 * Now, try and create the handler for the object
731 hres
= CoCreateInstance(&storageInfo
.clsid
,
733 CLSCTX_INPROC_HANDLER
,
738 * If that fails, as it will most times, load the default
743 hres
= OleCreateDefaultHandler(&storageInfo
.clsid
,
750 * If we couldn't find a handler... this is bad. Abort the whole thing.
756 * Inform the new object of it's client site.
758 hres
= IOleObject_SetClientSite(oleObject
, pClientSite
);
761 * Initialize the object with it's IPersistStorage interface.
763 hres
= IOleObject_QueryInterface(oleObject
,
764 &IID_IPersistStorage
,
765 (void**)&persistStorage
);
769 IPersistStorage_Load(persistStorage
, pStg
);
771 IPersistStorage_Release(persistStorage
);
772 persistStorage
= NULL
;
776 * Return the requested interface to the caller.
778 hres
= IOleObject_QueryInterface(oleObject
, riid
, ppvObj
);
781 * Cleanup interfaces used internally
783 IOleObject_Release(oleObject
);
788 /***********************************************************************
791 HRESULT WINAPI
OleSave(
792 LPPERSISTSTORAGE pPS
,
799 TRACE("(%p,%p,%x)\n", pPS
, pStg
, fSameAsLoad
);
802 * First, we transfer the class ID (if available)
804 hres
= IPersistStorage_GetClassID(pPS
, &objectClass
);
808 WriteClassStg(pStg
, &objectClass
);
812 * Then, we ask the object to save itself to the
813 * storage. If it is successful, we commit the storage.
815 hres
= IPersistStorage_Save(pPS
, pStg
, fSameAsLoad
);
819 IStorage_Commit(pStg
,
827 /******************************************************************************
828 * OleLockRunning [OLE32.@]
830 HRESULT WINAPI
OleLockRunning(LPUNKNOWN pUnknown
, BOOL fLock
, BOOL fLastUnlockCloses
)
832 IRunnableObject
* runnable
= NULL
;
835 TRACE("(%p,%x,%x)\n", pUnknown
, fLock
, fLastUnlockCloses
);
837 hres
= IUnknown_QueryInterface(pUnknown
,
838 &IID_IRunnableObject
,
843 hres
= IRunnableObject_LockRunning(runnable
, fLock
, fLastUnlockCloses
);
845 IRunnableObject_Release(runnable
);
854 /**************************************************************************
855 * Internal methods to manage the shared OLE menu in response to the
856 * OLE***MenuDescriptor API
860 * OLEMenu_Initialize()
862 * Initializes the OLEMENU data structures.
864 static void OLEMenu_Initialize()
869 * OLEMenu_UnInitialize()
871 * Releases the OLEMENU data structures.
873 static void OLEMenu_UnInitialize()
877 /*************************************************************************
878 * OLEMenu_InstallHooks
879 * Install thread scope message hooks for WH_GETMESSAGE and WH_CALLWNDPROC
881 * RETURNS: TRUE if message hooks were successfully installed
884 BOOL
OLEMenu_InstallHooks( DWORD tid
)
886 OleMenuHookItem
*pHookItem
= NULL
;
888 /* Create an entry for the hook table */
889 if ( !(pHookItem
= HeapAlloc(GetProcessHeap(), 0,
890 sizeof(OleMenuHookItem
)) ) )
893 pHookItem
->tid
= tid
;
894 pHookItem
->hHeap
= GetProcessHeap();
896 /* Install a thread scope message hook for WH_GETMESSAGE */
897 pHookItem
->GetMsg_hHook
= SetWindowsHookExA( WH_GETMESSAGE
, OLEMenu_GetMsgProc
,
898 0, GetCurrentThreadId() );
899 if ( !pHookItem
->GetMsg_hHook
)
902 /* Install a thread scope message hook for WH_CALLWNDPROC */
903 pHookItem
->CallWndProc_hHook
= SetWindowsHookExA( WH_CALLWNDPROC
, OLEMenu_CallWndProc
,
904 0, GetCurrentThreadId() );
905 if ( !pHookItem
->CallWndProc_hHook
)
908 /* Insert the hook table entry */
909 pHookItem
->next
= hook_list
;
910 hook_list
= pHookItem
;
915 /* Unhook any hooks */
916 if ( pHookItem
->GetMsg_hHook
)
917 UnhookWindowsHookEx( pHookItem
->GetMsg_hHook
);
918 if ( pHookItem
->CallWndProc_hHook
)
919 UnhookWindowsHookEx( pHookItem
->CallWndProc_hHook
);
920 /* Release the hook table entry */
921 HeapFree(pHookItem
->hHeap
, 0, pHookItem
);
926 /*************************************************************************
927 * OLEMenu_UnInstallHooks
928 * UnInstall thread scope message hooks for WH_GETMESSAGE and WH_CALLWNDPROC
930 * RETURNS: TRUE if message hooks were successfully installed
933 BOOL
OLEMenu_UnInstallHooks( DWORD tid
)
935 OleMenuHookItem
*pHookItem
= NULL
;
936 OleMenuHookItem
**ppHook
= &hook_list
;
940 if ((*ppHook
)->tid
== tid
)
943 *ppHook
= pHookItem
->next
;
946 ppHook
= &(*ppHook
)->next
;
948 if (!pHookItem
) return FALSE
;
950 /* Uninstall the hooks installed for this thread */
951 if ( !UnhookWindowsHookEx( pHookItem
->GetMsg_hHook
) )
953 if ( !UnhookWindowsHookEx( pHookItem
->CallWndProc_hHook
) )
956 /* Release the hook table entry */
957 HeapFree(pHookItem
->hHeap
, 0, pHookItem
);
962 /* Release the hook table entry */
963 HeapFree(pHookItem
->hHeap
, 0, pHookItem
);
968 /*************************************************************************
969 * OLEMenu_IsHookInstalled
970 * Tests if OLEMenu hooks have been installed for a thread
972 * RETURNS: The pointer and index of the hook table entry for the tid
973 * NULL and -1 for the index if no hooks were installed for this thread
975 OleMenuHookItem
* OLEMenu_IsHookInstalled( DWORD tid
)
977 OleMenuHookItem
*pHookItem
= NULL
;
979 /* Do a simple linear search for an entry whose tid matches ours.
980 * We really need a map but efficiency is not a concern here. */
981 for (pHookItem
= hook_list
; pHookItem
; pHookItem
= pHookItem
->next
)
983 if ( tid
== pHookItem
->tid
)
990 /***********************************************************************
991 * OLEMenu_FindMainMenuIndex
993 * Used by OLEMenu API to find the top level group a menu item belongs to.
994 * On success pnPos contains the index of the item in the top level menu group
996 * RETURNS: TRUE if the ID was found, FALSE on failure
998 static BOOL
OLEMenu_FindMainMenuIndex( HMENU hMainMenu
, HMENU hPopupMenu
, UINT
*pnPos
)
1002 nItems
= GetMenuItemCount( hMainMenu
);
1004 for (i
= 0; i
< nItems
; i
++)
1008 /* Is the current item a submenu? */
1009 if ( (hsubmenu
= GetSubMenu(hMainMenu
, i
)) )
1011 /* If the handle is the same we're done */
1012 if ( hsubmenu
== hPopupMenu
)
1018 /* Recursively search without updating pnPos */
1019 else if ( OLEMenu_FindMainMenuIndex( hsubmenu
, hPopupMenu
, NULL
) )
1031 /***********************************************************************
1032 * OLEMenu_SetIsServerMenu
1034 * Checks whether a popup menu belongs to a shared menu group which is
1035 * owned by the server, and sets the menu descriptor state accordingly.
1036 * All menu messages from these groups should be routed to the server.
1038 * RETURNS: TRUE if the popup menu is part of a server owned group
1039 * FASE if the popup menu is part of a container owned group
1041 BOOL
OLEMenu_SetIsServerMenu( HMENU hmenu
, OleMenuDescriptor
*pOleMenuDescriptor
)
1043 UINT nPos
= 0, nWidth
, i
;
1045 pOleMenuDescriptor
->bIsServerItem
= FALSE
;
1047 /* Don't bother searching if the popup is the combined menu itself */
1048 if ( hmenu
== pOleMenuDescriptor
->hmenuCombined
)
1051 /* Find the menu item index in the shared OLE menu that this item belongs to */
1052 if ( !OLEMenu_FindMainMenuIndex( pOleMenuDescriptor
->hmenuCombined
, hmenu
, &nPos
) )
1055 /* The group widths array has counts for the number of elements
1056 * in the groups File, Edit, Container, Object, Window, Help.
1057 * The Edit, Object & Help groups belong to the server object
1058 * and the other three belong to the container.
1059 * Loop through the group widths and locate the group we are a member of.
1061 for ( i
= 0, nWidth
= 0; i
< 6; i
++ )
1063 nWidth
+= pOleMenuDescriptor
->mgw
.width
[i
];
1064 if ( nPos
< nWidth
)
1066 /* Odd elements are server menu widths */
1067 pOleMenuDescriptor
->bIsServerItem
= (i
%2) ? TRUE
: FALSE
;
1072 return pOleMenuDescriptor
->bIsServerItem
;
1075 /*************************************************************************
1076 * OLEMenu_CallWndProc
1077 * Thread scope WH_CALLWNDPROC hook proc filter function (callback)
1078 * This is invoked from a message hook installed in OleSetMenuDescriptor.
1080 LRESULT CALLBACK
OLEMenu_CallWndProc(INT code
, WPARAM wParam
, LPARAM lParam
)
1082 LPCWPSTRUCT pMsg
= NULL
;
1083 HOLEMENU hOleMenu
= 0;
1084 OleMenuDescriptor
*pOleMenuDescriptor
= NULL
;
1085 OleMenuHookItem
*pHookItem
= NULL
;
1088 TRACE("%i, %04x, %08x\n", code
, wParam
, (unsigned)lParam
);
1090 /* Check if we're being asked to process the message */
1091 if ( HC_ACTION
!= code
)
1094 /* Retrieve the current message being dispatched from lParam */
1095 pMsg
= (LPCWPSTRUCT
)lParam
;
1097 /* Check if the message is destined for a window we are interested in:
1098 * If the window has an OLEMenu property we may need to dispatch
1099 * the menu message to its active objects window instead. */
1101 hOleMenu
= (HOLEMENU
)GetPropA( pMsg
->hwnd
, "PROP_OLEMenuDescriptor" );
1105 /* Get the menu descriptor */
1106 pOleMenuDescriptor
= (OleMenuDescriptor
*) GlobalLock( hOleMenu
);
1107 if ( !pOleMenuDescriptor
) /* Bad descriptor! */
1110 /* Process menu messages */
1111 switch( pMsg
->message
)
1115 /* Reset the menu descriptor state */
1116 pOleMenuDescriptor
->bIsServerItem
= FALSE
;
1118 /* Send this message to the server as well */
1119 SendMessageA( pOleMenuDescriptor
->hwndActiveObject
,
1120 pMsg
->message
, pMsg
->wParam
, pMsg
->lParam
);
1124 case WM_INITMENUPOPUP
:
1126 /* Save the state for whether this is a server owned menu */
1127 OLEMenu_SetIsServerMenu( (HMENU
)pMsg
->wParam
, pOleMenuDescriptor
);
1133 fuFlags
= HIWORD(pMsg
->wParam
); /* Get flags */
1134 if ( fuFlags
& MF_SYSMENU
)
1137 /* Save the state for whether this is a server owned popup menu */
1138 else if ( fuFlags
& MF_POPUP
)
1139 OLEMenu_SetIsServerMenu( (HMENU
)pMsg
->lParam
, pOleMenuDescriptor
);
1146 LPDRAWITEMSTRUCT lpdis
= (LPDRAWITEMSTRUCT
) pMsg
->lParam
;
1147 if ( pMsg
->wParam
!= 0 || lpdis
->CtlType
!= ODT_MENU
)
1148 goto NEXTHOOK
; /* Not a menu message */
1157 /* If the message was for the server dispatch it accordingly */
1158 if ( pOleMenuDescriptor
->bIsServerItem
)
1160 SendMessageA( pOleMenuDescriptor
->hwndActiveObject
,
1161 pMsg
->message
, pMsg
->wParam
, pMsg
->lParam
);
1165 if ( pOleMenuDescriptor
)
1166 GlobalUnlock( hOleMenu
);
1168 /* Lookup the hook item for the current thread */
1169 if ( !( pHookItem
= OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) )
1171 /* This should never fail!! */
1172 WARN("could not retrieve hHook for current thread!\n" );
1176 /* Pass on the message to the next hooker */
1177 return CallNextHookEx( pHookItem
->CallWndProc_hHook
, code
, wParam
, lParam
);
1180 /*************************************************************************
1181 * OLEMenu_GetMsgProc
1182 * Thread scope WH_GETMESSAGE hook proc filter function (callback)
1183 * This is invoked from a message hook installed in OleSetMenuDescriptor.
1185 LRESULT CALLBACK
OLEMenu_GetMsgProc(INT code
, WPARAM wParam
, LPARAM lParam
)
1188 HOLEMENU hOleMenu
= 0;
1189 OleMenuDescriptor
*pOleMenuDescriptor
= NULL
;
1190 OleMenuHookItem
*pHookItem
= NULL
;
1193 TRACE("%i, %04x, %08x\n", code
, wParam
, (unsigned)lParam
);
1195 /* Check if we're being asked to process a messages */
1196 if ( HC_ACTION
!= code
)
1199 /* Retrieve the current message being dispatched from lParam */
1200 pMsg
= (LPMSG
)lParam
;
1202 /* Check if the message is destined for a window we are interested in:
1203 * If the window has an OLEMenu property we may need to dispatch
1204 * the menu message to its active objects window instead. */
1206 hOleMenu
= (HOLEMENU
)GetPropA( pMsg
->hwnd
, "PROP_OLEMenuDescriptor" );
1210 /* Process menu messages */
1211 switch( pMsg
->message
)
1215 wCode
= HIWORD(pMsg
->wParam
); /* Get notification code */
1217 goto NEXTHOOK
; /* Not a menu message */
1224 /* Get the menu descriptor */
1225 pOleMenuDescriptor
= (OleMenuDescriptor
*) GlobalLock( hOleMenu
);
1226 if ( !pOleMenuDescriptor
) /* Bad descriptor! */
1229 /* If the message was for the server dispatch it accordingly */
1230 if ( pOleMenuDescriptor
->bIsServerItem
)
1232 /* Change the hWnd in the message to the active objects hWnd.
1233 * The message loop which reads this message will automatically
1234 * dispatch it to the embedded objects window. */
1235 pMsg
->hwnd
= pOleMenuDescriptor
->hwndActiveObject
;
1239 if ( pOleMenuDescriptor
)
1240 GlobalUnlock( hOleMenu
);
1242 /* Lookup the hook item for the current thread */
1243 if ( !( pHookItem
= OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) )
1245 /* This should never fail!! */
1246 WARN("could not retrieve hHook for current thread!\n" );
1250 /* Pass on the message to the next hooker */
1251 return CallNextHookEx( pHookItem
->GetMsg_hHook
, code
, wParam
, lParam
);
1254 /***********************************************************************
1255 * OleCreateMenuDescriptor [OLE32.@]
1256 * Creates an OLE menu descriptor for OLE to use when dispatching
1257 * menu messages and commands.
1260 * hmenuCombined - Handle to the objects combined menu
1261 * lpMenuWidths - Pointer to array of 6 LONG's indicating menus per group
1264 HOLEMENU WINAPI
OleCreateMenuDescriptor(
1265 HMENU hmenuCombined
,
1266 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
1269 OleMenuDescriptor
*pOleMenuDescriptor
;
1272 if ( !hmenuCombined
|| !lpMenuWidths
)
1275 /* Create an OLE menu descriptor */
1276 if ( !(hOleMenu
= GlobalAlloc(GMEM_MOVEABLE
| GMEM_ZEROINIT
,
1277 sizeof(OleMenuDescriptor
) ) ) )
1280 pOleMenuDescriptor
= (OleMenuDescriptor
*) GlobalLock( hOleMenu
);
1281 if ( !pOleMenuDescriptor
)
1284 /* Initialize menu group widths and hmenu */
1285 for ( i
= 0; i
< 6; i
++ )
1286 pOleMenuDescriptor
->mgw
.width
[i
] = lpMenuWidths
->width
[i
];
1288 pOleMenuDescriptor
->hmenuCombined
= hmenuCombined
;
1289 pOleMenuDescriptor
->bIsServerItem
= FALSE
;
1290 GlobalUnlock( hOleMenu
);
1295 /***********************************************************************
1296 * OleDestroyMenuDescriptor [OLE32.@]
1297 * Destroy the shared menu descriptor
1299 HRESULT WINAPI
OleDestroyMenuDescriptor(
1300 HOLEMENU hmenuDescriptor
)
1302 if ( hmenuDescriptor
)
1303 GlobalFree( hmenuDescriptor
);
1307 /***********************************************************************
1308 * OleSetMenuDescriptor [OLE32.@]
1309 * Installs or removes OLE dispatching code for the containers frame window
1310 * FIXME: The lpFrame and lpActiveObject parameters are currently ignored
1311 * OLE should install context sensitive help F1 filtering for the app when
1312 * these are non null.
1315 * hOleMenu Handle to composite menu descriptor
1316 * hwndFrame Handle to containers frame window
1317 * hwndActiveObject Handle to objects in-place activation window
1318 * lpFrame Pointer to IOleInPlaceFrame on containers window
1319 * lpActiveObject Pointer to IOleInPlaceActiveObject on active in-place object
1322 * S_OK - menu installed correctly
1323 * E_FAIL, E_INVALIDARG, E_UNEXPECTED - failure
1325 HRESULT WINAPI
OleSetMenuDescriptor(
1328 HWND hwndActiveObject
,
1329 LPOLEINPLACEFRAME lpFrame
,
1330 LPOLEINPLACEACTIVEOBJECT lpActiveObject
)
1332 OleMenuDescriptor
*pOleMenuDescriptor
= NULL
;
1335 if ( !hwndFrame
|| (hOleMenu
&& !hwndActiveObject
) )
1336 return E_INVALIDARG
;
1338 if ( lpFrame
|| lpActiveObject
)
1340 FIXME("(%x, %p, %p, %p, %p), Context sensitive help filtering not implemented!\n",
1341 (unsigned int)hOleMenu
,
1348 /* Set up a message hook to intercept the containers frame window messages.
1349 * The message filter is responsible for dispatching menu messages from the
1350 * shared menu which are intended for the object.
1353 if ( hOleMenu
) /* Want to install dispatching code */
1355 /* If OLEMenu hooks are already installed for this thread, fail
1356 * Note: This effectively means that OleSetMenuDescriptor cannot
1357 * be called twice in succession on the same frame window
1358 * without first calling it with a null hOleMenu to uninstall */
1359 if ( OLEMenu_IsHookInstalled( GetCurrentThreadId() ) )
1362 /* Get the menu descriptor */
1363 pOleMenuDescriptor
= (OleMenuDescriptor
*) GlobalLock( hOleMenu
);
1364 if ( !pOleMenuDescriptor
)
1365 return E_UNEXPECTED
;
1367 /* Update the menu descriptor */
1368 pOleMenuDescriptor
->hwndFrame
= hwndFrame
;
1369 pOleMenuDescriptor
->hwndActiveObject
= hwndActiveObject
;
1371 GlobalUnlock( hOleMenu
);
1372 pOleMenuDescriptor
= NULL
;
1374 /* Add a menu descriptor windows property to the frame window */
1375 SetPropA( hwndFrame
, "PROP_OLEMenuDescriptor", hOleMenu
);
1377 /* Install thread scope message hooks for WH_GETMESSAGE and WH_CALLWNDPROC */
1378 if ( !OLEMenu_InstallHooks( GetCurrentThreadId() ) )
1381 else /* Want to uninstall dispatching code */
1383 /* Uninstall the hooks */
1384 if ( !OLEMenu_UnInstallHooks( GetCurrentThreadId() ) )
1387 /* Remove the menu descriptor property from the frame window */
1388 RemovePropA( hwndFrame
, "PROP_OLEMenuDescriptor" );
1394 /******************************************************************************
1395 * IsAccelerator [OLE32.@]
1396 * Mostly copied from controls/menu.c TranslateAccelerator implementation
1398 BOOL WINAPI
IsAccelerator(HACCEL hAccel
, int cAccelEntries
, LPMSG lpMsg
, WORD
* lpwCmd
)
1403 if(!lpMsg
) return FALSE
;
1406 WARN_(accel
)("NULL accel handle\n");
1409 if((lpMsg
->message
!= WM_KEYDOWN
&&
1410 lpMsg
->message
!= WM_KEYUP
&&
1411 lpMsg
->message
!= WM_SYSKEYDOWN
&&
1412 lpMsg
->message
!= WM_SYSKEYUP
&&
1413 lpMsg
->message
!= WM_CHAR
)) return FALSE
;
1414 lpAccelTbl
= HeapAlloc(GetProcessHeap(), 0, cAccelEntries
* sizeof(ACCEL
));
1415 if (NULL
== lpAccelTbl
)
1419 if (CopyAcceleratorTableW(hAccel
, lpAccelTbl
, cAccelEntries
) != cAccelEntries
)
1421 WARN_(accel
)("CopyAcceleratorTableW failed\n");
1422 HeapFree(GetProcessHeap(), 0, lpAccelTbl
);
1426 TRACE_(accel
)("hAccel=%p, cAccelEntries=%d,"
1427 "msg->hwnd=%p, msg->message=%04x, wParam=%08x, lParam=%08lx\n",
1428 hAccel
, cAccelEntries
,
1429 lpMsg
->hwnd
, lpMsg
->message
, lpMsg
->wParam
, lpMsg
->lParam
);
1430 for(i
= 0; i
< cAccelEntries
; i
++)
1432 if(lpAccelTbl
[i
].key
!= lpMsg
->wParam
)
1435 if(lpMsg
->message
== WM_CHAR
)
1437 if(!(lpAccelTbl
[i
].fVirt
& FALT
) && !(lpAccelTbl
[i
].fVirt
& FVIRTKEY
))
1439 TRACE_(accel
)("found accel for WM_CHAR: ('%c')\n", lpMsg
->wParam
& 0xff);
1445 if(lpAccelTbl
[i
].fVirt
& FVIRTKEY
)
1448 TRACE_(accel
)("found accel for virt_key %04x (scan %04x)\n",
1449 lpMsg
->wParam
, HIWORD(lpMsg
->lParam
) & 0xff);
1450 if(GetKeyState(VK_SHIFT
) & 0x8000) mask
|= FSHIFT
;
1451 if(GetKeyState(VK_CONTROL
) & 0x8000) mask
|= FCONTROL
;
1452 if(GetKeyState(VK_MENU
) & 0x8000) mask
|= FALT
;
1453 if(mask
== (lpAccelTbl
[i
].fVirt
& (FSHIFT
| FCONTROL
| FALT
))) goto found
;
1454 TRACE_(accel
)("incorrect SHIFT/CTRL/ALT-state\n");
1458 if(!(lpMsg
->lParam
& 0x01000000)) /* no special_key */
1460 if((lpAccelTbl
[i
].fVirt
& FALT
) && (lpMsg
->lParam
& 0x20000000))
1461 { /* ^^ ALT pressed */
1462 TRACE_(accel
)("found accel for Alt-%c\n", lpMsg
->wParam
& 0xff);
1470 WARN_(accel
)("couldn't translate accelerator key\n");
1471 HeapFree(GetProcessHeap(), 0, lpAccelTbl
);
1475 if(lpwCmd
) *lpwCmd
= lpAccelTbl
[i
].cmd
;
1476 HeapFree(GetProcessHeap(), 0, lpAccelTbl
);
1480 /***********************************************************************
1481 * ReleaseStgMedium [OLE32.@]
1483 void WINAPI
ReleaseStgMedium(
1486 switch (pmedium
->tymed
)
1490 if ( (pmedium
->pUnkForRelease
==0) &&
1491 (pmedium
->u
.hGlobal
!=0) )
1492 GlobalFree(pmedium
->u
.hGlobal
);
1497 if (pmedium
->u
.lpszFileName
!=0)
1499 if (pmedium
->pUnkForRelease
==0)
1501 DeleteFileW(pmedium
->u
.lpszFileName
);
1504 CoTaskMemFree(pmedium
->u
.lpszFileName
);
1510 if (pmedium
->u
.pstm
!=0)
1512 IStream_Release(pmedium
->u
.pstm
);
1516 case TYMED_ISTORAGE
:
1518 if (pmedium
->u
.pstg
!=0)
1520 IStorage_Release(pmedium
->u
.pstg
);
1526 if ( (pmedium
->pUnkForRelease
==0) &&
1527 (pmedium
->u
.hBitmap
!=0) )
1528 DeleteObject(pmedium
->u
.hBitmap
);
1533 if ( (pmedium
->pUnkForRelease
==0) &&
1534 (pmedium
->u
.hMetaFilePict
!=0) )
1536 LPMETAFILEPICT pMP
= GlobalLock(pmedium
->u
.hMetaFilePict
);
1537 DeleteMetaFile(pMP
->hMF
);
1538 GlobalUnlock(pmedium
->u
.hMetaFilePict
);
1539 GlobalFree(pmedium
->u
.hMetaFilePict
);
1545 if ( (pmedium
->pUnkForRelease
==0) &&
1546 (pmedium
->u
.hEnhMetaFile
!=0) )
1548 DeleteEnhMetaFile(pmedium
->u
.hEnhMetaFile
);
1556 pmedium
->tymed
=TYMED_NULL
;
1559 * After cleaning up, the unknown is released
1561 if (pmedium
->pUnkForRelease
!=0)
1563 IUnknown_Release(pmedium
->pUnkForRelease
);
1564 pmedium
->pUnkForRelease
= 0;
1569 * OLEDD_Initialize()
1571 * Initializes the OLE drag and drop data structures.
1573 static void OLEDD_Initialize()
1577 ZeroMemory (&wndClass
, sizeof(WNDCLASSA
));
1578 wndClass
.style
= CS_GLOBALCLASS
;
1579 wndClass
.lpfnWndProc
= OLEDD_DragTrackerWindowProc
;
1580 wndClass
.cbClsExtra
= 0;
1581 wndClass
.cbWndExtra
= sizeof(TrackerWindowInfo
*);
1582 wndClass
.hCursor
= 0;
1583 wndClass
.hbrBackground
= 0;
1584 wndClass
.lpszClassName
= OLEDD_DRAGTRACKERCLASS
;
1586 RegisterClassA (&wndClass
);
1590 * OLEDD_UnInitialize()
1592 * Releases the OLE drag and drop data structures.
1594 static void OLEDD_UnInitialize()
1597 * Simply empty the list.
1599 while (targetListHead
!=NULL
)
1601 RevokeDragDrop(targetListHead
->hwndTarget
);
1606 * OLEDD_InsertDropTarget()
1608 * Insert the target node in the tree.
1610 static void OLEDD_InsertDropTarget(DropTargetNode
* nodeToAdd
)
1612 DropTargetNode
* curNode
;
1613 DropTargetNode
** parentNodeLink
;
1616 * Iterate the tree to find the insertion point.
1618 curNode
= targetListHead
;
1619 parentNodeLink
= &targetListHead
;
1621 while (curNode
!=NULL
)
1623 if (nodeToAdd
->hwndTarget
<curNode
->hwndTarget
)
1626 * If the node we want to add has a smaller HWND, go left
1628 parentNodeLink
= &curNode
->prevDropTarget
;
1629 curNode
= curNode
->prevDropTarget
;
1631 else if (nodeToAdd
->hwndTarget
>curNode
->hwndTarget
)
1634 * If the node we want to add has a larger HWND, go right
1636 parentNodeLink
= &curNode
->nextDropTarget
;
1637 curNode
= curNode
->nextDropTarget
;
1642 * The item was found in the list. It shouldn't have been there
1650 * If we get here, we have found a spot for our item. The parentNodeLink
1651 * pointer points to the pointer that we have to modify.
1652 * The curNode should be NULL. We just have to establish the link and Voila!
1654 assert(curNode
==NULL
);
1655 assert(parentNodeLink
!=NULL
);
1656 assert(*parentNodeLink
==NULL
);
1658 *parentNodeLink
=nodeToAdd
;
1662 * OLEDD_ExtractDropTarget()
1664 * Removes the target node from the tree.
1666 static DropTargetNode
* OLEDD_ExtractDropTarget(HWND hwndOfTarget
)
1668 DropTargetNode
* curNode
;
1669 DropTargetNode
** parentNodeLink
;
1672 * Iterate the tree to find the insertion point.
1674 curNode
= targetListHead
;
1675 parentNodeLink
= &targetListHead
;
1677 while (curNode
!=NULL
)
1679 if (hwndOfTarget
<curNode
->hwndTarget
)
1682 * If the node we want to add has a smaller HWND, go left
1684 parentNodeLink
= &curNode
->prevDropTarget
;
1685 curNode
= curNode
->prevDropTarget
;
1687 else if (hwndOfTarget
>curNode
->hwndTarget
)
1690 * If the node we want to add has a larger HWND, go right
1692 parentNodeLink
= &curNode
->nextDropTarget
;
1693 curNode
= curNode
->nextDropTarget
;
1698 * The item was found in the list. Detach it from it's parent and
1699 * re-insert it's kids in the tree.
1701 assert(parentNodeLink
!=NULL
);
1702 assert(*parentNodeLink
==curNode
);
1705 * We arbitrately re-attach the left sub-tree to the parent.
1707 *parentNodeLink
= curNode
->prevDropTarget
;
1710 * And we re-insert the right subtree
1712 if (curNode
->nextDropTarget
!=NULL
)
1714 OLEDD_InsertDropTarget(curNode
->nextDropTarget
);
1718 * The node we found is still a valid node once we complete
1719 * the unlinking of the kids.
1721 curNode
->nextDropTarget
=NULL
;
1722 curNode
->prevDropTarget
=NULL
;
1729 * If we get here, the node is not in the tree
1735 * OLEDD_FindDropTarget()
1737 * Finds information about the drop target.
1739 static DropTargetNode
* OLEDD_FindDropTarget(HWND hwndOfTarget
)
1741 DropTargetNode
* curNode
;
1744 * Iterate the tree to find the HWND value.
1746 curNode
= targetListHead
;
1748 while (curNode
!=NULL
)
1750 if (hwndOfTarget
<curNode
->hwndTarget
)
1753 * If the node we want to add has a smaller HWND, go left
1755 curNode
= curNode
->prevDropTarget
;
1757 else if (hwndOfTarget
>curNode
->hwndTarget
)
1760 * If the node we want to add has a larger HWND, go right
1762 curNode
= curNode
->nextDropTarget
;
1767 * The item was found in the list.
1774 * If we get here, the item is not in the list
1780 * OLEDD_DragTrackerWindowProc()
1782 * This method is the WindowProcedure of the drag n drop tracking
1783 * window. During a drag n Drop operation, an invisible window is created
1784 * to receive the user input and act upon it. This procedure is in charge
1787 static LRESULT WINAPI
OLEDD_DragTrackerWindowProc(
1797 LPCREATESTRUCTA createStruct
= (LPCREATESTRUCTA
)lParam
;
1799 SetWindowLongA(hwnd
, 0, (LONG
)createStruct
->lpCreateParams
);
1806 TrackerWindowInfo
* trackerInfo
= (TrackerWindowInfo
*)GetWindowLongA(hwnd
, 0);
1810 * Get the current mouse position in screen coordinates.
1812 mousePos
.x
= LOWORD(lParam
);
1813 mousePos
.y
= HIWORD(lParam
);
1814 ClientToScreen(hwnd
, &mousePos
);
1817 * Track the movement of the mouse.
1819 OLEDD_TrackMouseMove(trackerInfo
, mousePos
, wParam
);
1826 case WM_LBUTTONDOWN
:
1827 case WM_MBUTTONDOWN
:
1828 case WM_RBUTTONDOWN
:
1830 TrackerWindowInfo
* trackerInfo
= (TrackerWindowInfo
*)GetWindowLongA(hwnd
, 0);
1834 * Get the current mouse position in screen coordinates.
1836 mousePos
.x
= LOWORD(lParam
);
1837 mousePos
.y
= HIWORD(lParam
);
1838 ClientToScreen(hwnd
, &mousePos
);
1841 * Notify everyone that the button state changed
1842 * TODO: Check if the "escape" key was pressed.
1844 OLEDD_TrackStateChange(trackerInfo
, mousePos
, wParam
);
1851 * This is a window proc after all. Let's call the default.
1853 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
1857 * OLEDD_TrackMouseMove()
1859 * This method is invoked while a drag and drop operation is in effect.
1860 * it will generate the appropriate callbacks in the drop source
1861 * and drop target. It will also provide the expected feedback to
1865 * trackerInfo - Pointer to the structure identifying the
1866 * drag & drop operation that is currently
1868 * mousePos - Current position of the mouse in screen
1870 * keyState - Contains the state of the shift keys and the
1871 * mouse buttons (MK_LBUTTON and the like)
1873 static void OLEDD_TrackMouseMove(
1874 TrackerWindowInfo
* trackerInfo
,
1878 HWND hwndNewTarget
= 0;
1882 * Get the handle of the window under the mouse
1884 hwndNewTarget
= WindowFromPoint(mousePos
);
1887 * Every time, we re-initialize the effects passed to the
1888 * IDropTarget to the effects allowed by the source.
1890 *trackerInfo
->pdwEffect
= trackerInfo
->dwOKEffect
;
1893 * If we are hovering over the same target as before, send the
1894 * DragOver notification
1896 if ( (trackerInfo
->curDragTarget
!= 0) &&
1897 (trackerInfo
->curTargetHWND
== hwndNewTarget
) )
1899 POINTL mousePosParam
;
1902 * The documentation tells me that the coordinate should be in the target
1903 * window's coordinate space. However, the tests I made tell me the
1904 * coordinates should be in screen coordinates.
1906 mousePosParam
.x
= mousePos
.x
;
1907 mousePosParam
.y
= mousePos
.y
;
1909 IDropTarget_DragOver(trackerInfo
->curDragTarget
,
1912 trackerInfo
->pdwEffect
);
1916 DropTargetNode
* newDropTargetNode
= 0;
1919 * If we changed window, we have to notify our old target and check for
1922 if (trackerInfo
->curDragTarget
!=0)
1924 IDropTarget_DragLeave(trackerInfo
->curDragTarget
);
1928 * Make sure we're hovering over a window.
1930 if (hwndNewTarget
!=0)
1933 * Find-out if there is a drag target under the mouse
1935 HWND nexttar
= hwndNewTarget
;
1936 trackerInfo
->curTargetHWND
= hwndNewTarget
;
1939 newDropTargetNode
= OLEDD_FindDropTarget(nexttar
);
1940 } while (!newDropTargetNode
&& (nexttar
= GetParent(nexttar
)) != 0);
1941 if(nexttar
) hwndNewTarget
= nexttar
;
1943 trackerInfo
->curDragTargetHWND
= hwndNewTarget
;
1944 trackerInfo
->curDragTarget
= newDropTargetNode
? newDropTargetNode
->dropTarget
: 0;
1947 * If there is, notify it that we just dragged-in
1949 if (trackerInfo
->curDragTarget
!=0)
1951 POINTL mousePosParam
;
1954 * The documentation tells me that the coordinate should be in the target
1955 * window's coordinate space. However, the tests I made tell me the
1956 * coordinates should be in screen coordinates.
1958 mousePosParam
.x
= mousePos
.x
;
1959 mousePosParam
.y
= mousePos
.y
;
1961 IDropTarget_DragEnter(trackerInfo
->curDragTarget
,
1962 trackerInfo
->dataObject
,
1965 trackerInfo
->pdwEffect
);
1971 * The mouse is not over a window so we don't track anything.
1973 trackerInfo
->curDragTargetHWND
= 0;
1974 trackerInfo
->curTargetHWND
= 0;
1975 trackerInfo
->curDragTarget
= 0;
1980 * Now that we have done that, we have to tell the source to give
1981 * us feedback on the work being done by the target. If we don't
1982 * have a target, simulate no effect.
1984 if (trackerInfo
->curDragTarget
==0)
1986 *trackerInfo
->pdwEffect
= DROPEFFECT_NONE
;
1989 hr
= IDropSource_GiveFeedback(trackerInfo
->dropSource
,
1990 *trackerInfo
->pdwEffect
);
1993 * When we ask for feedback from the drop source, sometimes it will
1994 * do all the necessary work and sometimes it will not handle it
1995 * when that's the case, we must display the standard drag and drop
1998 if (hr
==DRAGDROP_S_USEDEFAULTCURSORS
)
2000 if (*trackerInfo
->pdwEffect
& DROPEFFECT_MOVE
)
2002 SetCursor(LoadCursorA(OLE32_hInstance
, MAKEINTRESOURCEA(1)));
2004 else if (*trackerInfo
->pdwEffect
& DROPEFFECT_COPY
)
2006 SetCursor(LoadCursorA(OLE32_hInstance
, MAKEINTRESOURCEA(2)));
2008 else if (*trackerInfo
->pdwEffect
& DROPEFFECT_LINK
)
2010 SetCursor(LoadCursorA(OLE32_hInstance
, MAKEINTRESOURCEA(3)));
2014 SetCursor(LoadCursorA(OLE32_hInstance
, MAKEINTRESOURCEA(0)));
2020 * OLEDD_TrackStateChange()
2022 * This method is invoked while a drag and drop operation is in effect.
2023 * It is used to notify the drop target/drop source callbacks when
2024 * the state of the keyboard or mouse button change.
2027 * trackerInfo - Pointer to the structure identifying the
2028 * drag & drop operation that is currently
2030 * mousePos - Current position of the mouse in screen
2032 * keyState - Contains the state of the shift keys and the
2033 * mouse buttons (MK_LBUTTON and the like)
2035 static void OLEDD_TrackStateChange(
2036 TrackerWindowInfo
* trackerInfo
,
2041 * Ask the drop source what to do with the operation.
2043 trackerInfo
->returnValue
= IDropSource_QueryContinueDrag(
2044 trackerInfo
->dropSource
,
2045 trackerInfo
->escPressed
,
2049 * All the return valued will stop the operation except the S_OK
2052 if (trackerInfo
->returnValue
!=S_OK
)
2055 * Make sure the message loop in DoDragDrop stops
2057 trackerInfo
->trackingDone
= TRUE
;
2060 * Release the mouse in case the drop target decides to show a popup
2061 * or a menu or something.
2066 * If we end-up over a target, drop the object in the target or
2067 * inform the target that the operation was cancelled.
2069 if (trackerInfo
->curDragTarget
!=0)
2071 switch (trackerInfo
->returnValue
)
2074 * If the source wants us to complete the operation, we tell
2075 * the drop target that we just dropped the object in it.
2077 case DRAGDROP_S_DROP
:
2079 POINTL mousePosParam
;
2082 * The documentation tells me that the coordinate should be
2083 * in the target window's coordinate space. However, the tests
2084 * I made tell me the coordinates should be in screen coordinates.
2086 mousePosParam
.x
= mousePos
.x
;
2087 mousePosParam
.y
= mousePos
.y
;
2089 IDropTarget_Drop(trackerInfo
->curDragTarget
,
2090 trackerInfo
->dataObject
,
2093 trackerInfo
->pdwEffect
);
2097 * If the source told us that we should cancel, fool the drop
2098 * target by telling it that the mouse left it's window.
2099 * Also set the drop effect to "NONE" in case the application
2100 * ignores the result of DoDragDrop.
2102 case DRAGDROP_S_CANCEL
:
2103 IDropTarget_DragLeave(trackerInfo
->curDragTarget
);
2104 *trackerInfo
->pdwEffect
= DROPEFFECT_NONE
;
2112 * OLEDD_GetButtonState()
2114 * This method will use the current state of the keyboard to build
2115 * a button state mask equivalent to the one passed in the
2116 * WM_MOUSEMOVE wParam.
2118 static DWORD
OLEDD_GetButtonState()
2120 BYTE keyboardState
[256];
2123 GetKeyboardState(keyboardState
);
2125 if ( (keyboardState
[VK_SHIFT
] & 0x80) !=0)
2126 keyMask
|= MK_SHIFT
;
2128 if ( (keyboardState
[VK_CONTROL
] & 0x80) !=0)
2129 keyMask
|= MK_CONTROL
;
2131 if ( (keyboardState
[VK_LBUTTON
] & 0x80) !=0)
2132 keyMask
|= MK_LBUTTON
;
2134 if ( (keyboardState
[VK_RBUTTON
] & 0x80) !=0)
2135 keyMask
|= MK_RBUTTON
;
2137 if ( (keyboardState
[VK_MBUTTON
] & 0x80) !=0)
2138 keyMask
|= MK_MBUTTON
;
2144 * OLEDD_GetButtonState()
2146 * This method will read the default value of the registry key in
2147 * parameter and extract a DWORD value from it. The registry key value
2148 * can be in a string key or a DWORD key.
2151 * regKey - Key to read the default value from
2152 * pdwValue - Pointer to the location where the DWORD
2153 * value is returned. This value is not modified
2154 * if the value is not found.
2157 static void OLEUTL_ReadRegistryDWORDValue(
2166 lres
= RegQueryValueExA(regKey
,
2173 if (lres
==ERROR_SUCCESS
)
2178 *pdwValue
= *(DWORD
*)buffer
;
2183 *pdwValue
= (DWORD
)strtoul(buffer
, NULL
, 10);
2189 /******************************************************************************
2192 * The operation of this function is documented literally in the WinAPI
2193 * documentation to involve a QueryInterface for the IViewObject interface,
2194 * followed by a call to IViewObject::Draw.
2196 HRESULT WINAPI
OleDraw(
2203 IViewObject
*viewobject
;
2205 hres
= IUnknown_QueryInterface(pUnk
,
2207 (void**)&viewobject
);
2209 if (SUCCEEDED(hres
))
2213 rectl
.left
= lprcBounds
->left
;
2214 rectl
.right
= lprcBounds
->right
;
2215 rectl
.top
= lprcBounds
->top
;
2216 rectl
.bottom
= lprcBounds
->bottom
;
2217 hres
= IViewObject_Draw(viewobject
, dwAspect
, -1, 0, 0, 0, hdcDraw
, &rectl
, 0, 0, 0);
2219 IViewObject_Release(viewobject
);
2224 return DV_E_NOIVIEWOBJECT
;
2228 /***********************************************************************
2229 * OleTranslateAccelerator [OLE32.@]
2231 HRESULT WINAPI
OleTranslateAccelerator (LPOLEINPLACEFRAME lpFrame
,
2232 LPOLEINPLACEFRAMEINFO lpFrameInfo
, LPMSG lpmsg
)
2236 TRACE("(%p,%p,%p)\n", lpFrame
, lpFrameInfo
, lpmsg
);
2238 if (IsAccelerator(lpFrameInfo
->haccel
,lpFrameInfo
->cAccelEntries
,lpmsg
,&wID
))
2239 return IOleInPlaceFrame_TranslateAccelerator(lpFrame
,lpmsg
,wID
);
2244 /******************************************************************************
2245 * OleCreate [OLE32.@]
2248 HRESULT WINAPI
OleCreate(
2252 LPFORMATETC pFormatEtc
,
2253 LPOLECLIENTSITE pClientSite
,
2257 HRESULT hres
, hres1
;
2258 IUnknown
* pUnk
= NULL
;
2260 FIXME("\n\t%s\n\t%s semi-stub!\n", debugstr_guid(rclsid
), debugstr_guid(riid
));
2262 if (SUCCEEDED((hres
= CoCreateInstance(rclsid
, 0, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
|CLSCTX_LOCAL_SERVER
, riid
, (LPVOID
*)&pUnk
))))
2267 IPersistStorage
* pPS
;
2268 if (SUCCEEDED((hres
= IUnknown_QueryInterface( pUnk
, &IID_IOleObject
, (LPVOID
*)&pOE
))))
2270 TRACE("trying to set clientsite %p\n", pClientSite
);
2271 hres1
= IOleObject_SetClientSite(pOE
, pClientSite
);
2272 TRACE("-- result 0x%08lx\n", hres1
);
2273 IOleObject_Release(pOE
);
2275 if (SUCCEEDED((hres
= IUnknown_QueryInterface( pUnk
, &IID_IPersistStorage
, (LPVOID
*)&pPS
))))
2277 TRACE("trying to set stg %p\n", pStg
);
2278 hres1
= IPersistStorage_InitNew(pPS
, pStg
);
2279 TRACE("-- result 0x%08lx\n", hres1
);
2280 IPersistStorage_Release(pPS
);
2287 TRACE("-- %p \n", pUnk
);
2291 /******************************************************************************
2292 * OleSetAutoConvert [OLE32.@]
2294 /* FIXME: convert to Unicode */
2295 HRESULT WINAPI
OleSetAutoConvert(REFCLSID clsidOld
, REFCLSID clsidNew
)
2298 char buf
[200], szClsidNew
[200];
2301 TRACE("(%s,%s)\n", debugstr_guid(clsidOld
), debugstr_guid(clsidNew
));
2302 sprintf(buf
,"CLSID\\");WINE_StringFromCLSID(clsidOld
,&buf
[6]);
2303 WINE_StringFromCLSID(clsidNew
, szClsidNew
);
2304 if (RegOpenKeyA(HKEY_CLASSES_ROOT
,buf
,&hkey
))
2306 res
= REGDB_E_CLASSNOTREG
;
2309 if (RegSetValueA(hkey
, "AutoConvertTo", REG_SZ
, szClsidNew
, strlen(szClsidNew
)+1))
2311 res
= REGDB_E_WRITEREGDB
;
2316 if (hkey
) RegCloseKey(hkey
);
2320 /******************************************************************************
2321 * OleDoAutoConvert [OLE32.@]
2323 HRESULT WINAPI
OleDoAutoConvert(IStorage
*pStg
, LPCLSID pClsidNew
)
2325 FIXME("(%p,%p) : stub\n",pStg
,pClsidNew
);
2329 /***********************************************************************
2330 * OLE_FreeClipDataArray [internal]
2333 * frees the data associated with an array of CLIPDATAs
2335 static void OLE_FreeClipDataArray(ULONG count
, CLIPDATA
* pClipDataArray
)
2338 for (i
= 0; i
< count
; i
++)
2339 if (pClipDataArray
[i
].pClipData
)
2340 CoTaskMemFree(pClipDataArray
[i
].pClipData
);
2343 /******************************************************************************
2344 * Check if a PROPVARIANT's type is valid.
2346 static inline HRESULT
PROPVARIANT_ValidateType(VARTYPE vt
)
2372 case VT_STREAMED_OBJECT
:
2373 case VT_STORED_OBJECT
:
2374 case VT_BLOB_OBJECT
:
2377 case VT_I2
|VT_VECTOR
:
2378 case VT_I4
|VT_VECTOR
:
2379 case VT_R4
|VT_VECTOR
:
2380 case VT_R8
|VT_VECTOR
:
2381 case VT_CY
|VT_VECTOR
:
2382 case VT_DATE
|VT_VECTOR
:
2383 case VT_BSTR
|VT_VECTOR
:
2384 case VT_ERROR
|VT_VECTOR
:
2385 case VT_BOOL
|VT_VECTOR
:
2386 case VT_VARIANT
|VT_VECTOR
:
2387 case VT_UI1
|VT_VECTOR
:
2388 case VT_UI2
|VT_VECTOR
:
2389 case VT_UI4
|VT_VECTOR
:
2390 case VT_I8
|VT_VECTOR
:
2391 case VT_UI8
|VT_VECTOR
:
2392 case VT_LPSTR
|VT_VECTOR
:
2393 case VT_LPWSTR
|VT_VECTOR
:
2394 case VT_FILETIME
|VT_VECTOR
:
2395 case VT_CF
|VT_VECTOR
:
2396 case VT_CLSID
|VT_VECTOR
:
2399 WARN("Bad type %d\n", vt
);
2400 return STG_E_INVALIDPARAMETER
;
2403 /***********************************************************************
2404 * PropVariantClear [OLE32.@]
2406 HRESULT WINAPI
PropVariantClear(PROPVARIANT
* pvar
) /* [in/out] */
2410 TRACE("(%p)\n", pvar
);
2415 hr
= PROPVARIANT_ValidateType(pvar
->vt
);
2422 case VT_STREAMED_OBJECT
:
2424 case VT_STORED_OBJECT
:
2425 if (pvar
->u
.pStream
)
2426 IUnknown_Release(pvar
->u
.pStream
);
2431 /* pick an arbitary typed pointer - we don't care about the type
2432 * as we are just freeing it */
2433 CoTaskMemFree(pvar
->u
.puuid
);
2436 case VT_BLOB_OBJECT
:
2437 CoTaskMemFree(pvar
->u
.blob
.pBlobData
);
2440 if (pvar
->u
.bstrVal
)
2442 FIXME("Need to load OLEAUT32 for SysFreeString\n");
2443 /* SysFreeString(pvar->u.bstrVal); */
2447 if (pvar
->u
.pclipdata
)
2449 OLE_FreeClipDataArray(1, pvar
->u
.pclipdata
);
2450 CoTaskMemFree(pvar
->u
.pclipdata
);
2454 switch (pvar
->vt
& ~VT_VECTOR
)
2457 FreePropVariantArray(pvar
->u
.capropvar
.cElems
, pvar
->u
.capropvar
.pElems
);
2460 OLE_FreeClipDataArray(pvar
->u
.caclipdata
.cElems
, pvar
->u
.caclipdata
.pElems
);
2466 FIXME("Freeing of vector sub-type not supported yet\n");
2468 if (pvar
->vt
& ~VT_VECTOR
)
2470 /* pick an arbitary VT_VECTOR structure - they all have the same
2472 CoTaskMemFree(pvar
->u
.capropvar
.pElems
);
2476 ZeroMemory(pvar
, sizeof(*pvar
));
2481 /***********************************************************************
2482 * PropVariantCopy [OLE32.@]
2484 HRESULT WINAPI
PropVariantCopy(PROPVARIANT
*pvarDest
, /* [out] */
2485 const PROPVARIANT
*pvarSrc
) /* [in] */
2490 TRACE("(%p, %p)\n", pvarDest
, pvarSrc
);
2492 hr
= PROPVARIANT_ValidateType(pvarSrc
->vt
);
2496 /* this will deal with most cases */
2497 CopyMemory(pvarDest
, pvarSrc
, sizeof(*pvarDest
));
2502 case VT_STREAMED_OBJECT
:
2504 case VT_STORED_OBJECT
:
2505 IUnknown_AddRef((LPUNKNOWN
)pvarDest
->u
.pStream
);
2508 pvarDest
->u
.puuid
= CoTaskMemAlloc(sizeof(CLSID
));
2509 CopyMemory(pvarDest
->u
.puuid
, pvarSrc
->u
.puuid
, sizeof(CLSID
));
2512 len
= strlen(pvarSrc
->u
.pszVal
);
2513 pvarDest
->u
.pszVal
= CoTaskMemAlloc((len
+1)*sizeof(CHAR
));
2514 CopyMemory(pvarDest
->u
.pszVal
, pvarSrc
->u
.pszVal
, (len
+1)*sizeof(CHAR
));
2517 len
= lstrlenW(pvarSrc
->u
.pwszVal
);
2518 pvarDest
->u
.pwszVal
= CoTaskMemAlloc((len
+1)*sizeof(WCHAR
));
2519 CopyMemory(pvarDest
->u
.pwszVal
, pvarSrc
->u
.pwszVal
, (len
+1)*sizeof(WCHAR
));
2522 case VT_BLOB_OBJECT
:
2523 if (pvarSrc
->u
.blob
.pBlobData
)
2525 len
= pvarSrc
->u
.blob
.cbSize
;
2526 pvarDest
->u
.blob
.pBlobData
= CoTaskMemAlloc(len
);
2527 CopyMemory(pvarDest
->u
.blob
.pBlobData
, pvarSrc
->u
.blob
.pBlobData
, len
);
2531 FIXME("Need to copy BSTR\n");
2534 if (pvarSrc
->u
.pclipdata
)
2536 len
= pvarSrc
->u
.pclipdata
->cbSize
- sizeof(pvarSrc
->u
.pclipdata
->ulClipFmt
);
2537 CoTaskMemAlloc(len
);
2538 CopyMemory(pvarDest
->u
.pclipdata
->pClipData
, pvarSrc
->u
.pclipdata
->pClipData
, len
);
2542 if (pvarSrc
->vt
& VT_VECTOR
)
2545 switch(pvarSrc
->vt
& VT_VECTOR
)
2547 case VT_I1
: elemSize
= sizeof(pvarSrc
->u
.cVal
); break;
2548 case VT_UI1
: elemSize
= sizeof(pvarSrc
->u
.bVal
); break;
2549 case VT_I2
: elemSize
= sizeof(pvarSrc
->u
.iVal
); break;
2550 case VT_UI2
: elemSize
= sizeof(pvarSrc
->u
.uiVal
); break;
2551 case VT_BOOL
: elemSize
= sizeof(pvarSrc
->u
.boolVal
); break;
2552 case VT_I4
: elemSize
= sizeof(pvarSrc
->u
.lVal
); break;
2553 case VT_UI4
: elemSize
= sizeof(pvarSrc
->u
.ulVal
); break;
2554 case VT_R4
: elemSize
= sizeof(pvarSrc
->u
.fltVal
); break;
2555 case VT_R8
: elemSize
= sizeof(pvarSrc
->u
.dblVal
); break;
2556 case VT_ERROR
: elemSize
= sizeof(pvarSrc
->u
.scode
); break;
2557 case VT_I8
: elemSize
= sizeof(pvarSrc
->u
.hVal
); break;
2558 case VT_UI8
: elemSize
= sizeof(pvarSrc
->u
.uhVal
); break;
2559 case VT_CY
: elemSize
= sizeof(pvarSrc
->u
.cyVal
); break;
2560 case VT_DATE
: elemSize
= sizeof(pvarSrc
->u
.date
); break;
2561 case VT_FILETIME
: elemSize
= sizeof(pvarSrc
->u
.filetime
); break;
2562 case VT_CLSID
: elemSize
= sizeof(*pvarSrc
->u
.puuid
); break;
2563 case VT_CF
: elemSize
= sizeof(*pvarSrc
->u
.pclipdata
); break;
2570 FIXME("Invalid element type: %ul\n", pvarSrc
->vt
& VT_VECTOR
);
2571 return E_INVALIDARG
;
2573 len
= pvarSrc
->u
.capropvar
.cElems
;
2574 pvarDest
->u
.capropvar
.pElems
= CoTaskMemAlloc(len
* elemSize
);
2575 if (pvarSrc
->vt
== (VT_VECTOR
| VT_VARIANT
))
2578 for (i
= 0; i
< len
; i
++)
2579 PropVariantCopy(&pvarDest
->u
.capropvar
.pElems
[i
], &pvarSrc
->u
.capropvar
.pElems
[i
]);
2581 else if (pvarSrc
->vt
== (VT_VECTOR
| VT_CF
))
2583 FIXME("Copy clipformats\n");
2585 else if (pvarSrc
->vt
== (VT_VECTOR
| VT_BSTR
))
2587 FIXME("Copy BSTRs\n");
2589 else if (pvarSrc
->vt
== (VT_VECTOR
| VT_LPSTR
))
2591 FIXME("Copy LPSTRs\n");
2593 else if (pvarSrc
->vt
== (VT_VECTOR
| VT_LPSTR
))
2595 FIXME("Copy LPWSTRs\n");
2598 CopyMemory(pvarDest
->u
.capropvar
.pElems
, pvarSrc
->u
.capropvar
.pElems
, len
* elemSize
);
2605 /***********************************************************************
2606 * FreePropVariantArray [OLE32.@]
2608 HRESULT WINAPI
FreePropVariantArray(ULONG cVariants
, /* [in] */
2609 PROPVARIANT
*rgvars
) /* [in/out] */
2613 TRACE("(%lu, %p)\n", cVariants
, rgvars
);
2615 for(i
= 0; i
< cVariants
; i
++)
2616 PropVariantClear(&rgvars
[i
]);
2621 /******************************************************************************
2622 * DllDebugObjectRPCHook (OLE32.@)
2623 * turns on and off internal debugging, pointer is only used on macintosh
2626 BOOL WINAPI
DllDebugObjectRPCHook(BOOL b
, void *dummy
)