Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

menuddc.c File Reference

#include "precomp.h"
#include "initguid.h"

Go to the source code of this file.

Defines

#define PMNIDT(pdt)   ((PMNIDROPTARGET)pdt)

Functions

ULONG mndtAddRef (LPDROPTARGET pdt)
HRESULT mndtQueryInterface (LPDROPTARGET pdt, REFIID riid, PVOID *ppvObj)
ULONG mndtRelease (LPDROPTARGET pdt)
HRESULT mndtDragOver (LPDROPTARGET pdt, DWORD grfKeyState, POINTL ptl, LPDWORD pdwEffect)
HRESULT mndtDragEnter (LPDROPTARGET pdt, LPDATAOBJECT pdo, DWORD grfKeyState, POINTL ptl, LPDWORD pdwEffect)
HRESULT mndtDragLeave (LPDROPTARGET pdt)
HRESULT mndtDrop (LPDROPTARGET pdt, LPDATAOBJECT pdo, DWORD grfKeyState, POINTL ptl, LPDWORD pdwEffect)
DWORD __ClientRegisterDragDrop (HWND *phwnd)
DWORD __ClientRevokeDragDrop (HWND *phwnd)
NTSTATUS LoadOLEOnce (void)
DWORD __ClientLoadOLE (PVOID p)

Variables

IDropTargetVtbl idtVtbl


Define Documentation

#define PMNIDT pdt   )     ((PMNIDROPTARGET)pdt)
 

Definition at line 22 of file menuddc.c.

Referenced by mndtAddRef(), mndtDragEnter(), mndtDragLeave(), mndtDragOver(), mndtDrop(), and mndtRelease().


Function Documentation

DWORD __ClientLoadOLE PVOID  p  ) 
 

Definition at line 362 of file menuddc.c.

References DWORD, ghinstOLE, gpfnOLERegisterDD, gpfnOLERevokeDD, LoadOLEOnce(), NTSTATUS(), NULL, OLEWONTLOAD, Status, and UserCallbackReturn.

00362 { 00363 00364 NTSTATUS Status; 00365 00366 UNREFERENCED_PARAMETER(p); 00367 00368 if (ghinstOLE == NULL) { 00369 Status = LoadOLEOnce(); 00370 } else if (ghinstOLE == OLEWONTLOAD) { 00371 Status = STATUS_UNSUCCESSFUL; 00372 } else { 00373 UserAssert(gpfnOLERegisterDD != NULL); 00374 UserAssert(gpfnOLERevokeDD != NULL); 00375 Status = STATUS_SUCCESS; 00376 } 00377 00378 return UserCallbackReturn(NULL, 0, Status); 00379 }

DWORD __ClientRegisterDragDrop HWND *  phwnd  ) 
 

Definition at line 224 of file menuddc.c.

References DWORD, gpfnOLERegisterDD, tagMNIDROPTARGET::idt, idtVtbl, MNIDROPTARGET, NULL, PMNIDROPTARGET, REGISTERDDPROC, and UserCallbackReturn.

00225 { 00226 HRESULT hres = STATUS_UNSUCCESSFUL; 00227 PMNIDROPTARGET pmnidt; 00228 00229 /* 00230 * Allocate the IDropTarget interface struct & additional data 00231 */ 00232 pmnidt = (PMNIDROPTARGET)LocalAlloc(LPTR, sizeof(MNIDROPTARGET)); 00233 if (pmnidt == NULL) { 00234 RIPMSG0(RIP_WARNING, "__ClientRegisterDragDrop allocation Failed"); 00235 hres = STATUS_UNSUCCESSFUL; 00236 goto BackToKernel; 00237 } 00238 00239 /* 00240 * Initialize it 00241 */ 00242 pmnidt->idt.lpVtbl = &idtVtbl; 00243 00244 /* 00245 * Call RegisterDragDrop 00246 */ 00247 hres = (*(REGISTERDDPROC)gpfnOLERegisterDD)(*phwnd, (LPDROPTARGET)pmnidt); 00248 if (!SUCCEEDED(hres)) { 00249 RIPMSG1(RIP_WARNING, "__ClientRegisterDragDrop Failed:%#lx", hres); 00250 } 00251 00252 BackToKernel: 00253 return UserCallbackReturn(NULL, 0, hres); 00254 }

DWORD __ClientRevokeDragDrop HWND *  phwnd  ) 
 

Definition at line 261 of file menuddc.c.

References DWORD, gpfnOLERevokeDD, NULL, REVOKEDDPROC, and UserCallbackReturn.

00262 { 00263 HRESULT hres; 00264 00265 /* 00266 * Call RevokeDragDrop 00267 */ 00268 hres = (*(REVOKEDDPROC)gpfnOLERevokeDD)(*phwnd); 00269 if (!SUCCEEDED(hres)) { 00270 RIPMSG1(RIP_WARNING, "__ClientRevokeDragDrop Failed:%#lx", hres); 00271 } 00272 00273 return UserCallbackReturn(NULL, 0, hres); 00274 }

NTSTATUS LoadOLEOnce void   ) 
 

Definition at line 281 of file menuddc.c.

References GETPROCINFO, ghinstOLE, gpfnOLEOleUninitialize, gpfnOLERegisterDD, gpfnOLERevokeDD, L, tagGETPROCINFO::lpsz, NTSTATUS(), NULL, OLEINITIALIZEPROC, OLEWONTLOAD, tagGETPROCINFO::ppfn, and Status.

Referenced by __ClientLoadOLE().

00281 { 00282 00283 NTSTATUS Status = STATUS_SUCCESS; 00284 OLEINITIALIZEPROC pfnOLEOleInitialize; 00285 00286 /* 00287 * These are the functions that we'll call. 00288 */ 00289 GETPROCINFO gpi [] = { 00290 {&((FARPROC)pfnOLEOleInitialize), (LPCSTR)"OleInitialize"}, 00291 {&gpfnOLEOleUninitialize, (LPCSTR)"OleUninitialize"}, 00292 {&gpfnOLERegisterDD, (LPCSTR)"RegisterDragDrop"}, 00293 {&gpfnOLERevokeDD, (LPCSTR)"RevokeDragDrop"}, 00294 {NULL, NULL} 00295 }; 00296 00297 GETPROCINFO * pgpi = gpi; 00298 00299 /* 00300 * We should come here only once 00301 */ 00302 UserAssert(ghinstOLE == NULL); 00303 00304 /* 00305 * Load it 00306 */ 00307 ghinstOLE = LoadLibrary(L"OLE32.DLL"); 00308 if (ghinstOLE == NULL) { 00309 RIPMSG1(RIP_WARNING, "LoadOLEOnce: Failed to load OLE32.DLL: %#lx", GetLastError()); 00310 goto OLEWontLoad; 00311 } 00312 00313 /* 00314 * Get the address of all procs 00315 */ 00316 while (pgpi->ppfn != NULL) { 00317 *(pgpi->ppfn) = GetProcAddress(ghinstOLE, pgpi->lpsz); 00318 if (*(pgpi->ppfn) == NULL) { 00319 RIPMSG2(RIP_WARNING, "LoadOLEOnce: GetProcAddress failed: '%s': %#lx", 00320 pgpi->lpsz, GetLastError()); 00321 break; 00322 } 00323 pgpi++; 00324 } 00325 00326 /* 00327 * If it got all procs, call OleInitialize 00328 */ 00329 if (pgpi->ppfn == NULL) { 00330 Status = (*pfnOLEOleInitialize)(NULL); 00331 if (SUCCEEDED(Status)) { 00332 goto BackToKernel; 00333 } else { 00334 RIPMSG1(RIP_WARNING, "LoadOLEOnce: OleInitialize failed:%#lx", Status); 00335 } 00336 } 00337 00338 /* 00339 * Something failed; NULL out all function pointers 00340 * free the library and mark hinstOLE so we won't comeback here 00341 */ 00342 pgpi = gpi; 00343 while (pgpi->ppfn != NULL) { 00344 *(pgpi->ppfn) = NULL; 00345 pgpi++; 00346 } 00347 FreeLibrary(ghinstOLE); 00348 00349 OLEWontLoad: 00350 ghinstOLE = OLEWONTLOAD; 00351 Status = STATUS_UNSUCCESSFUL; 00352 00353 BackToKernel: 00354 return Status; 00355 }

ULONG mndtAddRef LPDROPTARGET  pdt  ) 
 

Definition at line 32 of file menuddc.c.

References PMNIDT.

Referenced by mndtQueryInterface().

00033 { 00034 return ++(PMNIDT(pdt)->dwRefCount); 00035 }

HRESULT mndtDragEnter LPDROPTARGET  pdt,
LPDATAOBJECT  pdo,
DWORD  grfKeyState,
POINTL  ptl,
LPDWORD  pdwEffect
 

Definition at line 139 of file menuddc.c.

References mndtDragOver(), and PMNIDT.

00140 { 00141 /* 00142 * Save the IDataObject 00143 */ 00144 PMNIDT(pdt)->pido = pdo; 00145 00146 /* 00147 * DragEnter is the same as a DragOver; only that we will never fail it 00148 */ 00149 mndtDragOver(pdt, grfKeyState, ptl, pdwEffect); 00150 00151 return NOERROR; 00152 }

HRESULT mndtDragLeave LPDROPTARGET  pdt  ) 
 

Definition at line 158 of file menuddc.c.

References NtUserMNDragLeave(), NULL, and PMNIDT.

Referenced by mndtDrop().

00159 { 00160 /* 00161 * Let the kernel mode clean up 00162 */ 00163 NtUserMNDragLeave(); 00164 00165 /* 00166 * DragLeave and Release the current item, if any 00167 */ 00168 if (PMNIDT(pdt)->pidt != NULL) { 00169 PMNIDT(pdt)->pidt->lpVtbl->DragLeave(PMNIDT(pdt)->pidt); 00170 PMNIDT(pdt)->pidt->lpVtbl->Release(PMNIDT(pdt)->pidt); 00171 PMNIDT(pdt)->pidt = NULL; 00172 } 00173 00174 return NOERROR; 00175 }

HRESULT mndtDragOver LPDROPTARGET  pdt,
DWORD  grfKeyState,
POINTL  ptl,
LPDWORD  pdwEffect
 

Definition at line 74 of file menuddc.c.

References tagMNDRAGOVERINFO::dwFlags, tagMNDRAGOVERINFO::hmenu, tagMNDRAGOVERINFO::hwndNotify, MFMWFP_NOITEM, MNDRAGOVERINFO, NtUserMNDragOver(), NULL, PMNIDT, SendMessage(), and tagMNDRAGOVERINFO::uItemIndex.

Referenced by mndtDragEnter().

00075 { 00076 MNDRAGOVERINFO mndoi; 00077 MENUGETOBJECTINFO mngoi; 00078 00079 /* 00080 * Get the dragover info for the selection corresponding to this point 00081 */ 00082 if (!NtUserMNDragOver((POINT *)&ptl, &mndoi)) { 00083 RIPMSG0(RIP_WARNING, "mndtDragOver: NtUserDragOver failed"); 00084 *pdwEffect = DROPEFFECT_NONE; 00085 return NOERROR; 00086 } 00087 00088 /* 00089 * If not switching items or crossing gap boundaries, pass the 00090 * the drag over. 00091 */ 00092 if (!(mndoi.dwFlags & MNGOF_CROSSBOUNDARY)) { 00093 if (PMNIDT(pdt)->pidt != NULL) { 00094 return PMNIDT(pdt)->pidt->lpVtbl->DragOver(PMNIDT(pdt)->pidt, grfKeyState, ptl, pdwEffect); 00095 } 00096 } else { 00097 /* 00098 * DragLeave and Release the current item, if any 00099 */ 00100 if (PMNIDT(pdt)->pidt != NULL) { 00101 PMNIDT(pdt)->pidt->lpVtbl->DragLeave(PMNIDT(pdt)->pidt); 00102 PMNIDT(pdt)->pidt->lpVtbl->Release(PMNIDT(pdt)->pidt); 00103 PMNIDT(pdt)->pidt = NULL; 00104 } 00105 00106 /* 00107 * If an item is selected, Get the interface for it 00108 */ 00109 if (mndoi.uItemIndex != MFMWFP_NOITEM) { 00110 mngoi.hmenu = mndoi.hmenu; 00111 mngoi.dwFlags = mndoi.dwFlags & MNGOF_GAP; 00112 mngoi.uPos = mndoi.uItemIndex; 00113 mngoi.riid = (PVOID)&IID_IDropTarget; 00114 mngoi.pvObj = NULL; 00115 00116 if (MNGO_NOERROR == SendMessage(mndoi.hwndNotify, WM_MENUGETOBJECT, 0, (LPARAM)&mngoi)) { 00117 PMNIDT(pdt)->pidt = mngoi.pvObj; 00118 } 00119 } 00120 00121 /* 00122 * If we got a new interface, AddRef and DragEnter it 00123 */ 00124 if (PMNIDT(pdt)->pidt != NULL) { 00125 PMNIDT(pdt)->pidt->lpVtbl->AddRef(PMNIDT(pdt)->pidt); 00126 return PMNIDT(pdt)->pidt->lpVtbl->DragEnter(PMNIDT(pdt)->pidt, PMNIDT(pdt)->pido, grfKeyState, ptl, pdwEffect); 00127 } 00128 } /* if (!(mndoi.dwFlags & MNGOF_CROSSBOUNDARY)) */ 00129 00130 *pdwEffect = DROPEFFECT_NONE; 00131 return NOERROR; 00132 }

HRESULT mndtDrop LPDROPTARGET  pdt,
LPDATAOBJECT  pdo,
DWORD  grfKeyState,
POINTL  ptl,
LPDWORD  pdwEffect
 

Definition at line 182 of file menuddc.c.

References mndtDragLeave(), NULL, and PMNIDT.

00183 { 00184 HRESULT hres; 00185 00186 /* 00187 * If we got a target, pass the drop and release it. 00188 */ 00189 if (PMNIDT(pdt)->pidt != NULL) { 00190 hres = PMNIDT(pdt)->pidt->lpVtbl->Drop(PMNIDT(pdt)->pidt, pdo, grfKeyState, ptl, pdwEffect); 00191 PMNIDT(pdt)->pidt->lpVtbl->Release(PMNIDT(pdt)->pidt); 00192 PMNIDT(pdt)->pidt = NULL; 00193 } else { 00194 *pdwEffect = DROPEFFECT_NONE; 00195 hres = NOERROR; 00196 } 00197 00198 /* 00199 * Clean up 00200 */ 00201 mndtDragLeave(pdt); 00202 00203 return hres; 00204 }

HRESULT mndtQueryInterface LPDROPTARGET  pdt,
REFIID  riid,
PVOID *  ppvObj
 

Definition at line 42 of file menuddc.c.

References mndtAddRef().

00043 { 00044 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDropTarget)) { 00045 mndtAddRef(pdt); 00046 *ppvObj = pdt; 00047 return NOERROR; 00048 } else { 00049 return E_NOINTERFACE; 00050 } 00051 }

ULONG mndtRelease LPDROPTARGET  pdt  ) 
 

Definition at line 59 of file menuddc.c.

References PMNIDT.

00060 { 00061 if (--(PMNIDT(pdt)->dwRefCount) != 0) { 00062 return PMNIDT(pdt)->dwRefCount; 00063 } 00064 00065 LocalFree(pdt); 00066 return NOERROR; 00067 }


Variable Documentation

IDropTargetVtbl idtVtbl
 

Initial value:

Definition at line 210 of file menuddc.c.

Referenced by __ClientRegisterDragDrop().


Generated on Sat May 15 19:44:38 2004 for test by doxygen 1.3.7