Changeset 8553 for trunk/src/user32/dragdrop.cpp
- Timestamp:
- Jun 2, 2002, 9:34:36 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/dragdrop.cpp
r8542 r8553 1 /* $Id: dragdrop.cpp,v 1. 1 2002-06-02 10:08:09sandervl Exp $ */1 /* $Id: dragdrop.cpp,v 1.2 2002-06-02 19:34:25 sandervl Exp $ */ 2 2 3 3 /* … … 11 11 #include <windows.h> 12 12 #include <dbglog.h> 13 #include <oledd.h> 13 14 14 15 #define DBG_LOCALLOG DBG_dragdrop 15 16 #include "dbglocal.h" 16 17 18 static PFN_DRAGENTER pfnDragEnter = NULL; 19 static PFN_DRAGLEAVE pfnDragLeave = NULL; 20 static PFN_DROPFILES pfnDropFiles = NULL; 21 static PFN_DRAGOVER pfnDragOver = NULL; 22 static PFN_ACCEPTSDRAGDROP pfnAcceptsDragDrop = NULL; 23 static HANDLE hOLE32 = 0; 24 17 25 //****************************************************************************** 18 26 //****************************************************************************** 19 ULONG DragDropFiles(HWND hwnd, UINT cFiles, POINT point, LPSTR pszFiles, UINT cbszFiles, BOOL fNonClient)27 ULONG DragDropFiles(HWND hwnd, POINT point, UINT cFiles, LPSTR pszFiles, UINT cbszFiles, BOOL fNonClient) 20 28 { 21 29 DROPFILES *pDropFile; 22 30 HGLOBAL hDropFile; 23 31 DWORD dwExStyle; 32 HWND orghwnd = hwnd; 24 33 25 34 dwExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE); 26 35 27 // Is it correct if the window or parent accepts files or must we check the topparentparent?36 //TODO: Is it correct if the window or parent accepts files or must we check the top parent? 28 37 hwnd = (dwExStyle & WS_EX_ACCEPTFILES) ? hwnd : GetParent(hwnd); 38 39 dwExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE); 40 if(!(dwExStyle & WS_EX_ACCEPTFILES)) { 41 if(pfnDropFiles) { 42 return pfnDropFiles(hwnd); 43 } 44 return FALSE; 45 } 29 46 cbszFiles++; //extra terminating 0 30 31 if(IsWindowUnicode(hwnd)) {32 dprintf(("unicode dropfiles"));33 cbszFiles *= 2;34 }35 36 47 hDropFile = GlobalAlloc(0, sizeof(DROPFILES)+cbszFiles); 37 48 pDropFile = (DROPFILES *)GlobalLock(hDropFile); … … 42 53 pDropFile->pFiles = sizeof(DROPFILES); 43 54 pDropFile->fNC = fNonClient; 44 pDropFile->fWide = ::IsWindowUnicode(hwnd);55 pDropFile->fWide = FALSE; 45 56 pDropFile->pt = point; 46 if(IsWindowUnicode(hwnd)) { 47 LPWSTR lpszFilesW = (LPWSTR)(pDropFile+1); 48 while(*pszFiles) { 49 int len = strlen(pszFiles); 50 MultiByteToWideChar(CP_ACP, 0, pszFiles, -1, lpszFilesW, len); 51 pszFiles += len + 1; 52 lpszFilesW += len + 1; 53 } 54 *lpszFilesW = 0; 55 } 56 else { 57 //copy strings (excluding terminating 0) 58 memcpy((pDropFile+1), pszFiles, cbszFiles-1); 59 } 57 //copy strings (excluding terminating 0) 58 memcpy((pDropFile+1), pszFiles, cbszFiles-1); 60 59 GlobalUnlock(hDropFile); 61 60 SendMessageA(hwnd, WM_DROPFILES, hDropFile, 0); 62 61 return 0; 62 } 63 //****************************************************************************** 64 //****************************************************************************** 65 BOOL DragDropDragOver(HWND hwnd, DWORD dwEffect) 66 { 67 if(pfnDragOver) { 68 return pfnDragOver(hwnd, dwEffect); 69 } 70 return TRUE; //ignore 71 } 72 //****************************************************************************** 73 //****************************************************************************** 74 BOOL DragDropDragEnter(HWND hwnd, POINT point, UINT cFiles, LPSTR pszFiles, UINT cbszFiles, 75 DWORD dwEffect, BOOL fNonClient) 76 { 77 DROPFILES *pDropFile; 78 HGLOBAL hDropFile; 79 80 if(pfnDragEnter) { 81 cbszFiles++; //extra terminating 0 82 hDropFile = GlobalAlloc(0, sizeof(DROPFILES)+cbszFiles); 83 pDropFile = (DROPFILES *)GlobalLock(hDropFile); 84 if(pDropFile == NULL) { 85 DebugInt3(); 86 return FALSE; 87 } 88 pDropFile->pFiles = sizeof(DROPFILES); 89 pDropFile->fNC = fNonClient; 90 pDropFile->fWide = FALSE; 91 pDropFile->pt = point; 92 //copy strings (excluding terminating 0) 93 memcpy((pDropFile+1), pszFiles, cbszFiles-1); 94 GlobalUnlock(hDropFile); 95 96 return pfnDragEnter(hwnd, hDropFile, dwEffect); 97 } 98 return TRUE; //ignore 99 } 100 //****************************************************************************** 101 //****************************************************************************** 102 BOOL DragDropDragLeave(HWND hwnd) 103 { 104 if(pfnDragLeave) { 105 return pfnDragLeave(hwnd); 106 } 107 return TRUE; //ignore 63 108 } 64 109 //****************************************************************************** … … 75 120 DWORD dwStyle = GetWindowLongA(GetParent(hwnd), GWL_EXSTYLE); 76 121 if(!(dwStyle & WS_EX_ACCEPTFILES)) { 122 if(pfnAcceptsDragDrop == NULL) { 123 //check for OLE drag & drop 124 125 hOLE32 = GetModuleHandleA("OLE32.DLL"); 126 if(hOLE32 == 0) { 127 //if ole32.dll isn't loaded, then ole drag and drop can't be active 128 return FALSE; 129 } 130 //make sure the dll doesn't get unloaded 131 hOLE32 = LoadLibraryA("OLE32.DLL"); 132 133 pfnAcceptsDragDrop = (PFN_ACCEPTSDRAGDROP)GetProcAddress(hOLE32, "OLEDD_AcceptsDragDrop"); 134 pfnDragOver = (PFN_DRAGOVER)GetProcAddress(hOLE32, "OLEDD_DragOver"); 135 pfnDragLeave = (PFN_DRAGLEAVE)GetProcAddress(hOLE32, "OLEDD_DragLeave"); 136 pfnDragEnter = (PFN_DRAGENTER)GetProcAddress(hOLE32, "OLEDD_DragEnter"); 137 pfnDropFiles = (PFN_DROPFILES)GetProcAddress(hOLE32, "OLEDD_DropFiles"); 138 if(!pfnAcceptsDragDrop || !pfnDragOver || !pfnDragLeave || !pfnDragEnter || !pfnDropFiles) { 139 dprintf(("OLE DD functions not found!!")); 140 DebugInt3(); 141 return FALSE; 142 } 143 } 144 if(pfnAcceptsDragDrop) { 145 return pfnAcceptsDragDrop(hwnd); 146 } 77 147 return FALSE; 78 148 }
Note:
See TracChangeset
for help on using the changeset viewer.