Added possibility to load .stabs/.stabstr sections from PE dlls.
[wine/multimedia.git] / ole / ole2.c
blobb9c0f383079c187b5781effae3f78fb8f35bf108
1 /*
2 * OLE2 library
4 * Copyright 1995 Martin von Loewis
5 * Copyright 1999 Francis Beaudet
6 */
8 #include <assert.h>
10 #include "windows.h"
11 #include "winerror.h"
12 #include "ole2.h"
13 #include "process.h"
14 #include "debug.h"
15 #include "objbase.h"
16 #include "objidl.h"
17 #include "wine/obj_base.h"
18 #include "wine/obj_clientserver.h"
19 #include "wine/obj_storage.h"
20 #include "wine/obj_moniker.h"
22 /******************************************************************************
23 * These are static/global variables and internal data structures that the
24 * OLE module uses to maintain it's state.
26 typedef struct tagDropTargetNode
28 HWND32 hwndTarget;
29 IDropTarget* dropTarget;
30 struct tagDropTargetNode* prevDropTarget;
31 struct tagDropTargetNode* nextDropTarget;
32 } DropTargetNode;
34 typedef struct tagTrackerWindowInfo
36 IDataObject* dataObject;
37 IDropSource* dropSource;
38 DWORD dwOKEffect;
39 DWORD* pdwEffect;
40 BOOL32 trackingDone;
41 HRESULT returnValue;
43 BOOL32 escPressed;
44 HWND32 curDragTargetHWND;
45 IDropTarget* curDragTarget;
46 } TrackerWindowInfo;
49 * This is the lock count on the OLE library. It is controlled by the
50 * OLEInitialize/OLEUninitialize methods.
52 static ULONG OLE_moduleLockCount = 0;
55 * Name of our registered window class.
57 static const char OLEDD_DRAGTRACKERCLASS[] = "WineDragDropTracker32";
60 * This is the head of the Drop target container.
62 static DropTargetNode* targetListHead = NULL;
64 /******************************************************************************
65 * These are the prototypes of the utility methods used for OLE Drag n Drop
67 static void OLEDD_Initialize();
68 static void OLEDD_UnInitialize();
69 static void OLEDD_InsertDropTarget(
70 DropTargetNode* nodeToAdd);
71 static DropTargetNode* OLEDD_ExtractDropTarget(
72 HWND32 hwndOfTarget);
73 static DropTargetNode* OLEDD_FindDropTarget(
74 HWND32 hwndOfTarget);
75 static LRESULT WINAPI OLEDD_DragTrackerWindowProc(
76 HWND32 hwnd,
77 UINT32 uMsg,
78 WPARAM32 wParam,
79 LPARAM lParam);
80 static void OLEDD_TrackMouseMove(
81 TrackerWindowInfo* trackerInfo,
82 POINT32 mousePos,
83 DWORD keyState);
84 static void OLEDD_TrackStateChange(
85 TrackerWindowInfo* trackerInfo,
86 POINT32 mousePos,
87 DWORD keyState);
88 static DWORD OLEDD_GetButtonState();
91 /******************************************************************************
92 * OleBuildVersion [OLE2.1]
94 DWORD WINAPI OleBuildVersion(void)
96 TRACE(ole,"(void)\n");
97 return (rmm<<16)+rup;
100 /***********************************************************************
101 * OleInitialize (OLE2.2) (OLE32.108)
103 HRESULT WINAPI OleInitialize(LPVOID reserved)
105 HRESULT hr;
107 TRACE(ole, "(%p)\n", reserved);
110 * The first duty of the OleInitialize is to initialize the COM libraries.
112 hr = CoInitializeEx32(NULL, COINIT_APARTMENTTHREADED);
115 * If the CoInitializeEx call failed, the OLE libraries can't be
116 * initialized.
118 if (FAILED(hr))
119 return hr;
122 * Then, it has to initialize the OLE specific modules.
123 * This includes:
124 * Clipboard
125 * Drag and Drop
126 * Object linking and Embedding
127 * In-place activation
129 if (OLE_moduleLockCount==0)
132 * Initialize the libraries.
134 TRACE(ole, "() - Initializing the OLE libraries\n");
137 * Drag and Drop
139 OLEDD_Initialize();
143 * Then, we increase the lock count on the OLE module.
145 OLE_moduleLockCount++;
147 return hr;
150 /******************************************************************************
151 * CoGetCurrentProcess [COMPOBJ.34] [OLE2.2][OLE32.108]
153 * NOTES
154 * Is DWORD really the correct return type for this function?
156 DWORD WINAPI CoGetCurrentProcess(void) {
157 return (DWORD)PROCESS_Current();
160 /******************************************************************************
161 * OleUninitialize [OLE2.3] [OLE32.131]
163 void WINAPI OleUninitialize(void)
165 TRACE(ole, "()\n");
168 * Decrease the lock count on the OLE module.
170 OLE_moduleLockCount--;
173 * If we hit the bottom of the lock stack, free the libraries.
175 if (OLE_moduleLockCount==0)
178 * Actually free the libraries.
180 TRACE(ole, "() - Freeing the last reference count\n");
183 * Drag and Drop
185 OLEDD_UnInitialize();
189 * Then, uninitialize the COM libraries.
191 CoUninitialize32();
194 /***********************************************************************
195 * OleFlushClipboard [OLE2.76]
197 HRESULT WINAPI OleFlushClipboard(void)
199 return S_OK;
202 /***********************************************************************
203 * OleSetClipboard [OLE32.127]
205 HRESULT WINAPI OleSetClipboard(LPVOID pDataObj)
207 FIXME(ole,"(%p), stub!\n", pDataObj);
208 return S_OK;
211 /******************************************************************************
212 * CoRegisterMessageFilter32 [OLE32.38]
214 HRESULT WINAPI CoRegisterMessageFilter32(
215 LPMESSAGEFILTER lpMessageFilter, /* Pointer to interface */
216 LPMESSAGEFILTER *lplpMessageFilter /* Indirect pointer to prior instance if non-NULL */
218 FIXME(ole,"stub\n");
219 if (lplpMessageFilter) {
220 *lplpMessageFilter = NULL;
222 return S_OK;
225 /******************************************************************************
226 * OleInitializeWOW [OLE32.109]
228 HRESULT WINAPI OleInitializeWOW(DWORD x) {
229 FIXME(ole,"(0x%08lx),stub!\n",x);
230 return 0;
233 /***********************************************************************
234 * RegisterDragDrop16 (OLE2.35)
236 HRESULT WINAPI RegisterDragDrop16(
237 HWND16 hwnd,
238 LPDROPTARGET pDropTarget
240 FIXME(ole,"(0x%04x,%p),stub!\n",hwnd,pDropTarget);
241 return S_OK;
244 /***********************************************************************
245 * RegisterDragDrop32 (OLE32.139)
247 HRESULT WINAPI RegisterDragDrop32(
248 HWND32 hwnd,
249 LPDROPTARGET pDropTarget)
251 DropTargetNode* dropTargetInfo;
253 TRACE(ole,"(0x%x,%p)\n", hwnd, pDropTarget);
256 * First, check if the window is already registered.
258 dropTargetInfo = OLEDD_FindDropTarget(hwnd);
260 if (dropTargetInfo!=NULL)
261 return DRAGDROP_E_ALREADYREGISTERED;
264 * If it's not there, we can add it. We first create a node for it.
266 dropTargetInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(DropTargetNode));
268 if (dropTargetInfo==NULL)
269 return E_OUTOFMEMORY;
271 dropTargetInfo->hwndTarget = hwnd;
272 dropTargetInfo->prevDropTarget = NULL;
273 dropTargetInfo->nextDropTarget = NULL;
276 * Don't forget that this is an interface pointer, need to nail it down since
277 * we keep a copy of it.
279 dropTargetInfo->dropTarget = pDropTarget;
280 IDropTarget_AddRef(dropTargetInfo->dropTarget);
282 OLEDD_InsertDropTarget(dropTargetInfo);
284 return S_OK;
287 /***********************************************************************
288 * RevokeDragDrop16 (OLE2.36)
290 HRESULT WINAPI RevokeDragDrop16(
291 HWND16 hwnd
293 FIXME(ole,"(0x%04x),stub!\n",hwnd);
294 return S_OK;
297 /***********************************************************************
298 * RevokeDragDrop32 (OLE32.141)
300 HRESULT WINAPI RevokeDragDrop32(
301 HWND32 hwnd)
303 DropTargetNode* dropTargetInfo;
305 TRACE(ole,"(0x%x)\n", hwnd);
308 * First, check if the window is already registered.
310 dropTargetInfo = OLEDD_ExtractDropTarget(hwnd);
313 * If it ain't in there, it's an error.
315 if (dropTargetInfo==NULL)
316 return DRAGDROP_E_NOTREGISTERED;
319 * If it's in there, clean-up it's used memory and
320 * references
322 IDropTarget_Release(dropTargetInfo->dropTarget);
323 HeapFree(GetProcessHeap(), 0, dropTargetInfo);
325 return S_OK;
328 /***********************************************************************
329 * OleRegGetUserType (OLE32.122)
331 HRESULT WINAPI OleRegGetUserType32(
332 REFCLSID clsid,
333 DWORD dwFormOfType,
334 LPOLESTR32* pszUserType)
336 FIXME(ole,",stub!\n");
337 return S_OK;
340 /***********************************************************************
341 * DoDragDrop32 [OLE32.65]
343 HRESULT WINAPI DoDragDrop32 (
344 IDataObject *pDataObject, /* ptr to the data obj */
345 IDropSource* pDropSource, /* ptr to the source obj */
346 DWORD dwOKEffect, /* effects allowed by the source */
347 DWORD *pdwEffect) /* ptr to effects of the source */
349 TrackerWindowInfo trackerInfo;
350 HWND32 hwndTrackWindow;
351 MSG32 msg;
353 TRACE(ole,"(DataObject %p, DropSource %p)\n", pDataObject, pDropSource);
356 * Setup the drag n drop tracking window.
358 trackerInfo.dataObject = pDataObject;
359 trackerInfo.dropSource = pDropSource;
360 trackerInfo.dwOKEffect = dwOKEffect;
361 trackerInfo.pdwEffect = pdwEffect;
362 trackerInfo.trackingDone = FALSE;
363 trackerInfo.escPressed = FALSE;
364 trackerInfo.curDragTargetHWND = 0;
365 trackerInfo.curDragTarget = 0;
367 hwndTrackWindow = CreateWindow32A(OLEDD_DRAGTRACKERCLASS,
368 "TrackerWindow",
369 WS_POPUP,
370 CW_USEDEFAULT32, CW_USEDEFAULT32,
371 CW_USEDEFAULT32, CW_USEDEFAULT32,
375 (LPVOID)&trackerInfo);
377 if (hwndTrackWindow!=0)
380 * Capture the mouse input
382 SetCapture32(hwndTrackWindow);
385 * Pump messages. All mouse input should go the the capture window.
387 while (!trackerInfo.trackingDone && GetMessage32A(&msg, 0, 0, 0) )
389 if ( (msg.message >= WM_KEYFIRST) &&
390 (msg.message <= WM_KEYFIRST) )
393 * When keyboard messages are sent to windows on this thread, we
394 * want to ignore notify the drop source that the state changed.
395 * in the case of the Escape key, we also notify the drop source
396 * we give it a special meaning.
398 if ( (msg.message==WM_KEYDOWN) &&
399 (msg.wParam==VK_ESCAPE) )
401 trackerInfo.escPressed = TRUE;
405 * Notify the drop source.
407 OLEDD_TrackStateChange(&trackerInfo,
408 msg.pt,
409 OLEDD_GetButtonState());
411 else
414 * Dispatch the messages only when it's not a keyboard message.
416 DispatchMessage32A(&msg);
421 * Destroy the temporary window.
423 DestroyWindow32(hwndTrackWindow);
425 return trackerInfo.returnValue;
428 return E_FAIL;
431 /***********************************************************************
432 * OleQueryLinkFromData32 [OLE32.118]
434 HRESULT WINAPI OleQueryLinkFromData32(
435 IDataObject* pSrcDataObject)
437 FIXME(ole,"(%p),stub!\n", pSrcDataObject);
438 return S_OK;
441 /***********************************************************************
442 * OleRegGetMiscStatus32 [OLE32.121]
444 HRESULT WINAPI OleRegGetMiscStatus32(
445 REFCLSID clsid,
446 DWORD dwAspect,
447 DWORD* pdwStatus)
449 FIXME(ole,"(),stub!\n");
450 return REGDB_E_CLASSNOTREG;
453 /***********************************************************************
454 * OleGetClipboard32 [OLE32.105]
456 HRESULT WINAPI OleGetClipboard32(
457 IDataObject** ppDataObj)
459 FIXME(ole,"(%p),stub!\n", ppDataObj);
461 if (ppDataObj)
462 *ppDataObj=0;
464 return E_FAIL;
467 /***
468 * OLEDD_Initialize()
470 * Initializes the OLE drag and drop data structures.
472 static void OLEDD_Initialize()
474 WNDCLASS32A wndClass;
476 ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
477 wndClass.style = CS_GLOBALCLASS;
478 wndClass.lpfnWndProc = (WNDPROC32)OLEDD_DragTrackerWindowProc;
479 wndClass.cbClsExtra = 0;
480 wndClass.cbWndExtra = sizeof(TrackerWindowInfo*);
481 wndClass.hCursor = 0;
482 wndClass.hbrBackground = 0;
483 wndClass.lpszClassName = OLEDD_DRAGTRACKERCLASS;
485 RegisterClass32A (&wndClass);
488 /***
489 * OLEDD_UnInitialize()
491 * Releases the OLE drag and drop data structures.
493 static void OLEDD_UnInitialize()
496 * Simply empty the list.
498 while (targetListHead!=NULL)
500 RevokeDragDrop32(targetListHead->hwndTarget);
504 /***
505 * OLEDD_InsertDropTarget()
507 * Insert the target node in the tree.
509 static void OLEDD_InsertDropTarget(DropTargetNode* nodeToAdd)
511 DropTargetNode* curNode;
512 DropTargetNode** parentNodeLink;
515 * Iterate the tree to find the insertion point.
517 curNode = targetListHead;
518 parentNodeLink = &targetListHead;
520 while (curNode!=NULL)
522 if (nodeToAdd->hwndTarget<curNode->hwndTarget)
525 * If the node we want to add has a smaller HWND, go left
527 parentNodeLink = &curNode->prevDropTarget;
528 curNode = curNode->prevDropTarget;
530 else if (nodeToAdd->hwndTarget>curNode->hwndTarget)
533 * If the node we want to add has a larger HWND, go right
535 parentNodeLink = &curNode->nextDropTarget;
536 curNode = curNode->nextDropTarget;
538 else
541 * The item was found in the list. It shouldn't have been there
543 assert(FALSE);
544 return;
549 * If we get here, we have found a spot for our item. The parentNodeLink
550 * pointer points to the pointer that we have to modify.
551 * The curNode should be NULL. We just have to establish the link and Voila!
553 assert(curNode==NULL);
554 assert(parentNodeLink!=NULL);
555 assert(*parentNodeLink==NULL);
557 *parentNodeLink=nodeToAdd;
560 /***
561 * OLEDD_ExtractDropTarget()
563 * Removes the target node from the tree.
565 static DropTargetNode* OLEDD_ExtractDropTarget(HWND32 hwndOfTarget)
567 DropTargetNode* curNode;
568 DropTargetNode** parentNodeLink;
571 * Iterate the tree to find the insertion point.
573 curNode = targetListHead;
574 parentNodeLink = &targetListHead;
576 while (curNode!=NULL)
578 if (hwndOfTarget<curNode->hwndTarget)
581 * If the node we want to add has a smaller HWND, go left
583 parentNodeLink = &curNode->prevDropTarget;
584 curNode = curNode->prevDropTarget;
586 else if (hwndOfTarget>curNode->hwndTarget)
589 * If the node we want to add has a larger HWND, go right
591 parentNodeLink = &curNode->nextDropTarget;
592 curNode = curNode->nextDropTarget;
594 else
597 * The item was found in the list. Detach it from it's parent and
598 * re-insert it's kids in the tree.
600 assert(parentNodeLink!=NULL);
601 assert(*parentNodeLink==curNode);
604 * We arbitrately re-attach the left sub-tree to the parent.
606 *parentNodeLink = curNode->prevDropTarget;
609 * And we re-insert the right subtree
611 if (curNode->nextDropTarget!=NULL)
613 OLEDD_InsertDropTarget(curNode->nextDropTarget);
617 * The node we found is still a valid node once we complete
618 * the unlinking of the kids.
620 curNode->nextDropTarget=NULL;
621 curNode->prevDropTarget=NULL;
623 return curNode;
628 * If we get here, the node is not in the tree
630 return NULL;
633 /***
634 * OLEDD_FindDropTarget()
636 * Finds information about the drop target.
638 static DropTargetNode* OLEDD_FindDropTarget(HWND32 hwndOfTarget)
640 DropTargetNode* curNode;
643 * Iterate the tree to find the HWND value.
645 curNode = targetListHead;
647 while (curNode!=NULL)
649 if (hwndOfTarget<curNode->hwndTarget)
652 * If the node we want to add has a smaller HWND, go left
654 curNode = curNode->prevDropTarget;
656 else if (hwndOfTarget>curNode->hwndTarget)
659 * If the node we want to add has a larger HWND, go right
661 curNode = curNode->nextDropTarget;
663 else
666 * The item was found in the list.
668 return curNode;
673 * If we get here, the item is not in the list
675 return NULL;
678 /***
679 * OLEDD_DragTrackerWindowProc()
681 * This method is the WindowProcedure of the drag n drop tracking
682 * window. During a drag n Drop operation, an invisible window is created
683 * to receive the user input and act upon it. This procedure is in charge
684 * of this behavior.
686 static LRESULT WINAPI OLEDD_DragTrackerWindowProc(
687 HWND32 hwnd,
688 UINT32 uMsg,
689 WPARAM32 wParam,
690 LPARAM lParam)
692 switch (uMsg)
694 case WM_CREATE:
696 LPCREATESTRUCT32A createStruct = (LPCREATESTRUCT32A)lParam;
698 SetWindowLong32A(hwnd, 0, (LONG)createStruct->lpCreateParams);
701 break;
703 case WM_MOUSEMOVE:
705 TrackerWindowInfo* trackerInfo = (TrackerWindowInfo*)GetWindowLong32A(hwnd, 0);
706 POINT32 mousePos;
709 * Get the current mouse position in screen coordinates.
711 mousePos.x = LOWORD(lParam);
712 mousePos.y = HIWORD(lParam);
713 ClientToScreen32(hwnd, &mousePos);
716 * Track the movement of the mouse.
718 OLEDD_TrackMouseMove(trackerInfo, mousePos, wParam);
720 break;
722 case WM_LBUTTONUP:
723 case WM_MBUTTONUP:
724 case WM_RBUTTONUP:
725 case WM_LBUTTONDOWN:
726 case WM_MBUTTONDOWN:
727 case WM_RBUTTONDOWN:
729 TrackerWindowInfo* trackerInfo = (TrackerWindowInfo*)GetWindowLong32A(hwnd, 0);
730 POINT32 mousePos;
733 * Get the current mouse position in screen coordinates.
735 mousePos.x = LOWORD(lParam);
736 mousePos.y = HIWORD(lParam);
737 ClientToScreen32(hwnd, &mousePos);
740 * Notify everyone that the button state changed
741 * TODO: Check if the "escape" key was pressed.
743 OLEDD_TrackStateChange(trackerInfo, mousePos, wParam);
745 break;
750 * This is a window proc after all. Let's call the default.
752 return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
755 /***
756 * OLEDD_TrackMouseMove()
758 * This method is invoked while a drag and drop operation is in effect.
759 * it will generate the appropriate callbacks in the drop source
760 * and drop target. It will also provide the expected feedback to
761 * the user.
763 * params:
764 * trackerInfo - Pointer to the structure identifying the
765 * drag & drop operation that is currently
766 * active.
767 * mousePos - Current position of the mouse in screen
768 * coordinates.
769 * keyState - Contains the state of the shift keys and the
770 * mouse buttons (MK_LBUTTON and the like)
772 static void OLEDD_TrackMouseMove(
773 TrackerWindowInfo* trackerInfo,
774 POINT32 mousePos,
775 DWORD keyState)
777 HWND32 hwndNewTarget = 0;
778 HRESULT hr = S_OK;
781 * Get the handle of the window under the mouse
783 hwndNewTarget = WindowFromPoint32(mousePos);
786 * If we are hovering over the same target as before, send the
787 * DragOver notification
789 if ( (trackerInfo->curDragTarget != 0) &&
790 (trackerInfo->curDragTargetHWND==hwndNewTarget) )
792 POINTL mousePosParam;
795 * The documentation tells me that the coordinate should be in the target
796 * window's coordinate space. However, the tests I made tell me the
797 * coordinates should be in screen coordinates.
799 mousePosParam.x = mousePos.x;
800 mousePosParam.y = mousePos.y;
802 IDropTarget_DragOver(trackerInfo->curDragTarget,
803 keyState,
804 mousePosParam,
805 trackerInfo->pdwEffect);
807 else
809 DropTargetNode* newDropTargetNode = 0;
812 * If we changed window, we have to notify our old target and check for
813 * the new one.
815 if (trackerInfo->curDragTarget!=0)
817 IDropTarget_DragLeave(trackerInfo->curDragTarget);
821 * Make sure we're hovering over a window.
823 if (hwndNewTarget!=0)
826 * Find-out if there is a drag target under the mouse
828 newDropTargetNode = OLEDD_FindDropTarget(hwndNewTarget);
830 trackerInfo->curDragTargetHWND = hwndNewTarget;
831 trackerInfo->curDragTarget = newDropTargetNode ? newDropTargetNode->dropTarget : 0;
834 * If there is, notify it that we just dragged-in
836 if (trackerInfo->curDragTarget!=0)
838 POINTL mousePosParam;
841 * The documentation tells me that the coordinate should be in the target
842 * window's coordinate space. However, the tests I made tell me the
843 * coordinates should be in screen coordinates.
845 mousePosParam.x = mousePos.x;
846 mousePosParam.y = mousePos.y;
848 IDropTarget_DragEnter(trackerInfo->curDragTarget,
849 trackerInfo->dataObject,
850 keyState,
851 mousePosParam,
852 trackerInfo->pdwEffect);
855 else
858 * The mouse is not over a window so we don't track anything.
860 trackerInfo->curDragTargetHWND = 0;
861 trackerInfo->curDragTarget = 0;
866 * Now that we have done that, we have to tell the source to give
867 * us feedback on the work being done by the target. If we don't
868 * have a target, simulate no effect.
870 if (trackerInfo->curDragTarget==0)
872 *trackerInfo->pdwEffect = DROPEFFECT_NONE;
875 hr = IDropSource_GiveFeedback(trackerInfo->dropSource,
876 *trackerInfo->pdwEffect);
879 * When we ask for feedback from the drop source, sometimes it will
880 * do all the necessary work and sometimes it will not handle it
881 * when that's the case, we must display the standard drag and drop
882 * cursors.
884 if (hr==DRAGDROP_S_USEDEFAULTCURSORS)
886 if ( (*trackerInfo->pdwEffect & DROPEFFECT_MOVE) ||
887 (*trackerInfo->pdwEffect & DROPEFFECT_COPY) ||
888 (*trackerInfo->pdwEffect & DROPEFFECT_LINK) )
890 SetCursor32(LoadCursor32A(0, IDC_SIZEALL32A));
892 else
894 SetCursor32(LoadCursor32A(0, IDC_NO32A));
899 /***
900 * OLEDD_TrackStateChange()
902 * This method is invoked while a drag and drop operation is in effect.
903 * It is used to notify the drop target/drop source callbacks when
904 * the state of the keyboard or mouse button change.
906 * params:
907 * trackerInfo - Pointer to the structure identifying the
908 * drag & drop operation that is currently
909 * active.
910 * mousePos - Current position of the mouse in screen
911 * coordinates.
912 * keyState - Contains the state of the shift keys and the
913 * mouse buttons (MK_LBUTTON and the like)
915 static void OLEDD_TrackStateChange(
916 TrackerWindowInfo* trackerInfo,
917 POINT32 mousePos,
918 DWORD keyState)
921 * Ask the drop source what to do with the operation.
923 trackerInfo->returnValue = IDropSource_QueryContinueDrag(
924 trackerInfo->dropSource,
925 trackerInfo->escPressed,
926 keyState);
929 * All the return valued will stop the operation except the S_OK
930 * return value.
932 if (trackerInfo->returnValue!=S_OK)
935 * Make sure the message loop in DoDragDrop stops
937 trackerInfo->trackingDone = TRUE;
940 * Release the mouse in case the drop target decides to show a popup
941 * or a menu or something.
943 ReleaseCapture();
946 * If we end-up over a target, drop the object in the target or
947 * inform the target that the operation was cancelled.
949 if (trackerInfo->curDragTarget!=0)
951 switch (trackerInfo->returnValue)
954 * If the source wants us to complete the operation, we tell
955 * the drop target that we just dropped the object in it.
957 case DRAGDROP_S_DROP:
959 POINTL mousePosParam;
962 * The documentation tells me that the coordinate should be
963 * in the target window's coordinate space. However, the tests
964 * I made tell me the coordinates should be in screen coordinates.
966 mousePosParam.x = mousePos.x;
967 mousePosParam.y = mousePos.y;
969 IDropTarget_Drop(trackerInfo->curDragTarget,
970 trackerInfo->dataObject,
971 keyState,
972 mousePosParam,
973 trackerInfo->pdwEffect);
974 break;
977 * If the source told us that we should cancel, fool the drop
978 * target by telling it that the mouse left it's window.
980 case DRAGDROP_S_CANCEL:
981 IDropTarget_DragLeave(trackerInfo->curDragTarget);
982 break;
988 /***
989 * OLEDD_GetButtonState()
991 * This method will use the current state of the keyboard to build
992 * a button state mask equivalent to the one passed in the
993 * WM_MOUSEMOVE wParam.
995 static DWORD OLEDD_GetButtonState()
997 BYTE keyboardState[256];
998 DWORD keyMask = 0;
1000 GetKeyboardState(keyboardState);
1002 if ( (keyboardState[VK_SHIFT] & 0x80) !=0)
1003 keyMask |= MK_SHIFT;
1005 if ( (keyboardState[VK_CONTROL] & 0x80) !=0)
1006 keyMask |= MK_CONTROL;
1008 if ( (keyboardState[VK_LBUTTON] & 0x80) !=0)
1009 keyMask |= MK_LBUTTON;
1011 if ( (keyboardState[VK_RBUTTON] & 0x80) !=0)
1012 keyMask |= MK_RBUTTON;
1014 if ( (keyboardState[VK_MBUTTON] & 0x80) !=0)
1015 keyMask |= MK_MBUTTON;
1017 return keyMask;