Changeset 6711 for trunk/src/ole32/ole2.c
- Timestamp:
- Sep 15, 2001, 11:32:00 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ole32/ole2.c
r6648 r6711 1 /* $Id: ole2.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */2 1 /* 3 * 4 * 5 * Copyright 1995Martin von Loewis2 * OLE2 library 3 * 4 * Copyright 1995 Martin von Loewis 6 5 * Copyright 1999 Francis Beaudet 7 * Copyright 1999 Noel Borthwick 6 * Copyright 1999 Noel Borthwick 8 7 */ 9 8 … … 33 32 34 33 /****************************************************************************** 35 * These are static/global variables and internal data structures that the 34 * These are static/global variables and internal data structures that the 36 35 * OLE module uses to maintain it's state. 37 36 */ … … 95 94 96 95 /****************************************************************************** 97 * These are the prototypes of miscelaneous utility methods 96 * These are the prototypes of miscelaneous utility methods 98 97 */ 99 98 static void OLEUTL_ReadRegistryDWORDValue(HKEY regKey, DWORD* pdwValue); … … 124 123 static void OLEDD_UnInitialize(); 125 124 static void OLEDD_InsertDropTarget( 126 125 DropTargetNode* nodeToAdd); 127 126 static DropTargetNode* OLEDD_ExtractDropTarget( 128 127 HWND hwndOfTarget); … … 130 129 HWND hwndOfTarget); 131 130 static LRESULT WINAPI OLEDD_DragTrackerWindowProc( 132 HWND hwnd, 133 134 WPARAM wParam, 135 131 HWND hwnd, 132 UINT uMsg, 133 WPARAM wParam, 134 LPARAM lParam); 136 135 static void OLEDD_TrackMouseMove( 137 136 TrackerWindowInfo* trackerInfo, 138 139 137 POINT mousePos, 138 DWORD keyState); 140 139 static void OLEDD_TrackStateChange( 141 140 TrackerWindowInfo* trackerInfo, 142 143 141 POINT mousePos, 142 DWORD keyState); 144 143 static DWORD OLEDD_GetButtonState(); 145 144 146 145 147 146 /****************************************************************************** 148 * OleBuildVersion[OLE2.1]147 * OleBuildVersion [OLE2.1] 149 148 */ 150 149 DWORD WINAPI OleBuildVersion(void) … … 169 168 170 169 /* 171 * If the CoInitializeEx call failed, the OLE libraries can't be 170 * If the CoInitializeEx call failed, the OLE libraries can't be 172 171 * initialized. 173 172 */ 174 173 if (FAILED(hr)) 175 return hr; 174 return hr; 176 175 177 176 /* … … 185 184 if (OLE_moduleLockCount==0) 186 185 { 187 /* 186 /* 188 187 * Initialize the libraries. 189 188 */ … … 209 208 * Then, we increase the lock count on the OLE module. 210 209 */ 211 OLE_moduleLockCount++; 210 OLE_moduleLockCount++; 212 211 213 212 return hr; … … 215 214 216 215 /****************************************************************************** 217 * CoGetCurrentProcess[COMPOBJ.34] [OLE2.2][OLE32.108]216 * CoGetCurrentProcess [COMPOBJ.34] [OLE2.2][OLE32.108] 218 217 * 219 218 * NOTES … … 222 221 DWORD WINAPI CoGetCurrentProcess(void) 223 222 { 224 223 return GetCurrentProcessId(); 225 224 } 226 225 227 226 /****************************************************************************** 228 * OleUninitialize[OLE2.3] [OLE32.131]227 * OleUninitialize [OLE2.3] [OLE32.131] 229 228 */ 230 229 void WINAPI OleUninitialize(void) … … 256 255 */ 257 256 OLEDD_UnInitialize(); 258 257 259 258 /* 260 259 * OLE shared menu … … 262 261 OLEMenu_UnInitialize(); 263 262 } 264 263 265 264 /* 266 265 * Then, uninitialize the COM libraries. … … 272 271 //imessagefilter.cpp 273 272 /****************************************************************************** 274 * CoRegisterMessageFilter[OLE32.38]273 * CoRegisterMessageFilter [OLE32.38] 275 274 */ 276 275 HRESULT WINAPI CoRegisterMessageFilter( 277 LPMESSAGEFILTER lpMessageFilter, 278 LPMESSAGEFILTER *lplpMessageFilter 276 LPMESSAGEFILTER lpMessageFilter, /* [in] Pointer to interface */ 277 LPMESSAGEFILTER *lplpMessageFilter /* [out] Indirect pointer to prior instance if non-NULL */ 279 278 ) { 280 279 FIXME("stub\n"); 281 280 if (lplpMessageFilter) { 282 281 *lplpMessageFilter = NULL; 283 282 } 284 283 return S_OK; … … 287 286 288 287 /****************************************************************************** 289 * OleInitializeWOW[OLE32.109]288 * OleInitializeWOW [OLE32.109] 290 289 */ 291 290 HRESULT WINAPI OleInitializeWOW(DWORD x) { … … 298 297 */ 299 298 HRESULT WINAPI RegisterDragDrop16( 300 301 299 HWND16 hwnd, 300 LPDROPTARGET pDropTarget 302 301 ) { 303 304 302 FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget); 303 return S_OK; 305 304 } 306 305 … … 309 308 */ 310 309 HRESULT WINAPI RegisterDragDrop( 311 312 LPDROPTARGET pDropTarget) 310 HWND hwnd, 311 LPDROPTARGET pDropTarget) 313 312 { 314 313 DropTargetNode* dropTargetInfo; … … 342 341 dropTargetInfo->dropTarget = pDropTarget; 343 342 IDropTarget_AddRef(dropTargetInfo->dropTarget); 344 343 345 344 OLEDD_InsertDropTarget(dropTargetInfo); 346 345 347 346 return S_OK; 348 347 } 349 348 … … 352 351 */ 353 352 HRESULT WINAPI RevokeDragDrop16( 354 353 HWND16 hwnd 355 354 ) { 356 357 355 FIXME("(0x%04x),stub!\n",hwnd); 356 return S_OK; 358 357 } 359 358 … … 362 361 */ 363 362 HRESULT WINAPI RevokeDragDrop( 364 363 HWND hwnd) 365 364 { 366 365 DropTargetNode* dropTargetInfo; … … 384 383 */ 385 384 IDropTarget_Release(dropTargetInfo->dropTarget); 386 HeapFree(GetProcessHeap(), 0, dropTargetInfo); 387 388 385 HeapFree(GetProcessHeap(), 0, dropTargetInfo); 386 387 return S_OK; 389 388 } 390 389 … … 397 396 * way they are registered. 398 397 */ 399 HRESULT WINAPI OleRegGetUserType( 400 REFCLSID clsid, 401 402 398 HRESULT WINAPI OleRegGetUserType( 399 REFCLSID clsid, 400 DWORD dwFormOfType, 401 LPOLESTR* pszUserType) 403 402 { 404 403 char keyName[60]; … … 428 427 */ 429 428 hres = RegOpenKeyA(HKEY_CLASSES_ROOT, 430 431 429 keyName, 430 &clsidKey); 432 431 433 432 if (hres != ERROR_SUCCESS) … … 440 439 441 440 hres = RegQueryValueExA(clsidKey, 442 443 444 445 446 441 "", 442 NULL, 443 &dwKeyType, 444 NULL, 445 &cbData); 447 446 448 447 if (hres!=ERROR_SUCCESS) … … 474 473 475 474 hres = RegQueryValueExA(clsidKey, 476 477 478 479 480 475 "", 476 NULL, 477 &dwKeyType, 478 buffer, 479 &cbData); 481 480 482 481 RegCloseKey(clsidKey); 483 482 484 483 485 484 if (hres!=ERROR_SUCCESS) 486 485 { … … 528 527 529 528 hwndTrackWindow = CreateWindowA(OLEDD_DRAGTRACKERCLASS, 530 531 532 533 534 535 536 537 529 "TrackerWindow", 530 WS_POPUP, 531 CW_USEDEFAULT, CW_USEDEFAULT, 532 CW_USEDEFAULT, CW_USEDEFAULT, 533 0, 534 0, 535 0, 536 (LPVOID)&trackerInfo); 538 537 539 538 if (hwndTrackWindow!=0) … … 549 548 while (!trackerInfo.trackingDone && GetMessageA(&msg, 0, 0, 0) ) 550 549 { 551 if ( (msg.message >= WM_KEYFIRST) && 552 550 if ( (msg.message >= WM_KEYFIRST) && 551 (msg.message <= WM_KEYLAST) ) 553 552 { 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 */ 569 570 571 553 /* 554 * When keyboard messages are sent to windows on this thread, we 555 * want to ignore notify the drop source that the state changed. 556 * in the case of the Escape key, we also notify the drop source 557 * we give it a special meaning. 558 */ 559 if ( (msg.message==WM_KEYDOWN) && 560 (msg.wParam==VK_ESCAPE) ) 561 { 562 trackerInfo.escPressed = TRUE; 563 } 564 565 /* 566 * Notify the drop source. 567 */ 568 OLEDD_TrackStateChange(&trackerInfo, 569 msg.pt, 570 OLEDD_GetButtonState()); 572 571 } 573 572 else 574 573 { 575 576 577 578 574 /* 575 * Dispatch the messages only when it's not a keyboard message. 576 */ 577 DispatchMessageA(&msg); 579 578 } 580 579 } … … 634 633 */ 635 634 result = RegOpenKeyA(HKEY_CLASSES_ROOT, 636 637 635 keyName, 636 &clsidKey); 638 637 639 638 if (result != ERROR_SUCCESS) … … 644 643 */ 645 644 result = RegOpenKeyA(clsidKey, 646 647 648 649 645 "MiscStatus", 646 &miscStatusKey); 647 648 650 649 if (result != ERROR_SUCCESS) 651 650 { … … 665 664 666 665 result = RegOpenKeyA(miscStatusKey, 667 668 669 666 keyName, 667 &aspectKey); 668 670 669 if (result == ERROR_SUCCESS) 671 670 { … … 687 686 */ 688 687 HRESULT WINAPI OleSetContainedObject( 689 LPUNKNOWN pUnknown, 688 LPUNKNOWN pUnknown, 690 689 BOOL fContained) 691 690 { … … 696 695 697 696 hres = IUnknown_QueryInterface(pUnknown, 698 699 697 &IID_IRunnableObject, 698 (void**)&runnable); 700 699 701 700 if (SUCCEEDED(hres)) … … 715 714 */ 716 715 HRESULT WINAPI OleLoad( 717 LPSTORAGE pStg, 718 REFIID riid, 719 LPOLECLIENTSITE pClientSite, 716 LPSTORAGE pStg, 717 REFIID riid, 718 LPOLECLIENTSITE pClientSite, 720 719 LPVOID* ppvObj) 721 720 { … … 726 725 727 726 TRACE("(%p,%p,%p,%p)\n", pStg, riid, pClientSite, ppvObj); 728 727 729 728 /* 730 729 * TODO, Conversion ... OleDoAutoConvert … … 740 739 */ 741 740 hres = CoCreateInstance(&storageInfo.clsid, 742 743 744 745 741 NULL, 742 CLSCTX_INPROC_HANDLER, 743 &IID_IOleObject, 744 (void**)&oleObject); 746 745 747 746 /* … … 752 751 { 753 752 hres = OleCreateDefaultHandler(&storageInfo.clsid, 754 755 756 753 NULL, 754 &IID_IOleObject, 755 (void**)&oleObject); 757 756 } 758 757 … … 772 771 */ 773 772 hres = IOleObject_QueryInterface(oleObject, 774 775 776 777 if (SUCCEEDED(hres)) 773 &IID_IPersistStorage, 774 (void**)&persistStorage); 775 776 if (SUCCEEDED(hres)) 778 777 { 779 778 IPersistStorage_Load(persistStorage, pStg); … … 828 827 { 829 828 IStorage_Commit(pStg, 830 831 } 832 829 STGC_DEFAULT); 830 } 831 833 832 return hres; 834 833 } … … 838 837 * OleLockRunning [OLE32.114] 839 838 */ 840 HRESULT WINAPI OleLockRunning(LPUNKNOWN pUnknown, BOOL fLock, BOOL fLastUnlockCloses) 839 HRESULT WINAPI OleLockRunning(LPUNKNOWN pUnknown, BOOL fLock, BOOL fLastUnlockCloses) 841 840 { 842 841 IRunnableObject* runnable = NULL; … … 846 845 847 846 hres = IUnknown_QueryInterface(pUnknown, 848 849 847 &IID_IRunnableObject, 848 (void**)&runnable); 850 849 851 850 if (SUCCEEDED(hres)) … … 903 902 pHookItem->tid = tid; 904 903 pHookItem->hHeap = GetProcessHeap(); 905 904 906 905 /* Install a thread scope message hook for WH_GETMESSAGE */ 907 906 pHookItem->GetMsg_hHook = SetWindowsHookExA( WH_GETMESSAGE, OLEMenu_GetMsgProc, … … 919 918 pHookItem->next = hook_list; 920 919 hook_list = pHookItem; 921 920 922 921 return TRUE; 923 922 924 923 CLEANUP: 925 924 /* Unhook any hooks */ … … 930 929 /* Release the hook table entry */ 931 930 HeapFree(pHookItem->hHeap, 0, pHookItem ); 932 931 933 932 return FALSE; 934 933 } … … 995 994 return pHookItem; 996 995 } 997 996 998 997 return NULL; 999 998 } … … 1016 1015 { 1017 1016 HMENU hsubmenu; 1018 1017 1019 1018 /* Is the current item a submenu? */ 1020 1019 if ( (hsubmenu = GetSubMenu(hMainMenu, i)) ) … … 1063 1062 if ( !OLEMenu_FindMainMenuIndex( pOleMenuDescriptor->hmenuCombined, hmenu, &nPos ) ) 1064 1063 return FALSE; 1065 1064 1066 1065 /* The group widths array has counts for the number of elements 1067 1066 * in the groups File, Edit, Container, Object, Window, Help. … … 1096 1095 OleMenuHookItem *pHookItem = NULL; 1097 1096 WORD fuFlags; 1098 1097 1099 1098 TRACE("%i, %04x, %08x\n", code, wParam, (unsigned)lParam ); 1100 1099 … … 1102 1101 if ( HC_ACTION != code ) 1103 1102 goto NEXTHOOK; 1104 1103 1105 1104 /* Retrieve the current message being dispatched from lParam */ 1106 1105 pMsg = (LPCWPSTRUCT)lParam; … … 1132 1131 goto NEXTHOOK; 1133 1132 } 1134 1133 1135 1134 case WM_INITMENUPOPUP: 1136 1135 { … … 1139 1138 break; 1140 1139 } 1141 1140 1142 1141 case WM_MENUSELECT: 1143 1142 { … … 1152 1151 break; 1153 1152 } 1154 1153 1155 1154 case WM_DRAWITEM: 1156 1155 { … … 1172 1171 pMsg->message, pMsg->wParam, pMsg->lParam ); 1173 1172 } 1174 1173 1175 1174 NEXTHOOK: 1176 1175 if ( pOleMenuDescriptor ) 1177 1176 GlobalUnlock( hOleMenu ); 1178 1177 1179 1178 /* Lookup the hook item for the current thread */ 1180 1179 if ( !( pHookItem = OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) ) … … 1184 1183 return 0; 1185 1184 } 1186 1185 1187 1186 /* Pass on the message to the next hooker */ 1188 1187 return CallNextHookEx( pHookItem->CallWndProc_hHook, code, wParam, lParam ); … … 1201 1200 OleMenuHookItem *pHookItem = NULL; 1202 1201 WORD wCode; 1203 1202 1204 1203 TRACE("%i, %04x, %08x\n", code, wParam, (unsigned)lParam ); 1205 1204 … … 1207 1206 if ( HC_ACTION != code ) 1208 1207 goto NEXTHOOK; 1209 1208 1210 1209 /* Retrieve the current message being dispatched from lParam */ 1211 1210 pMsg = (LPMSG)lParam; … … 1246 1245 pMsg->hwnd = pOleMenuDescriptor->hwndActiveObject; 1247 1246 } 1248 1247 1249 1248 NEXTHOOK: 1250 1249 if ( pOleMenuDescriptor ) 1251 1250 GlobalUnlock( hOleMenu ); 1252 1251 1253 1252 /* Lookup the hook item for the current thread */ 1254 1253 if ( !( pHookItem = OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) ) … … 1258 1257 return FALSE; 1259 1258 } 1260 1259 1261 1260 /* Pass on the message to the next hooker */ 1262 1261 return CallNextHookEx( pHookItem->GetMsg_hHook, code, wParam, lParam ); … … 1296 1295 for ( i = 0; i < 6; i++ ) 1297 1296 pOleMenuDescriptor->mgw.width[i] = lpMenuWidths->width[i]; 1298 1297 1299 1298 pOleMenuDescriptor->hmenuCombined = hmenuCombined; 1300 1299 pOleMenuDescriptor->bIsServerItem = FALSE; 1301 1300 GlobalUnlock( hOleMenu ); 1302 1301 1303 1302 return hOleMenu; 1304 1303 } … … 1313 1312 if ( hmenuDescriptor ) 1314 1313 GlobalFree( hmenuDescriptor ); 1315 1314 return S_OK; 1316 1315 } 1317 1316 … … 1322 1321 * OLE should install context sensitive help F1 filtering for the app when 1323 1322 * these are non null. 1324 * 1323 * 1325 1324 * PARAMS: 1326 1325 * hOleMenu Handle to composite menu descriptor … … 1350 1349 { 1351 1350 FIXME("(%x, %x, %x, %p, %p), Context sensitive help filtering not implemented!\n", 1352 1353 1354 1355 1356 1351 (unsigned int)hOleMenu, 1352 hwndFrame, 1353 hwndActiveObject, 1354 lpFrame, 1355 lpActiveObject); 1357 1356 } 1358 1357 … … 1370 1369 if ( OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) 1371 1370 return E_FAIL; 1372 1371 1373 1372 /* Get the menu descriptor */ 1374 1373 pOleMenuDescriptor = (OleMenuDescriptor *) GlobalLock( hOleMenu ); … … 1382 1381 GlobalUnlock( hOleMenu ); 1383 1382 pOleMenuDescriptor = NULL; 1384 1383 1385 1384 /* Add a menu descriptor windows property to the frame window */ 1386 1385 SetPropA( hwndFrame, "PROP_OLEMenuDescriptor", hOleMenu ); … … 1395 1394 if ( !OLEMenu_UnInstallHooks( GetCurrentThreadId() ) ) 1396 1395 return E_FAIL; 1397 1396 1398 1397 /* Remove the menu descriptor property from the frame window */ 1399 1398 RemovePropA( hwndFrame, "PROP_OLEMenuDescriptor" ); 1400 1399 } 1401 1400 1402 1401 return S_OK; 1403 1402 } … … 1420 1419 #endif 1421 1420 { 1422 1423 1421 WARN_(accel)("invalid accel handle=%04x\n", hAccel); 1422 return FALSE; 1424 1423 } 1425 1424 if((lpMsg->message != WM_KEYDOWN && 1426 1427 1428 1429 1425 lpMsg->message != WM_KEYUP && 1426 lpMsg->message != WM_SYSKEYDOWN && 1427 lpMsg->message != WM_SYSKEYUP && 1428 lpMsg->message != WM_CHAR)) return FALSE; 1430 1429 1431 1430 TRACE_(accel)("hAccel=%04x, cAccelEntries=%d," 1432 1433 1434 1431 "msg->hwnd=%04x, msg->message=%04x, wParam=%08x, lParam=%08lx\n", 1432 hAccel, cAccelEntries, 1433 lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam); 1435 1434 for(i = 0; i < cAccelEntries; i++) 1436 1435 { 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 {/* ^^ ALT pressed */1467 1468 1469 1470 1471 1472 1473 } 1436 if(lpAccelTbl[i].key != lpMsg->wParam) 1437 continue; 1438 1439 if(lpMsg->message == WM_CHAR) 1440 { 1441 if(!(lpAccelTbl[i].fVirt & FALT) && !(lpAccelTbl[i].fVirt & FVIRTKEY)) 1442 { 1443 TRACE_(accel)("found accel for WM_CHAR: ('%c')\n", lpMsg->wParam & 0xff); 1444 goto found; 1445 } 1446 } 1447 else 1448 { 1449 if(lpAccelTbl[i].fVirt & FVIRTKEY) 1450 { 1451 INT mask = 0; 1452 TRACE_(accel)("found accel for virt_key %04x (scan %04x)\n", 1453 lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff); 1454 if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT; 1455 if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL; 1456 if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT; 1457 if(mask == (lpAccelTbl[i].fVirt & (FSHIFT | FCONTROL | FALT))) goto found; 1458 TRACE_(accel)("incorrect SHIFT/CTRL/ALT-state\n"); 1459 } 1460 else 1461 { 1462 if(!(lpMsg->lParam & 0x01000000)) /* no special_key */ 1463 { 1464 if((lpAccelTbl[i].fVirt & FALT) && (lpMsg->lParam & 0x20000000)) 1465 { /* ^^ ALT pressed */ 1466 TRACE_(accel)("found accel for Alt-%c\n", lpMsg->wParam & 0xff); 1467 goto found; 1468 } 1469 } 1470 } 1471 } 1472 } 1474 1473 1475 1474 WARN_(accel)("couldn't translate accelerator key\n"); … … 1491 1490 case TYMED_HGLOBAL: 1492 1491 { 1493 if ( (pmedium->pUnkForRelease==0) && 1494 1495 1492 if ( (pmedium->pUnkForRelease==0) && 1493 (pmedium->u.hGlobal!=0) ) 1494 GlobalFree(pmedium->u.hGlobal); 1496 1495 1497 1496 pmedium->u.hGlobal = 0; … … 1502 1501 if (pmedium->u.lpszFileName!=0) 1503 1502 { 1504 1505 1506 1507 1508 1509 1503 if (pmedium->pUnkForRelease==0) 1504 { 1505 DeleteFileW(pmedium->u.lpszFileName); 1506 } 1507 1508 CoTaskMemFree(pmedium->u.lpszFileName); 1510 1509 } 1511 1510 … … 1517 1516 if (pmedium->u.pstm!=0) 1518 1517 { 1519 1518 IStream_Release(pmedium->u.pstm); 1520 1519 } 1521 1520 … … 1527 1526 if (pmedium->u.pstg!=0) 1528 1527 { 1529 1528 IStorage_Release(pmedium->u.pstg); 1530 1529 } 1531 1530 … … 1535 1534 case TYMED_GDI: 1536 1535 { 1537 if ( (pmedium->pUnkForRelease==0) && 1538 1539 1536 if ( (pmedium->pUnkForRelease==0) && 1537 (pmedium->u.hGlobal!=0) ) 1538 DeleteObject(pmedium->u.hGlobal); 1540 1539 1541 1540 pmedium->u.hGlobal = 0; … … 1544 1543 case TYMED_MFPICT: 1545 1544 { 1546 if ( (pmedium->pUnkForRelease==0) && 1547 1545 if ( (pmedium->pUnkForRelease==0) && 1546 (pmedium->u.hMetaFilePict!=0) ) 1548 1547 { 1549 1550 1551 1552 1548 LPMETAFILEPICT pMP = GlobalLock(pmedium->u.hMetaFilePict); 1549 DeleteMetaFile(pMP->hMF); 1550 GlobalUnlock(pmedium->u.hMetaFilePict); 1551 GlobalFree(pmedium->u.hMetaFilePict); 1553 1552 } 1554 1553 … … 1558 1557 case TYMED_ENHMF: 1559 1558 { 1560 if ( (pmedium->pUnkForRelease==0) && 1561 1559 if ( (pmedium->pUnkForRelease==0) && 1560 (pmedium->u.hEnhMetaFile!=0) ) 1562 1561 { 1563 1562 DeleteEnhMetaFile(pmedium->u.hEnhMetaFile); 1564 1563 } 1565 1564 … … 1599 1598 wndClass.hbrBackground = 0; 1600 1599 wndClass.lpszClassName = OLEDD_DRAGTRACKERCLASS; 1601 1600 1602 1601 RegisterClassA (&wndClass); 1603 1602 } … … 1665 1664 /* 1666 1665 * If we get here, we have found a spot for our item. The parentNodeLink 1667 * pointer points to the pointer that we have to modify. 1666 * pointer points to the pointer that we have to modify. 1668 1667 * The curNode should be NULL. We just have to establish the link and Voila! 1669 1668 */ … … 1712 1711 { 1713 1712 /* 1714 * The item was found in the list. Detach it from it's parent and 1713 * The item was found in the list. Detach it from it's parent and 1715 1714 * re-insert it's kids in the tree. 1716 1715 */ … … 1728 1727 if (curNode->nextDropTarget!=NULL) 1729 1728 { 1730 1729 OLEDD_InsertDropTarget(curNode->nextDropTarget); 1731 1730 } 1732 1731 … … 1802 1801 */ 1803 1802 static LRESULT WINAPI OLEDD_DragTrackerWindowProc( 1804 HWND hwnd, 1805 1806 WPARAM wParam, 1807 1803 HWND hwnd, 1804 UINT uMsg, 1805 WPARAM wParam, 1806 LPARAM lParam) 1808 1807 { 1809 1808 switch (uMsg) … … 1813 1812 LPCREATESTRUCTA createStruct = (LPCREATESTRUCTA)lParam; 1814 1813 1815 SetWindowLongA(hwnd, 0, (LONG)createStruct->lpCreateParams); 1816 1817 1814 SetWindowLongA(hwnd, 0, (LONG)createStruct->lpCreateParams); 1815 1816 1818 1817 break; 1819 1818 } … … 1910 1909 * DragOver notification 1911 1910 */ 1912 if ( (trackerInfo->curDragTarget != 0) && 1911 if ( (trackerInfo->curDragTarget != 0) && 1913 1912 (trackerInfo->curDragTargetHWND==hwndNewTarget) ) 1914 1913 { 1915 1914 POINTL mousePosParam; 1916 1915 1917 1916 /* 1918 1917 * The documentation tells me that the coordinate should be in the target … … 1922 1921 mousePosParam.x = mousePos.x; 1923 1922 mousePosParam.y = mousePos.y; 1924 1923 1925 1924 IDropTarget_DragOver(trackerInfo->curDragTarget, 1926 1927 1928 1925 keyState, 1926 mousePosParam, 1927 trackerInfo->pdwEffect); 1929 1928 } 1930 1929 else 1931 1930 { 1932 1931 DropTargetNode* newDropTargetNode = 0; 1933 1932 1934 1933 /* 1935 1934 * If we changed window, we have to notify our old target and check for … … 1940 1939 IDropTarget_DragLeave(trackerInfo->curDragTarget); 1941 1940 } 1942 1941 1943 1942 /* 1944 1943 * Make sure we're hovering over a window. … … 1951 1950 HWND nexttar = hwndNewTarget; 1952 1951 do { 1953 1952 newDropTargetNode = OLEDD_FindDropTarget(nexttar); 1954 1953 } while (!newDropTargetNode && (nexttar = GetParent(nexttar)) != 0); 1955 1954 if(nexttar) hwndNewTarget = nexttar; … … 1957 1956 trackerInfo->curDragTargetHWND = hwndNewTarget; 1958 1957 trackerInfo->curDragTarget = newDropTargetNode ? newDropTargetNode->dropTarget : 0; 1959 1958 1960 1959 /* 1961 1960 * If there is, notify it that we just dragged-in … … 1963 1962 if (trackerInfo->curDragTarget!=0) 1964 1963 { 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1964 POINTL mousePosParam; 1965 1966 /* 1967 * The documentation tells me that the coordinate should be in the target 1968 * window's coordinate space. However, the tests I made tell me the 1969 * coordinates should be in screen coordinates. 1970 */ 1971 mousePosParam.x = mousePos.x; 1972 mousePosParam.y = mousePos.y; 1973 1974 IDropTarget_DragEnter(trackerInfo->curDragTarget, 1975 trackerInfo->dataObject, 1976 keyState, 1977 mousePosParam, 1978 trackerInfo->pdwEffect); 1980 1979 } 1981 1980 } … … 1991 1990 1992 1991 /* 1993 * Now that we have done that, we have to tell the source to give 1994 * us feedback on the work being done by the target. If we don't 1992 * Now that we have done that, we have to tell the source to give 1993 * us feedback on the work being done by the target. If we don't 1995 1994 * have a target, simulate no effect. 1996 1995 */ … … 2001 2000 2002 2001 hr = IDropSource_GiveFeedback(trackerInfo->dropSource, 2003 2002 *trackerInfo->pdwEffect); 2004 2003 2005 2004 /* … … 2027 2026 SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(0))); 2028 2027 } 2029 } 2028 } 2030 2029 } 2031 2030 … … 2055 2054 */ 2056 2055 trackerInfo->returnValue = IDropSource_QueryContinueDrag( 2057 2058 trackerInfo->escPressed, 2059 2060 2056 trackerInfo->dropSource, 2057 trackerInfo->escPressed, 2058 keyState); 2059 2061 2060 /* 2062 2061 * All the return valued will stop the operation except the S_OK … … 2071 2070 2072 2071 /* 2073 * Release the mouse in case the drop target decides to show a popup 2072 * Release the mouse in case the drop target decides to show a popup 2074 2073 * or a menu or something. 2075 2074 */ 2076 2075 ReleaseCapture(); 2077 2076 2078 2077 /* 2079 * If we end-up over a target, drop the object in the target or 2078 * If we end-up over a target, drop the object in the target or 2080 2079 * inform the target that the operation was cancelled. 2081 2080 */ … … 2084 2083 switch (trackerInfo->returnValue) 2085 2084 { 2086 2087 * If the source wants us to complete the operation, we tell 2088 2089 2085 /* 2086 * If the source wants us to complete the operation, we tell 2087 * the drop target that we just dropped the object in it. 2088 */ 2090 2089 case DRAGDROP_S_DROP: 2091 2092 2093 2094 2095 * The documentation tells me that the coordinate should be 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 * If the source told us that we should cancel, fool the drop 2111 2112 * Also set the drop effect to "NONE" in case the application 2113 2114 2090 { 2091 POINTL mousePosParam; 2092 2093 /* 2094 * The documentation tells me that the coordinate should be 2095 * in the target window's coordinate space. However, the tests 2096 * I made tell me the coordinates should be in screen coordinates. 2097 */ 2098 mousePosParam.x = mousePos.x; 2099 mousePosParam.y = mousePos.y; 2100 2101 IDropTarget_Drop(trackerInfo->curDragTarget, 2102 trackerInfo->dataObject, 2103 keyState, 2104 mousePosParam, 2105 trackerInfo->pdwEffect); 2106 break; 2107 } 2108 /* 2109 * If the source told us that we should cancel, fool the drop 2110 * target by telling it that the mouse left it's window. 2111 * Also set the drop effect to "NONE" in case the application 2112 * ignores the result of DoDragDrop. 2113 */ 2115 2114 case DRAGDROP_S_CANCEL: 2116 2117 2118 2115 IDropTarget_DragLeave(trackerInfo->curDragTarget); 2116 *trackerInfo->pdwEffect = DROPEFFECT_NONE; 2117 break; 2119 2118 } 2120 2119 } … … 2163 2162 * params: 2164 2163 * regKey - Key to read the default value from 2165 * pdwValue - Pointer to the location where the DWORD 2164 * pdwValue - Pointer to the location where the DWORD 2166 2165 * value is returned. This value is not modified 2167 2166 * if the value is not found. … … 2169 2168 2170 2169 static void OLEUTL_ReadRegistryDWORDValue( 2171 HKEY regKey, 2170 HKEY regKey, 2172 2171 DWORD* pdwValue) 2173 2172 { … … 2178 2177 2179 2178 lres = RegQueryValueExA(regKey, 2180 2181 2182 2183 2184 2179 "", 2180 NULL, 2181 &dwKeyType, 2182 (LPBYTE)buffer, 2183 &cbData); 2185 2184 2186 2185 if (lres==ERROR_SUCCESS) … … 2189 2188 { 2190 2189 case REG_DWORD: 2191 2192 2190 *pdwValue = *(DWORD*)buffer; 2191 break; 2193 2192 case REG_EXPAND_SZ: 2194 2193 case REG_MULTI_SZ: 2195 2194 case REG_SZ: 2196 2197 2195 *pdwValue = (DWORD)strtoul(buffer, NULL, 10); 2196 break; 2198 2197 } 2199 2198 } … … 2210 2209 */ 2211 2210 HGLOBAL16 WINAPI OleMetaFilePictFromIconAndLabel16( 2212 2213 2214 2215 2211 HICON16 hIcon, 2212 LPCOLESTR16 lpszLabel, 2213 LPCOLESTR16 lpszSourceFile, 2214 UINT16 iIconIndex 2216 2215 ) { 2217 2216 METAFILEPICT16 *mf; … … 2223 2222 if (!hIcon) { 2224 2223 if (lpszSourceFile) { 2225 2226 2227 2228 2229 2230 2231 2224 HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile); 2225 2226 /* load the icon at index from lpszSourceFile */ 2227 hIcon = (HICON16)LoadIconA(hInstance, (LPCSTR)(DWORD)iIconIndex); 2228 FreeLibrary16(hInstance); 2229 } else 2230 return (HGLOBAL)NULL; 2232 2231 } 2233 2232
Note:
See TracChangeset
for help on using the changeset viewer.